Spaces:
Paused
Paused
File size: 865 Bytes
e025579 2e85200 8102814 2e85200 8102814 af3334d 2e85200 cc27b51 2e85200 cc27b51 e025579 c6e95fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
from transformers import pipeline
from transformers import pipeline,AutoTokenizer
from optimum.intel import OVModelForQuestionAnswering
model_checkpoint = "letrunglinh/qa_pnc"
global model_convert,tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model_convert = OVModelForQuestionAnswering.from_pretrained(model_checkpoint,export=True, compile=False)
model_convert.half()
model_convert.compile()
def question_answer(context, question):
model = pipeline('question-answering', model=model_convert,
tokenizer=tokenizer)
to_predict = [
{
"question": question,
"context": context,
}
]
answers = model(to_predict)
return answers['answer'], answers['score']
gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["textbox","textbox"], theme = "grass", share = True).launch() |