Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2model_checkpoint = "sumanthmandavalli/english-to-tamil"
3tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
4model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
5def language_translator(text):
6 tokenized = tokenizer([text], return_tensors='pt')
7 out = model.generate(**tokenized, max_length=128)
8 return tokenizer.decode(out[0],skip_special_tokens=True)
9text_to_translate = "WELOCOME TO AI WORLD" # Sentence to translate
10output = language_translator(text_to_translate)
11print(output) # இது ஒரு சோதனை வழக்கு.