Nighter commited on
Commit
fa08b06
1 Parent(s): 620ab6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -51,6 +51,7 @@ def remove_parentheses(text):
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):
@@ -58,7 +59,8 @@ def answer_questions(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:
@@ -86,10 +88,15 @@ with gr.Blocks() as app:
86
  roberta_base_output = gr.Textbox(lines=3, label="RoBERTa Base")
87
  with gr.Column(scale=2):
88
  roberta_base_score = gr.Number(label="RoBERTa Base Score")
 
 
 
 
 
89
 
90
- submit_btn.click(fn=answer_questions, inputs=[context_input, question_input], outputs=[distilbert_base_uncased_output, distilbert_base_uncased_score, bert_base_uncased_output, bert_base_uncased_score, roberta_base_output, roberta_base_score])
91
  examples='examples'
92
- gr.Examples(examples,[context_input, question_input],[distilbert_base_uncased_output, distilbert_base_uncased_score, bert_base_uncased_output, bert_base_uncased_score, roberta_base_output, roberta_base_score],answer_questions)
93
 
94
  with gr.Tab("Long Answer Prediction"):
95
  with gr.Row():
 
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
+ longformer_base = pipeline(model="Nighter/Fine-tuned-longformer-base")
55
 
56
  # Function to answer on all models
57
  def answer_questions(context, question):
 
59
  distilbert_base_uncased_result = distilbert_base_uncased(question=question, context=remove_parentheses(context))
60
  bert_base_uncased_result = bert_base_uncased(question=question, context=remove_parentheses(context))
61
  roberta_base_result = roberta_base(question=question, context=remove_parentheses(context))
62
+ longformer_base_result = longformer_base(question=question, context=remove_parentheses(context))
63
+ 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'], longformer_base_result['score'], longformer_base_result['answer'], roberta_base_result['score'] #, long_answer, long_score
64
 
65
  # App Interface
66
  with gr.Blocks() as app:
 
88
  roberta_base_output = gr.Textbox(lines=3, label="RoBERTa Base")
89
  with gr.Column(scale=2):
90
  roberta_base_score = gr.Number(label="RoBERTa Base Score")
91
+ with gr.Row():
92
+ with gr.Column(scale=6):
93
+ longformer_base_output = gr.Textbox(lines=3, label="Longformer Base")
94
+ with gr.Column(scale=2):
95
+ longformer_base_score = gr.Number(label="Longformer Base Score")
96
 
97
+ submit_btn.click(fn=answer_questions, inputs=[context_input, question_input], outputs=[distilbert_base_uncased_output, distilbert_base_uncased_score, bert_base_uncased_output, bert_base_uncased_score, roberta_base_output, roberta_base_score, longformer_base_output, longformer_base_score])
98
  examples='examples'
99
+ gr.Examples(examples,[context_input, question_input],[distilbert_base_uncased_output, distilbert_base_uncased_score, bert_base_uncased_output, bert_base_uncased_score, roberta_base_output, roberta_base_score, longformer_base_output, longformer_base_score],answer_questions)
100
 
101
  with gr.Tab("Long Answer Prediction"):
102
  with gr.Row():