Tbb1111 commited on
Commit
db3dca1
·
verified ·
1 Parent(s): 7c5b58c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -9,7 +9,7 @@ tokenizer = T5Tokenizer.from_pretrained(model_name)
9
  # 翻译功能
10
  def translate_text(input_text):
11
  # 使用 T5 模型进行翻译
12
- inputs = tokenizer.encode("translate English to Chinese: " + input_text, return_tensors="pt", max_length=512, truncation=True)
13
  outputs = model.generate(inputs, max_length=1024, num_beams=4, early_stopping=True)
14
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
15
 
 
9
  # 翻译功能
10
  def translate_text(input_text):
11
  # 使用 T5 模型进行翻译
12
+ inputs = tokenizer.encode("翻译成中文: " + input_text, return_tensors="pt", max_length=512, truncation=True)
13
  outputs = model.generate(inputs, max_length=1024, num_beams=4, early_stopping=True)
14
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
15