trigger166 commited on
Commit
36c6aa0
·
1 Parent(s): 24b97e8

interface

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -62,3 +62,13 @@ trainer.push_to_hub("testA")
62
  ## Interfaccia Gradio
63
  #iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
64
  #iface.launch()
 
 
 
 
 
 
 
 
 
 
 
62
  ## Interfaccia Gradio
63
  #iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
64
  #iface.launch()
65
+
66
+
67
+ def answer_question(question):
68
+ inputs = tokenizer(question, return_tensors="pt", padding="max_length", truncation=True, max_length=128)
69
+ outputs = model.generate(inputs["input_ids"], max_length=50)
70
+ answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
71
+ return answer
72
+
73
+ iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
74
+ iface.launch()