Ajaykanth Maddi commited on
Commit ·
306eb28
1
Parent(s): 356c6bf
Chunk Count and BM25 UI Changes
Browse files
app.py
CHANGED
|
@@ -202,7 +202,8 @@ initial_subset = available_subsets[0] if available_subsets else None
|
|
| 202 |
initial_plot = plot_subset_metrics(initial_subset) if initial_subset else "No data available"
|
| 203 |
|
| 204 |
|
| 205 |
-
def run_rag_pipeline(subset, question, custom_question, chunking, embed_model, retriever,
|
|
|
|
| 206 |
final_question = custom_question if custom_question.strip() else question
|
| 207 |
print(f"The query is {final_question}")
|
| 208 |
|
|
@@ -229,7 +230,7 @@ def run_rag_pipeline(subset, question, custom_question, chunking, embed_model, r
|
|
| 229 |
print("Loaded the embeddings database - Complete")
|
| 230 |
|
| 231 |
# 4. Retrieve and Generate Answer
|
| 232 |
-
retrieved_chunks = rag.retrieve(final_question)
|
| 233 |
print("Retrieved the chunks - Complete")
|
| 234 |
|
| 235 |
context_docs = [chunk.text for chunk in retrieved_chunks]
|
|
@@ -310,9 +311,17 @@ with gr.Blocks(title="RAGBench Explorer") as demo:
|
|
| 310 |
embed_dropdown = gr.Dropdown(choices=embedding_models, label="🔗 Embedding Model", value="BAAI/bge-large-en-v1.5")
|
| 311 |
retriever_dropdown = gr.Dropdown(choices=generator_models, label="🧭 Generator Model", value="mistralai/Mistral-7B-Instruct-v0.2")
|
| 312 |
|
| 313 |
-
# with gr.Row():
|
| 314 |
with gr.Column(scale=2):
|
| 315 |
-
gr.Markdown("### ⚙️ Evaluation Option")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
reranking_checkbox = gr.Checkbox(label="Use Reranking", value=False)
|
| 317 |
evaluator_dropdown = gr.Dropdown(choices=evaluators, label="🧠 Evaluator Model", value="llama")
|
| 318 |
|
|
@@ -362,6 +371,7 @@ with gr.Blocks(title="RAGBench Explorer") as demo:
|
|
| 362 |
inputs=[
|
| 363 |
subset_dropdown, question_dropdown, custom_question_input,
|
| 364 |
chunking_dropdown, embed_dropdown, retriever_dropdown,
|
|
|
|
| 365 |
reranking_checkbox, evaluator_dropdown
|
| 366 |
],
|
| 367 |
outputs=[gen_ans_display, y_pred_metrics_display, chunks_retrieved_display, evaluator_json_output]
|
|
|
|
| 202 |
initial_plot = plot_subset_metrics(initial_subset) if initial_subset else "No data available"
|
| 203 |
|
| 204 |
|
| 205 |
+
def run_rag_pipeline(subset, question, custom_question, chunking, embed_model, retriever, chunk_count, retriever_type,
|
| 206 |
+
reranking, evaluator):
|
| 207 |
final_question = custom_question if custom_question.strip() else question
|
| 208 |
print(f"The query is {final_question}")
|
| 209 |
|
|
|
|
| 230 |
print("Loaded the embeddings database - Complete")
|
| 231 |
|
| 232 |
# 4. Retrieve and Generate Answer
|
| 233 |
+
retrieved_chunks = rag.retrieve(final_question, chunk_count=chunk_count)
|
| 234 |
print("Retrieved the chunks - Complete")
|
| 235 |
|
| 236 |
context_docs = [chunk.text for chunk in retrieved_chunks]
|
|
|
|
| 311 |
embed_dropdown = gr.Dropdown(choices=embedding_models, label="🔗 Embedding Model", value="BAAI/bge-large-en-v1.5")
|
| 312 |
retriever_dropdown = gr.Dropdown(choices=generator_models, label="🧭 Generator Model", value="mistralai/Mistral-7B-Instruct-v0.2")
|
| 313 |
|
|
|
|
| 314 |
with gr.Column(scale=2):
|
| 315 |
+
gr.Markdown("### ⚙️ Retrieval Settings and Evaluation Option")
|
| 316 |
+
chunk_count = gr.Slider(minimum=1, maximum=15,
|
| 317 |
+
value=5, # Default value
|
| 318 |
+
step=1, label="Number of Chunks to Retrieve")
|
| 319 |
+
|
| 320 |
+
retriever_type = gr.Dropdown(
|
| 321 |
+
choices=["BM25", "Vector"], # Add other options as needed
|
| 322 |
+
value="BM25", # Default selection
|
| 323 |
+
label="Retriever Type")
|
| 324 |
+
|
| 325 |
reranking_checkbox = gr.Checkbox(label="Use Reranking", value=False)
|
| 326 |
evaluator_dropdown = gr.Dropdown(choices=evaluators, label="🧠 Evaluator Model", value="llama")
|
| 327 |
|
|
|
|
| 371 |
inputs=[
|
| 372 |
subset_dropdown, question_dropdown, custom_question_input,
|
| 373 |
chunking_dropdown, embed_dropdown, retriever_dropdown,
|
| 374 |
+
chunk_count, retriever_type,
|
| 375 |
reranking_checkbox, evaluator_dropdown
|
| 376 |
],
|
| 377 |
outputs=[gen_ans_display, y_pred_metrics_display, chunks_retrieved_display, evaluator_json_output]
|