Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Replace this with your own checkpoint
|
5 |
+
model_checkpoint = "huggingface-course/bert-finetuned-squad"
|
6 |
+
question_answerer = pipeline("question-answering", model=model_checkpoint)
|
7 |
|
8 |
+
def answer_question(question, context):
|
9 |
+
answer = question_answerer(question=question, context=context)
|
10 |
+
return answer['answer']
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=answer_question,
|
14 |
+
inputs=[gr.inputs.Textbox(label="Context"), gr.inputs.Textbox(label="Question")],
|
15 |
+
outputs="text",
|
16 |
+
title="Hugging Face Question Answering"
|
17 |
+
)
|
18 |
+
iface.launch()
|