hiyouga commited on
Commit
e0b4597
·
1 Parent(s): 07fb958

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -1
README.md CHANGED
@@ -25,8 +25,20 @@ You may use this model for fine-tuning in downstream tasks, we recommend using o
25
  Usage:
26
 
27
  ```python
28
- from transformers import AutoModelForCausalLM, AutoTokenizer
29
 
30
  tokenizer = AutoTokenizer.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied", use_fast=False)
31
  model = AutoModelForCausalLM.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied").cuda()
 
 
 
 
 
 
 
 
 
 
 
 
32
  ```
 
25
  Usage:
26
 
27
  ```python
28
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
29
 
30
  tokenizer = AutoTokenizer.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied", use_fast=False)
31
  model = AutoModelForCausalLM.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied").cuda()
32
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
33
+
34
+ query = "<reserved_106>晚上睡不着怎么办<reserved_107>"
35
+ inputs = tokenizer([query], return_tensors="pt")
36
+ inputs = inputs.to("cuda")
37
+ generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)
38
+ ```
39
+
40
+ You could also alternatively launch a CLI demo by using the script in [LLaMA-Efficient-Tuning](https://github.com/hiyouga/LLaMA-Efficient-Tuning)
41
+
42
+ ```bash
43
+ python src/cli_demo.py --template baichuan2 --model_name_or_path Baichuan2-7B-Chat-LLaMAfied
44
  ```