File size: 1,297 Bytes
740f687
 
fe02692
 
 
 
 
740f687
ebce2f4
5b4bbaf
 
ebce2f4
 
 
 
 
 
 
 
 
 
 
 
 
 
1b98b3a
cfb9a07
1b98b3a
ebce2f4
 
8c688d8
 
 
 
 
 
 
 
 
5b4bbaf
 
 
 
 
 
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
---
license: apache-2.0
datasets:
- tatsu-lab/alpaca
language:
- zh
library_name: transformers
---

An instruction-tuned LoRA model of https://huggingface.co/baichuan-inc/baichuan-7B

This checkpoint is trained with: https://github.com/hiyouga/LLaMA-Efficient-Tuning

Usage:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/baichuan-7B", device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(model, "hiyouga/baichuan-7b-sft")

query = "晚上睡不着怎么办"

inputs = tokenizer(["<human>:{}\n<bot>:".format(query)], return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(**inputs)
output = tokenizer.batch_decode(generate_ids)[0]
print(output)
```

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 baichuan-inc/baichuan-7B \
    --checkpoint_dir hiyouga/baichuan-7b-sft \
    --prompt_template ziya
```

Loss curve on training set:
![train](training_loss.svg)

Loss curve on evaluation set:
![eval](eval_loss.svg)