yuyijiong commited on
Commit
a533dde
1 Parent(s): 195ded0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -33
README.md CHANGED
@@ -6,7 +6,42 @@ language:
6
  - zh
7
  pipeline_tag: text-generation
8
  ---
9
- 示例
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ```
11
  先阅读以下多个参考文档,然后根据文档内容,详细地回答问题,并指出所参考的文档的序号:
12
 
@@ -75,36 +110,4 @@ pipeline_tag: text-generation
75
  以上回答参考了文档-43。
76
  ```
77
 
78
- 使用方法:
79
- ```python
80
- from transformers import AutoModelForCausalLM, AutoTokenizer
81
- from transformers.generation import GenerationConfig
82
- import os
83
- os.environ["CUDA_VISIBLE_DEVICES"] = "0"
84
-
85
- model_path="yuyijiong/atom-7b-chat-16k"
86
- tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
87
-
88
- # use auto mode, automatically select precision based on the device.
89
- model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", load_in_8bit=True).eval()
90
-
91
- question="中国的首都是什么?"
92
- input_text = "<s>Human: " + question + "\n</s><s>Assistant: "
93
- input_ids = tokenizer(input_text, return_tensors='pt').input_ids.to(model.device)
94
 
95
- with torch.no_grad():
96
- with torch.autocast('cuda'):
97
- output = model.generate(input_ids=input_ids,
98
- max_new_tokens=max_new_tokens,
99
- do_sample=True,
100
- temperature=0.85,
101
- top_k=None,
102
- top_p=0.9,
103
- use_cache=True,
104
- **kwargs)
105
-
106
- reply = tokenizer.decode(output[0], skip_special_tokens=False)
107
- reply_return=reply.split('Assistant:')[-1].replace('</s>', '')
108
- print('模型回答:', reply_return)
109
-
110
- ```
 
6
  - zh
7
  pipeline_tag: text-generation
8
  ---
9
+ 此模型由[atom-7b-chat](https://huggingface.co/FlagAlpha/Atom-7B-Chat)经过lora微调得到,通过线性位置插值,将文本长度从4k扩展到16k,可以完成多文档检索、论文总结等任务。\
10
+ 此版本为v1,初步具有长对话能力,但回答错误依然较多,可能是因为微调数据质量低([yuyijiong/LongData-instruction-chinese](https://huggingface.co/datasets/yuyijiong/LongData-instruction-chinese) 都是谷歌翻译过来的英文数据)。未来将会持续改进,改进版本很快推出。\
11
+ 使用方法:
12
+ ```python
13
+ from transformers import AutoModelForCausalLM, AutoTokenizer
14
+ from transformers.generation import GenerationConfig
15
+ import os
16
+ os.environ["CUDA_VISIBLE_DEVICES"] = "0"
17
+
18
+ model_path="yuyijiong/atom-7b-chat-16k"
19
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
20
+
21
+ # use auto mode, automatically select precision based on the device.
22
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", load_in_8bit=True).eval()
23
+
24
+ question="中国的首都是什么?"
25
+ input_text = "<s>Human: " + question + "\n</s><s>Assistant: "
26
+ input_ids = tokenizer(input_text, return_tensors='pt').input_ids.to(model.device)
27
+
28
+ with torch.no_grad():
29
+ with torch.autocast('cuda'):
30
+ output = model.generate(input_ids=input_ids,
31
+ max_new_tokens=max_new_tokens,
32
+ do_sample=True,
33
+ temperature=0.85,
34
+ top_k=None,
35
+ top_p=0.9,
36
+ use_cache=True,
37
+ **kwargs)
38
+
39
+ reply = tokenizer.decode(output[0], skip_special_tokens=False)
40
+ reply_return=reply.split('Assistant:')[-1].replace('</s>', '')
41
+ print('模型回答:', reply_return)
42
+ ```
43
+
44
+ 示例(多文档检索(问答)任务,输入文本大于10000字)
45
  ```
46
  先阅读以下多个参考文档,然后根据文档内容,详细地回答问题,并指出所参考的文档的序号:
47
 
 
110
  以上回答参考了文档-43。
111
  ```
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113