File size: 714 Bytes
0e9ab77 c530228 cbc1d76 39c1e0a 560c4d8 e001d2e f6b625e 121d715 f6b625e 8d14cb2 f6b625e 560c4d8 a61985e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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>","")
|