Update README.md
Browse files
README.md
CHANGED
@@ -14,4 +14,36 @@ pipeline_tag: text-generation
|
|
14 |
inference: false
|
15 |
---
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
inference: false
|
15 |
---
|
16 |
|
17 |
+
A chinese instruction-tuned LoRA model of https://huggingface.co/baichuan-inc/Baichuan-13B-Base
|
18 |
+
|
19 |
+
- Instruction-following datasets used: alpaca-zh, sharegpt
|
20 |
+
- Training framework: https://github.com/hiyouga/LLaMA-Efficient-Tuning
|
21 |
+
|
22 |
+
Usage:
|
23 |
+
|
24 |
+
```python
|
25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
26 |
+
|
27 |
+
tokenizer = AutoTokenizer.from_pretrained("hiyouga/baichuan-13b-sft", trust_remote_code=True)
|
28 |
+
model = AutoModelForCausalLM.from_pretrained("hiyouga/baichuan-13b-sft", trust_remote_code=True).cuda()
|
29 |
+
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
30 |
+
|
31 |
+
query = "晚上睡不着怎么办"
|
32 |
+
template = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\nHuman: {}\nAssistant: "
|
33 |
+
|
34 |
+
inputs = tokenizer([template.format(query)], return_tensors="pt")
|
35 |
+
inputs = inputs.to("cuda")
|
36 |
+
generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)
|
37 |
+
```
|
38 |
+
|
39 |
+
You could also alternatively launch a CLI demo by using the script in https://github.com/hiyouga/LLaMA-Efficient-Tuning
|
40 |
+
|
41 |
+
```bash
|
42 |
+
python src/cli_demo.py --model_name_or_path hiyouga/baichuan-13b-sft
|
43 |
+
```
|
44 |
+
|
45 |
+
---
|
46 |
+
|
47 |
+
You can reproduce our results by visiting the following step-by-step (Chinese) guide:
|
48 |
+
|
49 |
+
https://zhuanlan.zhihu.com/p/645010851
|