piimaila commited on
Commit
8ee4ade
1 Parent(s): 887b960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
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-Coder-1.5B"
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=10000)
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