Spaces:
Sleeping
Sleeping
File size: 560 Bytes
3cd7b9b 1ea7b52 3cd7b9b 1ea7b52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
from transformers import pipeline
import gradio as grad
import AssertionError
model_name="deepset/roberta-base-squad2"
qa_pipeline = pipeline("question-answering", model=model_name, tokenizer=model_name)
def answer2question(question, context):
text = "{" + "'question': " + question + "','context': '" + context + "'}"
di = ast.literal_eval(text)
response = qa_pipeline(di)
return response
grad.Interface(answer2question, inputs=["text", "text"], outputs="text").launch() |