tiansz commited on
Commit
ff4222c
·
1 Parent(s): 422096f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - en
5
+ pipeline_tag: text2text-generation
6
+ ---
7
+
8
+ You can see more detail in this [repo](https://github.com/clue-ai/ChatYuan-7B)
9
+
10
+
11
+ # How to use
12
+ ```python
13
+ from transformers import LlamaForCausalLM, AutoTokenizer
14
+ import torch
15
+
16
+ ckpt = "tiansz/ChatYuan-7B-merge"
17
+ device = torch.device('cuda')
18
+ model = LlamaForCausalLM.from_pretrained(ckpt)
19
+ tokenizer = AutoTokenizer.from_pretrained(ckpt)
20
+
21
+ def answer(prompt):
22
+ prompt = f"用户:{prompt}\n小元:"
23
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
24
+ generate_ids = model.generate(input_ids, max_new_tokens=1024, do_sample = True, temperature = 0.7)
25
+ output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
26
+ response = output[len(prompt):]
27
+ return response
28
+
29
+ result = answer("你好")
30
+ print(result)
31
+ ```
32
+
33
+
34
+ # License
35
+ - [ChatYuan-7B](https://github.com/clue-ai/ChatYuan-7B)
36
+ - [llama](https://github.com/facebookresearch/llama)