yuyijiong commited on
Commit
7d7aed1
1 Parent(s): f86a35b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md CHANGED
@@ -1,3 +1,45 @@
1
  ---
2
  license: cc-by-nc-4.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-4.0
3
+ datasets:
4
+ - yuyijiong/Long-Instruction-Chinese
5
+ language:
6
+ - zh
7
+ - en
8
+ pipeline_tag: text-generation
9
  ---
10
+ [LongAlpaca](https://huggingface.co/Yukang/LongAlpaca-7B)通过对 llama2-chat 进行少量长文本数据的微调,展现出了优秀的长文本对话能力。\
11
+ LongAlpaca-7b-chinese 和 LongAlpaca 使用类似的训练方法:先使用线性位置插值,然后通过少量长文本数据的微调,使其获得优秀的长文本对话能力。\
12
+ 此模型由atom-7b-chat经过lora微调得到, 通过线性位置插值,将文本长度从4k扩展到16k,可以完成上万字的多文档检索、论文总结等任务,而短对话能力几乎没有下降。\
13
+ 使用方法:
14
+ ```python
15
+ from transformers import AutoModelForCausalLM, AutoTokenizer
16
+ from transformers.generation import GenerationConfig
17
+ import os
18
+ os.environ["CUDA_VISIBLE_DEVICES"] = "0"
19
+
20
+ model_path="yuyijiong/LongAlpaca-7b-chinese"
21
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
22
+
23
+ # use auto mode, automatically select precision based on the device.
24
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", load_in_8bit=True).eval()
25
+
26
+ question="中国的首都是什么?"
27
+ input_text = "<s>Human: " + question + "\n</s><s>Assistant: "
28
+ input_ids = tokenizer(input_text, return_tensors='pt').input_ids.to(model.device)
29
+
30
+ with torch.no_grad():
31
+ with torch.autocast('cuda'):
32
+ output = model.generate(input_ids=input_ids,
33
+ max_new_tokens=max_new_tokens,
34
+ do_sample=True,
35
+ temperature=0.85,
36
+ top_k=None,
37
+ top_p=0.9,
38
+ use_cache=True,
39
+ **kwargs)
40
+
41
+ reply = tokenizer.decode(output[0], skip_special_tokens=False)
42
+ reply_return=reply.split('Assistant:')[-1].replace('</s>', '')
43
+
44
+ print('模型回答:', reply_return)
45
+ ```