from transformers import T5Tokenizer, T5ForConditionalGeneration | |
def longText(answere, question): | |
print('###### LANGUAGES ######') | |
input_text = "i have a question and answer.\nthe question is : {}\n the response is : {};\n with this information, can you create an answer phrase?".format(question, answere) | |
print(question) | |
print(answere) | |
print(input_text) | |
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large") | |
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large") | |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids | |
outputs = model.generate(input_ids) | |
return tokenizer.decode(outputs[0]).replace("<pad>","").replace("</s>","") | |