Timing0311 commited on
Commit
b59dc4d
1 Parent(s): a88db4c

test translation job v1.1

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -6,9 +6,9 @@ tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
6
 
7
  def translation_CN2EN(text):
8
  inp = "translate English to Chinese:: "+text
9
- enc = tokenizer(inp, return_tensors="pt")
10
- tokens = mdl.generate(**enc)
11
- response = tokenizer.batch_decode(tokens)
12
  return response
13
  para=grad.Textbox(lines=1, label="Chinese Text", placeholder="Text in Chinese")
14
  out=grad.Textbox(lines=1, label="English Translation")
 
6
 
7
  def translation_CN2EN(text):
8
  inp = "translate English to Chinese:: "+text
9
+ enc = tokenizer(inp, return_tensors="pt").input_ids
10
+ tokens = mdl.generate(enc)
11
+ response = tokenizer.decode(tokens[0], skip_special_tokens=True)
12
  return response
13
  para=grad.Textbox(lines=1, label="Chinese Text", placeholder="Text in Chinese")
14
  out=grad.Textbox(lines=1, label="English Translation")