kimhung0011 commited on
Commit
d2b11c7
·
verified ·
1 Parent(s): 0da23b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
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()