-u
Browse files
app.py
CHANGED
@@ -1,7 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
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 |
|