added buttons to view context
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def process_query(query):
|
|
65 |
|
66 |
boolean_context_modified = miniWikiCollectionDict[boolean_ranking_modified[0]]
|
67 |
tf_idf_context_modified = miniWikiCollectionDict[tf_idf_ranking_modified[0]]
|
68 |
-
|
69 |
vision_context_modified = miniWikiCollectionDict[vision_ranking_modified[0]]
|
70 |
open_source_context_modified = miniWikiCollectionDict[open_source_ranking_modified[0]]
|
71 |
|
@@ -88,7 +88,7 @@ def process_query(query):
|
|
88 |
|
89 |
boolean_answer_modified = generate_answer_withContext(modified_query, boolean_context_modified)
|
90 |
tf_idf_answer_modified = generate_answer_withContext(modified_query, tf_idf_context_modified)
|
91 |
-
bm25_answer_modified = generate_answer_withContext(modified_query,
|
92 |
vision_answer_modified = generate_answer_withContext(modified_query, vision_context_modified)
|
93 |
open_source_answer_modified = generate_answer_withContext(modified_query, open_source_context_modified)
|
94 |
|
@@ -127,22 +127,22 @@ def process_query(query):
|
|
127 |
return (
|
128 |
best_model,
|
129 |
best_answer,
|
130 |
-
agent1_answer,
|
131 |
-
agent2_answer,
|
132 |
-
boolean_answer,
|
133 |
-
tf_idf_answer,
|
134 |
-
bm25_answer,
|
135 |
-
vision_answer,
|
136 |
-
open_source_answer,
|
137 |
-
boolean_answer_modified,
|
138 |
-
tf_idf_answer_modified,
|
139 |
-
bm25_answer_modified,
|
140 |
-
vision_answer_modified,
|
141 |
-
open_source_answer_modified,
|
142 |
-
tf_idf_bm25_open_RRF_Ranking_answer,
|
143 |
-
tf_idf_bm25_open_RRF_Ranking_modified_answer,
|
144 |
-
tf_idf_bm25_open_RRF_Ranking_combined_answer,
|
145 |
-
zeroShot,
|
146 |
)
|
147 |
|
148 |
# Gradio interface
|
@@ -155,32 +155,47 @@ def create_interface():
|
|
155 |
with gr.Row():
|
156 |
best_model_output = gr.Textbox(label="Best Model")
|
157 |
best_answer_output = gr.Textbox(label="Best Answer")
|
158 |
-
|
159 |
gr.Markdown("---") # Horizontal line
|
160 |
-
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
with gr.Row():
|
163 |
-
agent1_output =
|
164 |
-
agent2_output =
|
165 |
-
boolean_output =
|
166 |
-
tf_idf_output =
|
167 |
-
bm25_output =
|
168 |
-
|
|
|
|
|
169 |
with gr.Row():
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
with gr.Row():
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
zero_shot_output = gr.Textbox(label="Zero Shot")
|
184 |
|
185 |
gr.Button("Submit").click(
|
186 |
fn=process_query,
|
@@ -188,13 +203,22 @@ def create_interface():
|
|
188 |
outputs=[
|
189 |
best_model_output,
|
190 |
best_answer_output,
|
191 |
-
agent1_output,
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
]
|
199 |
)
|
200 |
|
|
|
65 |
|
66 |
boolean_context_modified = miniWikiCollectionDict[boolean_ranking_modified[0]]
|
67 |
tf_idf_context_modified = miniWikiCollectionDict[tf_idf_ranking_modified[0]]
|
68 |
+
bm25_context_modified = miniWikiCollectionDict[str(bm25_ranking_modified[0])]
|
69 |
vision_context_modified = miniWikiCollectionDict[vision_ranking_modified[0]]
|
70 |
open_source_context_modified = miniWikiCollectionDict[open_source_ranking_modified[0]]
|
71 |
|
|
|
88 |
|
89 |
boolean_answer_modified = generate_answer_withContext(modified_query, boolean_context_modified)
|
90 |
tf_idf_answer_modified = generate_answer_withContext(modified_query, tf_idf_context_modified)
|
91 |
+
bm25_answer_modified = generate_answer_withContext(modified_query, bm25_context_modified)
|
92 |
vision_answer_modified = generate_answer_withContext(modified_query, vision_context_modified)
|
93 |
open_source_answer_modified = generate_answer_withContext(modified_query, open_source_context_modified)
|
94 |
|
|
|
127 |
return (
|
128 |
best_model,
|
129 |
best_answer,
|
130 |
+
agent1_answer, agent1_context,
|
131 |
+
agent2_answer, agent2_context,
|
132 |
+
boolean_answer, boolean_context,
|
133 |
+
tf_idf_answer, tf_idf_context,
|
134 |
+
bm25_answer, bm25_context,
|
135 |
+
vision_answer, vision_context,
|
136 |
+
open_source_answer, open_source_context,
|
137 |
+
boolean_answer_modified, boolean_context_modified,
|
138 |
+
tf_idf_answer_modified, tf_idf_context_modified,
|
139 |
+
bm25_answer_modified, bm25_context_modified,
|
140 |
+
vision_answer_modified, vision_context_modified,
|
141 |
+
open_source_answer_modified, open_source_context_modified,
|
142 |
+
tf_idf_bm25_open_RRF_Ranking_answer, tf_idf_bm25_open_RRF_Ranking_context,
|
143 |
+
tf_idf_bm25_open_RRF_Ranking_modified_answer, tf_idf_bm25_open_RRF_Ranking_modified_context,
|
144 |
+
tf_idf_bm25_open_RRF_Ranking_combined_answer, tf_idf_bm25_open_RRF_Ranking_combined_context,
|
145 |
+
zeroShot, "Zero-shot doesn't have a context."
|
146 |
)
|
147 |
|
148 |
# Gradio interface
|
|
|
155 |
with gr.Row():
|
156 |
best_model_output = gr.Textbox(label="Best Model")
|
157 |
best_answer_output = gr.Textbox(label="Best Answer")
|
158 |
+
|
159 |
gr.Markdown("---") # Horizontal line
|
160 |
+
gr.Markdown("## All Answers and Contexts")
|
161 |
+
|
162 |
+
def create_answer_row(label, context):
|
163 |
+
with gr.Row():
|
164 |
+
answer_textbox = gr.Textbox(label=f"{label} Answer", interactive=False).style(container=True)
|
165 |
+
context_button = gr.Button(f"Show {label} Context")
|
166 |
+
context_textbox = gr.Textbox(label=f"{label} Context", visible=False).style(container=True)
|
167 |
+
|
168 |
+
context_button.click(
|
169 |
+
fn=lambda: gr.update(visible=True, value=context),
|
170 |
+
inputs=[],
|
171 |
+
outputs=context_textbox,
|
172 |
+
)
|
173 |
+
return answer_textbox, context_textbox
|
174 |
+
|
175 |
+
|
176 |
with gr.Row():
|
177 |
+
agent1_output, agent1_context_box = create_answer_row("Agent 1", agent1_context)
|
178 |
+
agent2_output, agent2_context_box = create_answer_row("Agent 2", agent_text_context)
|
179 |
+
boolean_output, boolean_context_box = create_answer_row("Boolean", boolean_context)
|
180 |
+
tf_idf_output, tf_idf_context_box = create_answer_row("TF-IDF", tf_idf_context)
|
181 |
+
bm25_output, bm25_context_box = create_answer_row("BM25", bm25_context)
|
182 |
+
vision_output, vision_context_box = create_answer_row("Vision", vision_context)
|
183 |
+
open_source_output, open_source_context_box = create_answer_row("Open Source", open_source_context)
|
184 |
+
|
185 |
with gr.Row():
|
186 |
+
boolean_mod_output, boolean_mod_context_box = create_answer_row("Boolean (Modified)", boolean_context_modified)
|
187 |
+
tf_idf_mod_output, tf_idf_mod_context_box = create_answer_row("TF-IDF (Modified)", tf_idf_context_modified)
|
188 |
+
bm25_mod_output, bm25_mod_context_box = create_answer_row("BM25 (Modified)", bm25_context_modified)
|
189 |
+
vision_mod_output, vision_mod_context_box = create_answer_row("Vision (Modified)", vision_context_modified)
|
190 |
+
open_source_mod_output, open_source_mod_context_box = create_answer_row("Open Source (Modified)", open_source_context_modified)
|
191 |
+
|
192 |
with gr.Row():
|
193 |
+
tf_idf_rrf_output, tf_idf_rrf_context_box = create_answer_row("TF-IDF + BM25 + Open RRF", tf_idf_bm25_open_RRF_Ranking_context)
|
194 |
+
tf_idf_rrf_mod_output, tf_idf_rrf_mod_context_box = create_answer_row("TF-IDF + BM25 + Open RRF (Modified)", tf_idf_bm25_open_RRF_Ranking_modified_context)
|
195 |
+
tf_idf_rrf_combined_output, tf_idf_rrf_combined_context_box = create_answer_row("TF-IDF + BM25 + Open RRF (Combined)", tf_idf_bm25_open_RRF_Ranking_combined_context)
|
196 |
+
|
197 |
+
with gr.Row():
|
198 |
+
zero_shot_output, zero_shot_context_box = create_answer_row("Zero Shot", "Zero-shot doesn't have a context.")
|
|
|
199 |
|
200 |
gr.Button("Submit").click(
|
201 |
fn=process_query,
|
|
|
203 |
outputs=[
|
204 |
best_model_output,
|
205 |
best_answer_output,
|
206 |
+
agent1_output, agent1_context_box,
|
207 |
+
agent2_output, agent2_context_box,
|
208 |
+
boolean_output, boolean_context_box,
|
209 |
+
tf_idf_output, tf_idf_context_box,
|
210 |
+
bm25_output, bm25_context_box,
|
211 |
+
vision_output, vision_context_box,
|
212 |
+
open_source_output, open_source_context_box,
|
213 |
+
boolean_mod_output, boolean_mod_context_box,
|
214 |
+
tf_idf_mod_output, tf_idf_mod_context_box,
|
215 |
+
bm25_mod_output, bm25_mod_context_box,
|
216 |
+
vision_mod_output, vision_mod_context_box,
|
217 |
+
open_source_mod_output, open_source_context_box,
|
218 |
+
tf_idf_rrf_output, tf_idf_rrf_context_box,
|
219 |
+
tf_idf_rrf_mod_output, tf_idf_rrf_mod_context_box,
|
220 |
+
tf_idf_rrf_combined_output, tf_idf_rrf_combined_context_box,
|
221 |
+
zero_shot_output, zero_shot_context_box,
|
222 |
]
|
223 |
)
|
224 |
|