Views
No views yet
7B) by Salesforce AI Research:pip:pip install tiktoken1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("Salesforce/xgen-7b-8k-inst", trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained("Salesforce/xgen-7b-8k-inst", torch_dtype=torch.bfloat16)
6
7header = (
8 "A chat between a curious human and an artificial intelligence assistant. "
9 "The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n"
10)
11article = "" # insert a document here
12prompt = f"### Human: Please summarize the following article.\n\n{article}.\n###"
13
14inputs = tokenizer(header + prompt, return_tensors="pt")
15sample = model.generate(**inputs, do_sample=True, max_new_tokens=2048, top_k=100, eos_token_id=50256)
16output = tokenizer.decode(sample[0])
17print(output.strip().replace("Assistant:", ""))1@misc{XGen,
2 title={Long Sequence Modeling with XGen: A 7B LLM Trained on 8K Input Sequence Length},
3 author={Erik Nijkamp, Tian Xie, Hiroaki Hayashi, Bo Pang, Congying Xia, Chen Xing, Jesse Vig, Semih Yavuz, Philippe Laban, Ben Krause, Senthil Purushwalkam, Tong Niu, Wojciech Kryscinski, Lidiya Murakhovs'ka, Prafulla Kumar Choubey, Alex Fabbri, Ye Liu, Rui Meng, Lifu Tu, Meghana Bhat, Chien-Sheng Wu, Silvio Savarese, Yingbo Zhou, Shafiq Rayhan Joty, Caiming Xiong},
4 howpublished={ArXiv},
5 year={2023},
6 url={https://arxiv.org/abs/2309.03450}
7}