Spaces:
Runtime error
Runtime error
IT5 model
Browse files- app.py +28 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
nlp_t2t = pipeline(
|
| 5 |
+
'text2text-generation',
|
| 6 |
+
model='z-uo/it5-squadv1-it',
|
| 7 |
+
tokenizer='z-uo/it5-squadv1-it'
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
def start(question, context):
|
| 11 |
+
text = question + '\n' + context
|
| 12 |
+
response = nlp_t2t(text)
|
| 13 |
+
|
| 14 |
+
return response[0]['generated_text']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
face = gr.Interface(
|
| 18 |
+
fn=start,
|
| 19 |
+
inputs=[
|
| 20 |
+
gr.inputs.Textbox(lines=1, placeholder="Question Here… "),
|
| 21 |
+
gr.inputs.Textbox(lines=10, placeholder="Context Here… ")
|
| 22 |
+
],
|
| 23 |
+
outputs=[
|
| 24 |
+
gr.outputs.Textbox(label="Answer"),
|
| 25 |
+
]
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
face.launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
torch
|
| 3 |
+
transformers
|
| 4 |
+
sentencepiece
|