Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ from transformers import pipeline
|
|
| 4 |
pipe = pipeline("question-answering", model="huggingface-course/bert-finetuned-squad")
|
| 5 |
|
| 6 |
def qa(question, context):
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
with gr.Blocks() as demo:
|
| 10 |
with gr.Row():
|
|
@@ -14,8 +15,9 @@ with gr.Blocks() as demo:
|
|
| 14 |
submit_btn = gr.Button(value = 'Submit')
|
| 15 |
with gr.Column():
|
| 16 |
answer = gr.Textbox(label= 'Answer')
|
|
|
|
| 17 |
|
| 18 |
-
submit_btn.click(qa, inputs = [question, context], outputs = answer)
|
| 19 |
|
| 20 |
demo.launch()
|
| 21 |
|
|
|
|
| 4 |
pipe = pipeline("question-answering", model="huggingface-course/bert-finetuned-squad")
|
| 5 |
|
| 6 |
def qa(question, context):
|
| 7 |
+
result = pipe(question=question, context=context)
|
| 8 |
+
return result['answer'], result['score']
|
| 9 |
|
| 10 |
with gr.Blocks() as demo:
|
| 11 |
with gr.Row():
|
|
|
|
| 15 |
submit_btn = gr.Button(value = 'Submit')
|
| 16 |
with gr.Column():
|
| 17 |
answer = gr.Textbox(label= 'Answer')
|
| 18 |
+
score = gr.Textbox(label= 'Score')
|
| 19 |
|
| 20 |
+
submit_btn.click(qa, inputs = [question, context], outputs = [answer, score])
|
| 21 |
|
| 22 |
demo.launch()
|
| 23 |
|