only translates into english

#14
by ishabrato - opened
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("alirezamsh/small100")
model = AutoModelForSeq2SeqLM.from_pretrained("alirezamsh/small100")
def translate(lang, text):

    lang = lang #lang.split(" ")[-1][1:-1]
    
    tokenizer.tgt_lang = lang
    encoded_text = tokenizer(text, return_tensors="pt")
    generated_tokens = model.generate(**encoded_text)
    return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]

result = translate("Bengali (bn)", "ramu is a good boy")
print(result)

please help

Sign up or log in to comment