Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -50,13 +50,15 @@ def remove_parentheses(text):
|
|
50 |
# Load short model
|
51 |
distilbert_base_uncased = pipeline(model="Nighter/QA_wiki_data_short_answer", from_tf=True)
|
52 |
bert_base_uncased = pipeline(model="Nighter/QA_bert_base_uncased_wiki_data_short_answer", from_tf=True)
|
|
|
53 |
|
54 |
# Function to answer on all models
|
55 |
def answer_questions(context, question):
|
56 |
# long_score, long_answer = predict_answer(context, question)
|
57 |
distilbert_base_uncased_result = distilbert_base_uncased(question=question, context=remove_parentheses(context))
|
58 |
-
bert_base_uncased_result =bert_base_uncased(question=question, context=remove_parentheses(context))
|
59 |
-
|
|
|
60 |
|
61 |
# App Interface
|
62 |
with gr.Blocks() as app:
|
@@ -70,14 +72,19 @@ with gr.Blocks() as app:
|
|
70 |
with gr.Column():
|
71 |
with gr.Row():
|
72 |
with gr.Column(scale=6):
|
73 |
-
short_answer_output = gr.Textbox(lines=
|
74 |
with gr.Column(scale=2):
|
75 |
short_score_output = gr.Number(label="Distil BERT Base Uncased Score")
|
76 |
with gr.Row():
|
77 |
with gr.Column(scale=6):
|
78 |
-
long_answer_output = gr.Textbox(lines=
|
79 |
with gr.Column(scale=2):
|
80 |
long_score_output = gr.Number(label="BERT Base Uncased Score")
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
submit_btn.click(fn=answer_questions, inputs=[context_input, question_input], outputs=[short_answer_output, short_score_output, long_answer_output, long_score_output])
|
83 |
examples='examples'
|
|
|
50 |
# Load short model
|
51 |
distilbert_base_uncased = pipeline(model="Nighter/QA_wiki_data_short_answer", from_tf=True)
|
52 |
bert_base_uncased = pipeline(model="Nighter/QA_bert_base_uncased_wiki_data_short_answer", from_tf=True)
|
53 |
+
roberta_base = pipeline(model="Nighter/QA_wiki_data_roberta_base_short_answer", from_tf=True)
|
54 |
|
55 |
# Function to answer on all models
|
56 |
def answer_questions(context, question):
|
57 |
# long_score, long_answer = predict_answer(context, question)
|
58 |
distilbert_base_uncased_result = distilbert_base_uncased(question=question, context=remove_parentheses(context))
|
59 |
+
bert_base_uncased_result = bert_base_uncased(question=question, context=remove_parentheses(context))
|
60 |
+
roberta_base_result = roberta_base(question=question, context=remove_parentheses(context))
|
61 |
+
return distilbert_base_uncased_result['answer'], distilbert_base_uncased_result['score'], bert_base_uncased_result['answer'], bert_base_uncased_result['score'], roberta_base_result['answer'], roberta_base_result['score'] #, long_answer, long_score
|
62 |
|
63 |
# App Interface
|
64 |
with gr.Blocks() as app:
|
|
|
72 |
with gr.Column():
|
73 |
with gr.Row():
|
74 |
with gr.Column(scale=6):
|
75 |
+
short_answer_output = gr.Textbox(lines=3, label="Distil BERT Base Uncased")
|
76 |
with gr.Column(scale=2):
|
77 |
short_score_output = gr.Number(label="Distil BERT Base Uncased Score")
|
78 |
with gr.Row():
|
79 |
with gr.Column(scale=6):
|
80 |
+
long_answer_output = gr.Textbox(lines=3, label="BERT Base Uncased")
|
81 |
with gr.Column(scale=2):
|
82 |
long_score_output = gr.Number(label="BERT Base Uncased Score")
|
83 |
+
with gr.Row():
|
84 |
+
with gr.Column(scale=6):
|
85 |
+
long_answer_output = gr.Textbox(lines=3, label="RoBERTa Base")
|
86 |
+
with gr.Column(scale=2):
|
87 |
+
long_score_output = gr.Number(label="RoBERTa Base Score")
|
88 |
|
89 |
submit_btn.click(fn=answer_questions, inputs=[context_input, question_input], outputs=[short_answer_output, short_score_output, long_answer_output, long_score_output])
|
90 |
examples='examples'
|