xsnames commited on
Commit
fc90836
β€’
1 Parent(s): b4a0855
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,7 +1,15 @@
 
 
 
 
 
1
  import gradio as gr
2
- from transformers import GPT2Tokenizer, TFGPT2LMHeadModel
3
- tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
4
- model = TFGPT2LMHeadModel.from_pretrained('gpt2')
 
 
 
5
 
6
  def generate(prompt):
7
 
 
1
+ import os
2
+ os.system('pip install transformers==4.31.0 accelerate tiktoken einops')
3
+ # os.system('pip install "modelscope" --upgrade -f https://pypi.org/project/modelscope/')
4
+ # os.system('pip install transformers_stream_generator')
5
+
6
  import gradio as gr
7
+ from transformers import AutoModelForCausalLM, AutoTokenizer
8
+ from transformers.generation import GenerationConfig
9
+
10
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-7B", trust_remote_code=True)
11
+ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B", device_map="auto", trust_remote_code=True).eval()
12
+ model.generation_config = GenerationConfig.from_pretrained("Qwen/Qwen-7B", trust_remote_code=True)
13
 
14
  def generate(prompt):
15