Spaces:
Runtime error
Runtime error
File size: 594 Bytes
e7ee46c ae59627 5946045 ae59627 e36d3cb ae59627 e7ee46c 18cfd04 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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() |