### Install SeqGPT Project Dependencies Source: https://github.com/alibaba-nlp/seqgpt/blob/main/README.md This shell script provides commands to create a dedicated Conda environment for SeqGPT with Python 3.8.16, activate it, and then install all required dependencies listed in the `requirements.txt` file. This ensures a consistent and isolated development environment. ```sh conda create -n seqgpt python==3.8.16 conda activate seqgpt pip install -r requirements.txt ``` -------------------------------- ### Perform Inference with SeqGPT-560M Model Source: https://github.com/alibaba-nlp/seqgpt/blob/main/README.md This Python script demonstrates how to load the SeqGPT-560M model and its tokenizer from Hugging Face. It sets up the model for inference on a GPU if available, and provides an interactive loop to take user input for sentences, task types (classification or extraction), and label sets, then generates and prints the model's response. The instruction format is crucial for performance. ```python from transformers import AutoTokenizer, AutoModelForCausalLM, AutoModel import torch model_name_or_path = 'DAMO-NLP/SeqGPT-560M' tokenizer = AutoTokenizer.from_pretrained(model_name_or_path) model = AutoModelForCausalLM.from_pretrained(model_name_or_path) tokenizer.padding_side = 'left' tokenizer.truncation_side = 'left' if torch.cuda.is_available(): model = model.half().cuda() model.eval() GEN_TOK = '[GEN]' while True: sent = input('输入/Input: ').strip() task = input('分类/classify press 1, 抽取/extract press 2: ').strip() labels = input('标签集/Label-Set (e.g, labelA,LabelB,LabelC): ').strip().replace(',', ',') task = '分类' if task == '1' else '抽取' # Changing the instruction can harm the performance p = '输入: {}\n{}: {}\n输出: {}'.format(sent, task, labels, GEN_TOK) input_ids = tokenizer(p, return_tensors="pt", padding=True, truncation=True, max_length=1024) input_ids = input_ids.to(model.device) outputs = model.generate(**input_ids, num_beams=4, do_sample=False, max_new_tokens=256) input_ids = input_ids.get('input_ids', input_ids) outputs = outputs[0][len(input_ids[0]):] response = tokenizer.decode(outputs, skip_special_tokens=True) print('BOT: ========== \n{}'.format(response)) ``` -------------------------------- ### Cite SeqGPT Research Paper Source: https://github.com/alibaba-nlp/seqgpt/blob/main/README.md This BibTeX entry provides the standard academic citation format for the SeqGPT research paper, titled 'SeqGPT: An Out-of-the-box Large Language Model for Open Domain Sequence Understanding'. It includes all necessary author, title, year, and arXiv details for proper referencing in scientific publications. ```bibtex @misc{yu2023seqgpt, title={SeqGPT: An Out-of-the-box Large Language Model for Open Domain Sequence Understanding}, author={Tianyu Yu and Chengyue Jiang and Chao Lou and Shen Huang and Xiaobin Wang and Wei Liu and Jiong Cai and Yangning Li and Yinghui Li and Kewei Tu and Hai-Tao Zheng and Ningyu Zhang and Pengjun Xie and Fei Huang and Yong Jiang}, year={2023}, eprint={2308.10529}, archivePrefix={arXiv}, primaryClass={cs.CL} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.