Short translation
#1
by
SaeedMLK
- opened
Hi, when I want to translate a long sentence the model does not translate the whole sentence. How can we get a full translation?
thank you.
Hi, when I want to translate a long sentence the model does not translate the whole sentence. How can we get a full translation?
thank you.
you can use max length like this:
def translate(text):
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
outputs = model.generate(**inputs, max_length=512)
return tokenizer.batch_decode(outputs, skip_special_tokens=True)