legacy107 commited on
Commit
4633d28
1 Parent(s): 79221a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -145,7 +145,7 @@ def retrieve_context(question, contexts):
145
  def generate_answer(question, context, ground, do_pretrained, do_natural, do_pretrained_natural):
146
  contexts = chunk_splitter(clean_data(context))
147
  retrieved_context = retrieve_context(question, contexts)
148
- ground_in_context = ground in retrieved_context
149
 
150
  # Combine question and context
151
  input_text = f"question: {question} context: {retrieved_context}"
@@ -183,7 +183,7 @@ def generate_answer(question, context, ground, do_pretrained, do_natural, do_pre
183
  if do_pretrained_natural:
184
  pretrained_paraphrased_answer = paraphrase_answer(question, generated_answer, True)
185
 
186
- return generated_answer, paraphrased_answer, ground_in_context, pretrained_answer, pretrained_paraphrased_answer, retrieved_context
187
 
188
 
189
  # Define a function to list examples from the dataset
@@ -211,7 +211,7 @@ iface = gr.Interface(
211
  outputs=[
212
  Textbox(label="Generated Answer"),
213
  Textbox(label="Natural Answer"),
214
- Checkbox(label="Ground truth in the retrieved context"),
215
  Textbox(label="Pretrained Model's Answer"),
216
  Textbox(label="Pretrained Model's Natural Answer"),
217
  Textbox(label="Retrieved Context")
 
145
  def generate_answer(question, context, ground, do_pretrained, do_natural, do_pretrained_natural):
146
  contexts = chunk_splitter(clean_data(context))
147
  retrieved_context = retrieve_context(question, contexts)
148
+ ground_in_context = (retrieved_context.find(ground) != -1)
149
 
150
  # Combine question and context
151
  input_text = f"question: {question} context: {retrieved_context}"
 
183
  if do_pretrained_natural:
184
  pretrained_paraphrased_answer = paraphrase_answer(question, generated_answer, True)
185
 
186
+ return generated_answer, paraphrased_answer, ("Yes" if ground_in_context else "No"), pretrained_answer, pretrained_paraphrased_answer, retrieved_context
187
 
188
 
189
  # Define a function to list examples from the dataset
 
211
  outputs=[
212
  Textbox(label="Generated Answer"),
213
  Textbox(label="Natural Answer"),
214
+ Textbox(label="Ground truth in the retrieved context"),
215
  Textbox(label="Pretrained Model's Answer"),
216
  Textbox(label="Pretrained Model's Natural Answer"),
217
  Textbox(label="Retrieved Context")