CoolFace
Apppublic

nontgcob/T2E_Vocabulary_Exam_Generator

sourceHugging Facemitupdated 2y agoView on Hugging Face
2likes
inference.py12 linesDownload Raw Back to modules
1from transformers import T5Tokenizer, T5ForConditionalGeneration2 3tokenizer = T5Tokenizer.from_pretrained("t5-small")4model = T5ForConditionalGeneration.from_pretrained("t5-small")5 6 7def infer_t5(input):8    input_ids = tokenizer(input, return_tensors="pt").input_ids9    outputs = model.generate(input_ids)10 11    return tokenizer.decode(outputs[0], skip_special_tokens=True)12