Yirany commited on
Commit
589f886
1 Parent(s): 40d619e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -0
README.md CHANGED
@@ -1,3 +1,63 @@
1
  ---
2
  license: apache-2.0
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
  ---
7
+ # SeqGPT-560M
8
+
9
+ <!-- Provide a quick summary of what the model is/does. -->
10
+
11
+ This is SeqGPT-560M weight, a compact model targeting open-domain Natural Language Understanding (NLU). We refer you to our github [repo](https://github.com/Alibaba-NLP/SeqGPT) for more details.
12
+
13
+
14
+ ## Model Details
15
+
16
+ ### Model Description
17
+
18
+ <!-- Provide a longer summary of what this model is. -->
19
+
20
+ The model is fine-tuned based on [BLOOMZ-560M](https://huggingface.co/bigscience/bloomz-560m).
21
+
22
+ ### Model Sources
23
+
24
+ <!-- Provide the basic links for the model. -->
25
+
26
+ - **Repository:** [SeqGPT](https://github.com/Alibaba-NLP/SeqGPT)
27
+ - **Paper:** [arxiv](https://arxiv.org/abs/2308.10529)
28
+ - **Demo:** [demo](https://www.modelscope.cn/studios/TTCoding/open_ner/summary)
29
+
30
+ ## Uses
31
+
32
+
33
+ ```py
34
+ import torch
35
+ from transformers import AutoTokenizer, AutoModelForCausalLM, AutoModel
36
+
37
+ model_name_or_path = 'Yirany/SeqGPT-560M'
38
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
39
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path)
40
+ tokenizer.padding_side = 'left'
41
+ tokenizer.truncation_side = 'left'
42
+
43
+ if torch.cuda.is_available():
44
+ model = model.half().cuda()
45
+ model.eval()
46
+ GEN_TOK = '[GEN]'
47
+
48
+ while True:
49
+ sent = input('输入/Input: ').strip()
50
+ task = input('分类/classify press 1, 抽取/extract press 2: ').strip()
51
+ labels = input('标签集/Label-Set (e.g, labelA,LabelB,LabelC): ').strip().replace(',', ',')
52
+ task = '分类' if task == '1' else '抽取'
53
+
54
+ # Changing the instruction can harm the performance
55
+ p = '输入: {}\n{}: {}\n输出: {}'.format(sent, task, labels, GEN_TOK)
56
+ input_ids = tokenizer(p, return_tensors="pt", padding=True, truncation=True, max_length=1024)
57
+ input_ids = input_ids.to(model.device)
58
+ outputs = model.generate(**input_ids, num_beams=4, do_sample=False, max_new_tokens=256)
59
+ input_ids = input_ids.get('input_ids', input_ids)
60
+ outputs = outputs[0][len(input_ids[0]):]
61
+ response = tokenizer.decode(outputs, skip_special_tokens=True)
62
+ print('BOT: ========== \n{}'.format(response))
63
+ ```