Spaces:
Sleeping
Sleeping
File size: 514 Bytes
5c2f8ce 80b26db 5c2f8ce 80b26db 5c2f8ce db6b88a d133fb5 5c2f8ce 144284a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
import gradio as grad
import ast
mdl_name = "deepset/roberta-base-squad2"
my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_name)
def answer_question(question,context):
text = '''{'question': {}, 'context': {} }'''.format(question, context)
di=ast.literal_eval(text)
response = my_pipeline(di)
return response
grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch() |