ffreemt commited on
Commit
a27c4fb
1 Parent(s): 588edf6
Files changed (2) hide show
  1. app.py +15 -0
  2. requirements.txt +12 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run qwen 7b.
2
+
3
+ transformers 4.31.0
4
+ """
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer
6
+ from transformers.generation import GenerationConfig
7
+
8
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-7B-Chat", trust_remote_code=True)
9
+
10
+ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B-Chat", device_map="auto", trust_remote_code=True).eval()
11
+ model.generation_config = GenerationConfig.from_pretrained("Qwen/Qwen-7B-Chat", trust_remote_code=True) # 可指定不同的生成长度、top_p等相关超参
12
+
13
+ response, history = model.chat(tokenizer, "你好", history=None)
14
+ # response, history = model.chat(tokenizer, "你好", history=[])
15
+ print(response)
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ transformers==4.31.0
2
+ accelerate
3
+ tiktoken
4
+ einops
5
+ flash-attention
6
+
7
+ # git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention
8
+ # cd flash-attention && pip install .
9
+ # pip install csrc/layer_norm
10
+ # pip install csrc/rotary
11
+
12
+ torch # 2.0.1