liangchen1225
commited on
Commit
·
7c21edd
1
Parent(s):
12e9693
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- tatsu-lab/alpaca
|
5 |
+
language:
|
6 |
+
- zh
|
7 |
+
- en
|
8 |
+
library_name: transformers
|
9 |
+
tags:
|
10 |
+
- baichuan
|
11 |
---
|
12 |
+
|
13 |
+
Usage:
|
14 |
+
```python
|
15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
16 |
+
from peft import PeftModel
|
17 |
+
|
18 |
+
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/baichuan-7B", trust_remote_code=True)
|
20 |
+
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/baichuan-7B", device_map="auto", trust_remote_code=True)
|
21 |
+
model = PeftModel.from_pretrained(model, "chenliang1225/baichuan-7b-sft")
|
22 |
+
streamer = TextStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
|
23 |
+
|
24 |
+
query = "陨石为什么总能落在陨石坑里?"
|
25 |
+
|
26 |
+
inputs = tokenizer(["### Instruction:\n{}\n\n### Response:\n".format(query)], return_tensors="pt")
|
27 |
+
inputs = inputs.to("cuda")
|
28 |
+
generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer, top_p=0.7, temperature=0.95)
|
29 |
+
```
|
30 |
+
|