Spaces:
Runtime error
Runtime error
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline | |
import gradio as grad | |
import ast | |
# First, the RoBERTa base model is used, fine-tuned using the SQuAD 2.0 dataset. | |
# It’s been trained on question-answer pairs, including unanswerable questions, for the task of question and answering. | |
mdl_name = "deepset/roberta-base-squad2" | |
my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_name) | |
def answer_question(question,context): | |
text= "{"+"'question': '"+question+"','context': '"+context+"'}" | |
di=ast.literal_eval(text) | |
response = my_pipeline(di) | |
return response | |
grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch() | |