SeqGPT-560M
This is SeqGPT-560M weight, a compact model targeting open-domain Natural Language Understanding (NLU). We refer you to our github repo for more details.
Model Details
Model Description
The model is fine-tuned based on BLOOMZ-560M.
Model Sources
Uses
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoModel
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))
- Downloads last month
- 66