Saurabhz's picture
Update app.py
18cfd04
raw
history blame contribute delete
594 Bytes
import gradio as gr
from transformers import pipeline
def question_answer(context, question):
model_checkpoint = "huggingface-course/bert-finetuned-squad"
model = pipeline("question-answering", model=model_checkpoint)
to_predict = [
{
"context": context,
"qas": [
{
"question": question,
"id": "0",
}
],
}
]
answers, probabilities = model.predict(to_predict)
return answers[0]['answer'][0]
gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["textbox"]).launch()