from transformers import T5ForConditionalGeneration, T5TokenizerFast t5_model = T5ForConditionalGeneration.from_pretrained('./pytorch_model') tokenizer = T5TokenizerFast.from_pretrained('./') text = 'বাংলার মুখ আমি দেখিয়াছি, তাই আমি পৃথিবীর রূপ খুঁজিতে যাই না' tokenized = tokenizer(text, return_tensors='pt') input_ids = tokenized.input_ids attention_mask = tokenized.attention_mask t5_model.eval() beam_outputs = t5_model.generate( input_ids=input_ids,attention_mask=attention_mask, max_length=64, early_stopping=True, num_beams=10, num_return_sequences=3, no_repeat_ngram_size=2 ) for beam_output in beam_outputs: sent = tokenizer.decode(beam_output, skip_special_tokens=True,clean_up_tokenization_spaces=True) print (sent)