Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
# 模型和分词器的名称
|
5 |
-
model_name = "Qwen/Qwen2.5-
|
6 |
|
7 |
# 加载模型和分词器
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
@@ -11,7 +11,7 @@ model = AutoModelForCausalLM.from_pretrained(model_name)
|
|
11 |
# 定义生成文本的函数
|
12 |
def generate_text(input_text):
|
13 |
inputs = tokenizer(input_text, return_tensors="pt")
|
14 |
-
outputs = model.generate(**inputs, max_length=
|
15 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return generated_text
|
17 |
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
# 模型和分词器的名称
|
5 |
+
model_name = "Qwen/Qwen2.5-0.5B-Instruct"
|
6 |
|
7 |
# 加载模型和分词器
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
11 |
# 定义生成文本的函数
|
12 |
def generate_text(input_text):
|
13 |
inputs = tokenizer(input_text, return_tensors="pt")
|
14 |
+
outputs = model.generate(**inputs, max_length=8192)
|
15 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return generated_text
|
17 |
|