Spaces:
Runtime error
Runtime error
Bert Q and A
Browse files- app.py +24 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
print('starat')
|
| 5 |
+
nlp_qa = pipeline(
|
| 6 |
+
'question-answering',
|
| 7 |
+
model='mrm8488/bert-italian-finedtuned-squadv1-it-alfa',
|
| 8 |
+
tokenizer='mrm8488/bert-italian-finedtuned-squadv1-it-alfa'
|
| 9 |
+
)
|
| 10 |
+
print('end')
|
| 11 |
+
|
| 12 |
+
def start(question, context):
|
| 13 |
+
response = nlp_qa({
|
| 14 |
+
'question': question,
|
| 15 |
+
'context': context
|
| 16 |
+
})
|
| 17 |
+
return response['answer'], response['score']
|
| 18 |
+
|
| 19 |
+
face = gr.Interface(
|
| 20 |
+
fn=start,
|
| 21 |
+
inputs=[gr.inputs.Textbox(lines=1, placeholder="Question Here… "), gr.inputs.Textbox(lines=10, placeholder="Context Here… ")],
|
| 22 |
+
outputs=["text", "number"]
|
| 23 |
+
)
|
| 24 |
+
face.launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
torch
|
| 3 |
+
transformers
|
| 4 |
+
sentencepiece
|