Spaces:
Paused
Paused
letrunglinh
commited on
Commit
•
2e85200
1
Parent(s):
08439a8
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from transformers import AutoModelForQuestionAnswering, pipeline,AutoTokenizer
|
3 |
-
import
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def question_answer(context, question):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
model = pipeline('question-answering', model=model,
|
12 |
-
tokenizer=tokenizer, use_auth_token=AUTH_TOKEN)
|
13 |
to_predict = [
|
14 |
{
|
15 |
"question": question,
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
from transformers import AutoModelForQuestionAnswering, pipeline,AutoTokenizer
|
4 |
+
from optimum.intel import OVModelForQuestionAnswering
|
5 |
+
model_checkpoint = "letrunglinh/qa_pnc"
|
6 |
+
global model_convert,tokenizer
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
8 |
+
model_convert = OVModelForQuestionAnswering.from_pretrained(model_checkpoint,export=True)
|
9 |
+
model_convert.half()
|
10 |
+
model_convert.compile()
|
11 |
+
|
12 |
def question_answer(context, question):
|
13 |
+
|
14 |
+
model = pipeline('question-answering', model=model_convert,
|
15 |
+
tokenizer=tokenizer)
|
16 |
+
|
17 |
+
|
|
|
|
|
18 |
to_predict = [
|
19 |
{
|
20 |
"question": question,
|