File size: 1,581 Bytes
13af3db
 
9c08765
 
 
 
 
 
 
69eb613
 
 
 
 
13af3db
9c08765
d80bb97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bd216bd
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
license: apache-2.0
datasets:
- tatsu-lab/alpaca
- FreedomIntelligence/ShareGPT-CN
language:
- zh
- en
library_name: transformers
tags:
- baichuan
- lora
pipeline_tag: text-generation
inference: false
---

A chinese instruction-tuned LoRA model of https://huggingface.co/baichuan-inc/Baichuan-13B-Base

- Instruction-following datasets used: alpaca-zh, sharegpt
- Training framework: https://github.com/hiyouga/LLaMA-Efficient-Tuning

Usage:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer

tokenizer = AutoTokenizer.from_pretrained("hiyouga/baichuan-13b-sft", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("hiyouga/baichuan-13b-sft", trust_remote_code=True).cuda()
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)

query = "晚上睡不着怎么办"
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: "

inputs = tokenizer([template.format(query)], return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)
```

You could also alternatively launch a CLI demo by using the script in https://github.com/hiyouga/LLaMA-Efficient-Tuning

```bash
python src/cli_demo.py --model_name_or_path hiyouga/baichuan-13b-sft
```

---

You can reproduce our results by visiting the following step-by-step (Chinese) guide:

https://zhuanlan.zhihu.com/p/645010851

Loss curve:

![loss](loss.png)