Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
Β·
b85d9b0
1
Parent(s):
f11c31d
Update SDK version and refactor leaderboard tabs for improved structure
Browse files- README.md +1 -1
- app.py +14 -10
- leaderboard_tab.py +43 -29
- reranking_leaderboard.py +33 -19
- retrieval_leaderboard.py +29 -18
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: π
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
short_description: The only leaderboard you will require for your RAG needs π
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.31.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
short_description: The only leaderboard you will require for your RAG needs π
|
app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from retrieval_leaderboard import create_retrieval_tab
|
| 3 |
-
from reranking_leaderboard import create_reranking_tab
|
| 4 |
-
from llm_in_context_leaderboard import create_llm_in_context_tab
|
| 5 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
HEADER = """<div style="text-align: center; margin-bottom: 20px;">
|
|
@@ -30,18 +32,19 @@ CITATION_BUTTON_TEXT = """
|
|
| 30 |
}
|
| 31 |
"""
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
gr.HTML(HEADER)
|
| 36 |
-
|
| 37 |
with gr.Tabs():
|
| 38 |
with gr.Tab("π΅οΈββοΈ Retrieval"):
|
| 39 |
create_retrieval_tab()
|
| 40 |
|
| 41 |
with gr.Tab("π Reranking"):
|
| 42 |
create_reranking_tab()
|
| 43 |
-
|
| 44 |
-
# with gr.Tab("
|
| 45 |
# create_llm_in_context_tab()
|
| 46 |
|
| 47 |
with gr.Row():
|
|
@@ -53,8 +56,9 @@ def main():
|
|
| 53 |
elem_id="citation-button",
|
| 54 |
show_copy_button=True,
|
| 55 |
)
|
|
|
|
| 56 |
|
| 57 |
-
demo.launch()
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
+
|
| 4 |
+
from llm_in_context_leaderboard import create_llm_in_context_tab
|
| 5 |
+
from reranking_leaderboard import create_reranking_tab
|
| 6 |
+
from retrieval_leaderboard import create_retrieval_tab
|
| 7 |
+
|
| 8 |
load_dotenv()
|
| 9 |
|
| 10 |
HEADER = """<div style="text-align: center; margin-bottom: 20px;">
|
|
|
|
| 32 |
}
|
| 33 |
"""
|
| 34 |
|
| 35 |
+
|
| 36 |
+
def create_app():
|
| 37 |
+
with gr.Blocks() as app:
|
| 38 |
gr.HTML(HEADER)
|
| 39 |
+
|
| 40 |
with gr.Tabs():
|
| 41 |
with gr.Tab("π΅οΈββοΈ Retrieval"):
|
| 42 |
create_retrieval_tab()
|
| 43 |
|
| 44 |
with gr.Tab("π Reranking"):
|
| 45 |
create_reranking_tab()
|
| 46 |
+
|
| 47 |
+
# with gr.Tab("π§ LLM in Context"):
|
| 48 |
# create_llm_in_context_tab()
|
| 49 |
|
| 50 |
with gr.Row():
|
|
|
|
| 56 |
elem_id="citation-button",
|
| 57 |
show_copy_button=True,
|
| 58 |
)
|
| 59 |
+
return app
|
| 60 |
|
|
|
|
| 61 |
|
| 62 |
if __name__ == "__main__":
|
| 63 |
+
app = create_app()
|
| 64 |
+
app.queue().launch()
|
leaderboard_tab.py
CHANGED
|
@@ -1,40 +1,46 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import pandas as pd
|
| 3 |
from fuzzywuzzy import fuzz
|
|
|
|
| 4 |
from utils import submit_gradio_module
|
| 5 |
|
|
|
|
| 6 |
def search_leaderboard(df, model_name, columns_to_show, threshold=95):
|
| 7 |
"""
|
| 8 |
Search the leaderboard for models matching the search term using fuzzy matching.
|
| 9 |
-
|
| 10 |
Args:
|
| 11 |
df: The dataframe containing all leaderboard data
|
| 12 |
model_name: The search term to find models
|
| 13 |
columns_to_show: List of columns to include in the result
|
| 14 |
threshold: Minimum similarity threshold (default: 95)
|
| 15 |
-
|
| 16 |
Returns:
|
| 17 |
Filtered dataframe with only matching models and selected columns
|
| 18 |
"""
|
| 19 |
if not model_name.strip():
|
| 20 |
return df.loc[:, columns_to_show]
|
| 21 |
search_name = model_name.lower() # compute once for efficiency
|
|
|
|
| 22 |
def calculate_similarity(row):
|
| 23 |
return fuzz.partial_ratio(search_name, row["Model"].lower())
|
|
|
|
| 24 |
filtered_df = df.copy()
|
| 25 |
filtered_df["similarity"] = filtered_df.apply(calculate_similarity, axis=1)
|
| 26 |
-
filtered_df = filtered_df[filtered_df["similarity"] >= threshold].sort_values(
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
return filtered_df
|
| 29 |
|
|
|
|
| 30 |
def update_columns_to_show(df, columns_to_show):
|
| 31 |
"""
|
| 32 |
Update the displayed columns in the dataframe.
|
| 33 |
-
|
| 34 |
Args:
|
| 35 |
df: The dataframe to update
|
| 36 |
columns_to_show: List of columns to include
|
| 37 |
-
|
| 38 |
Returns:
|
| 39 |
gradio.update object with the updated dataframe
|
| 40 |
"""
|
|
@@ -49,10 +55,19 @@ def update_columns_to_show(df, columns_to_show):
|
|
| 49 |
columns_widths.append(150)
|
| 50 |
return gr.update(value=dummy_df, column_widths=columns_widths)
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
"""
|
| 54 |
Create a complete leaderboard tab with search, column selection, and data display.
|
| 55 |
-
|
| 56 |
Args:
|
| 57 |
df: The dataframe containing the leaderboard data
|
| 58 |
initial_columns_to_show: Initial list of columns to display
|
|
@@ -60,31 +75,32 @@ def create_leaderboard_tab(df, initial_columns_to_show, search_function, update_
|
|
| 60 |
update_function: Function to handle column updates
|
| 61 |
about_section: Markdown text for the About tab
|
| 62 |
task_type: Type of the task ("Retriever" or "Reranker")
|
| 63 |
-
|
| 64 |
Returns:
|
| 65 |
A gradio Tabs component with the complete leaderboard interface
|
| 66 |
"""
|
| 67 |
-
columns_widths = [
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
with gr.Tabs() as tabs:
|
| 70 |
with gr.Tab("π Leaderboard"):
|
| 71 |
with gr.Column():
|
| 72 |
with gr.Row(equal_height=True):
|
| 73 |
search_box = gr.Textbox(
|
| 74 |
-
placeholder="Search for models...",
|
| 75 |
-
label="Search (You can also press Enter to search)",
|
| 76 |
-
scale=5
|
| 77 |
)
|
| 78 |
search_button = gr.Button(
|
| 79 |
-
value="Search",
|
| 80 |
-
variant="primary",
|
| 81 |
-
scale=1
|
| 82 |
)
|
| 83 |
columns_to_show_input = gr.CheckboxGroup(
|
| 84 |
label="Columns to Show",
|
| 85 |
choices=df.columns.tolist(),
|
| 86 |
value=initial_columns_to_show,
|
| 87 |
-
scale=4
|
| 88 |
)
|
| 89 |
|
| 90 |
leaderboard = gr.Dataframe(
|
|
@@ -93,30 +109,28 @@ def create_leaderboard_tab(df, initial_columns_to_show, search_function, update_
|
|
| 93 |
wrap=True,
|
| 94 |
show_fullscreen_button=True,
|
| 95 |
interactive=False,
|
| 96 |
-
column_widths=columns_widths
|
| 97 |
)
|
| 98 |
-
|
| 99 |
# Connect events
|
| 100 |
search_box.submit(
|
| 101 |
search_function,
|
| 102 |
inputs=[search_box, columns_to_show_input],
|
| 103 |
-
outputs=leaderboard
|
| 104 |
)
|
| 105 |
columns_to_show_input.select(
|
| 106 |
-
update_function,
|
| 107 |
-
inputs=columns_to_show_input,
|
| 108 |
-
outputs=leaderboard
|
| 109 |
)
|
| 110 |
search_button.click(
|
| 111 |
search_function,
|
| 112 |
inputs=[search_box, columns_to_show_input],
|
| 113 |
-
outputs=leaderboard
|
| 114 |
)
|
| 115 |
-
|
| 116 |
with gr.Tab("π΅οΈ Submit"):
|
| 117 |
-
submit_gradio_module(task_type)
|
| 118 |
|
| 119 |
with gr.Tab("βΉοΈ About"):
|
| 120 |
gr.Markdown(about_section)
|
| 121 |
-
|
| 122 |
return tabs
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from fuzzywuzzy import fuzz
|
| 3 |
+
|
| 4 |
from utils import submit_gradio_module
|
| 5 |
|
| 6 |
+
|
| 7 |
def search_leaderboard(df, model_name, columns_to_show, threshold=95):
|
| 8 |
"""
|
| 9 |
Search the leaderboard for models matching the search term using fuzzy matching.
|
| 10 |
+
|
| 11 |
Args:
|
| 12 |
df: The dataframe containing all leaderboard data
|
| 13 |
model_name: The search term to find models
|
| 14 |
columns_to_show: List of columns to include in the result
|
| 15 |
threshold: Minimum similarity threshold (default: 95)
|
| 16 |
+
|
| 17 |
Returns:
|
| 18 |
Filtered dataframe with only matching models and selected columns
|
| 19 |
"""
|
| 20 |
if not model_name.strip():
|
| 21 |
return df.loc[:, columns_to_show]
|
| 22 |
search_name = model_name.lower() # compute once for efficiency
|
| 23 |
+
|
| 24 |
def calculate_similarity(row):
|
| 25 |
return fuzz.partial_ratio(search_name, row["Model"].lower())
|
| 26 |
+
|
| 27 |
filtered_df = df.copy()
|
| 28 |
filtered_df["similarity"] = filtered_df.apply(calculate_similarity, axis=1)
|
| 29 |
+
filtered_df = filtered_df[filtered_df["similarity"] >= threshold].sort_values(
|
| 30 |
+
"similarity", ascending=False
|
| 31 |
+
)
|
| 32 |
+
filtered_df = filtered_df.drop("similarity", axis=1).loc[:, columns_to_show]
|
| 33 |
return filtered_df
|
| 34 |
|
| 35 |
+
|
| 36 |
def update_columns_to_show(df, columns_to_show):
|
| 37 |
"""
|
| 38 |
Update the displayed columns in the dataframe.
|
| 39 |
+
|
| 40 |
Args:
|
| 41 |
df: The dataframe to update
|
| 42 |
columns_to_show: List of columns to include
|
| 43 |
+
|
| 44 |
Returns:
|
| 45 |
gradio.update object with the updated dataframe
|
| 46 |
"""
|
|
|
|
| 55 |
columns_widths.append(150)
|
| 56 |
return gr.update(value=dummy_df, column_widths=columns_widths)
|
| 57 |
|
| 58 |
+
|
| 59 |
+
def create_leaderboard_tab(
|
| 60 |
+
df,
|
| 61 |
+
initial_columns_to_show,
|
| 62 |
+
search_function,
|
| 63 |
+
update_function,
|
| 64 |
+
about_section,
|
| 65 |
+
task_type,
|
| 66 |
+
model_param_limit=2000,
|
| 67 |
+
):
|
| 68 |
"""
|
| 69 |
Create a complete leaderboard tab with search, column selection, and data display.
|
| 70 |
+
|
| 71 |
Args:
|
| 72 |
df: The dataframe containing the leaderboard data
|
| 73 |
initial_columns_to_show: Initial list of columns to display
|
|
|
|
| 75 |
update_function: Function to handle column updates
|
| 76 |
about_section: Markdown text for the About tab
|
| 77 |
task_type: Type of the task ("Retriever" or "Reranker")
|
| 78 |
+
|
| 79 |
Returns:
|
| 80 |
A gradio Tabs component with the complete leaderboard interface
|
| 81 |
"""
|
| 82 |
+
columns_widths = [
|
| 83 |
+
80 if col == "Rank" else 400 if col == "Model" else 150
|
| 84 |
+
for col in initial_columns_to_show
|
| 85 |
+
]
|
| 86 |
+
|
| 87 |
with gr.Tabs() as tabs:
|
| 88 |
with gr.Tab("π Leaderboard"):
|
| 89 |
with gr.Column():
|
| 90 |
with gr.Row(equal_height=True):
|
| 91 |
search_box = gr.Textbox(
|
| 92 |
+
placeholder="Search for models...",
|
| 93 |
+
label="Search (You can also press Enter to search)",
|
| 94 |
+
scale=5,
|
| 95 |
)
|
| 96 |
search_button = gr.Button(
|
| 97 |
+
value="Search", variant="primary", scale=1
|
|
|
|
|
|
|
| 98 |
)
|
| 99 |
columns_to_show_input = gr.CheckboxGroup(
|
| 100 |
label="Columns to Show",
|
| 101 |
choices=df.columns.tolist(),
|
| 102 |
value=initial_columns_to_show,
|
| 103 |
+
scale=4,
|
| 104 |
)
|
| 105 |
|
| 106 |
leaderboard = gr.Dataframe(
|
|
|
|
| 109 |
wrap=True,
|
| 110 |
show_fullscreen_button=True,
|
| 111 |
interactive=False,
|
| 112 |
+
column_widths=columns_widths,
|
| 113 |
)
|
| 114 |
+
|
| 115 |
# Connect events
|
| 116 |
search_box.submit(
|
| 117 |
search_function,
|
| 118 |
inputs=[search_box, columns_to_show_input],
|
| 119 |
+
outputs=leaderboard,
|
| 120 |
)
|
| 121 |
columns_to_show_input.select(
|
| 122 |
+
update_function, inputs=columns_to_show_input, outputs=leaderboard
|
|
|
|
|
|
|
| 123 |
)
|
| 124 |
search_button.click(
|
| 125 |
search_function,
|
| 126 |
inputs=[search_box, columns_to_show_input],
|
| 127 |
+
outputs=leaderboard,
|
| 128 |
)
|
| 129 |
+
|
| 130 |
with gr.Tab("π΅οΈ Submit"):
|
| 131 |
+
submit_gradio_module(task_type, model_param_limit=model_param_limit)
|
| 132 |
|
| 133 |
with gr.Tab("βΉοΈ About"):
|
| 134 |
gr.Markdown(about_section)
|
| 135 |
+
|
| 136 |
return tabs
|
reranking_leaderboard.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from utils import load_json_results
|
| 3 |
-
from leaderboard_tab import search_leaderboard, update_columns_to_show, create_leaderboard_tab
|
| 4 |
|
| 5 |
# Constants
|
| 6 |
RERANKER_ABOUT_SECTION = """
|
|
@@ -37,45 +42,54 @@ All metrics are averaged across multiple evaluation datasets to provide a compre
|
|
| 37 |
# Global variables
|
| 38 |
reranking_df = None
|
| 39 |
|
| 40 |
-
def load_reranking_results(prepare_for_display=False, sort_col=None, drop_cols=None):
|
| 41 |
-
dataframe_path = Path(__file__).parent / "results" / "reranking_results.json"
|
| 42 |
-
return load_json_results(
|
| 43 |
-
dataframe_path,
|
| 44 |
-
prepare_for_display=prepare_for_display,
|
| 45 |
-
sort_col=sort_col,
|
| 46 |
-
drop_cols=drop_cols
|
| 47 |
-
)
|
| 48 |
|
| 49 |
def load_reranking_leaderboard():
|
| 50 |
"""Load and prepare the reranking leaderboard data"""
|
| 51 |
global reranking_df
|
| 52 |
-
|
| 53 |
# Prepare reranking dataframe
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
reranking_df.insert(0, "Rank", range(1, 1 + len(reranking_df)))
|
| 56 |
-
|
| 57 |
return reranking_df
|
| 58 |
|
|
|
|
| 59 |
def reranking_search_leaderboard(model_name, columns_to_show):
|
| 60 |
"""Search function for reranking leaderboard"""
|
| 61 |
return search_leaderboard(reranking_df, model_name, columns_to_show)
|
| 62 |
|
|
|
|
| 63 |
def update_reranker_columns_to_show(columns_to_show):
|
| 64 |
"""Update displayed columns for reranking leaderboard"""
|
| 65 |
return update_columns_to_show(reranking_df, columns_to_show)
|
| 66 |
|
|
|
|
| 67 |
def create_reranking_tab():
|
| 68 |
"""Create the complete reranking leaderboard tab"""
|
| 69 |
global reranking_df
|
| 70 |
-
|
| 71 |
# Load data if not already loaded
|
| 72 |
-
if
|
| 73 |
reranking_df = load_reranking_leaderboard()
|
| 74 |
-
|
| 75 |
# Define default columns to show
|
| 76 |
-
default_columns = [
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# Create and return the tab
|
| 80 |
return create_leaderboard_tab(
|
| 81 |
df=reranking_df,
|
|
@@ -83,5 +97,5 @@ def create_reranking_tab():
|
|
| 83 |
search_function=reranking_search_leaderboard,
|
| 84 |
update_function=update_reranker_columns_to_show,
|
| 85 |
about_section=RERANKER_ABOUT_SECTION,
|
| 86 |
-
task_type="Reranker"
|
| 87 |
)
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
+
|
| 3 |
+
from leaderboard_tab import (
|
| 4 |
+
create_leaderboard_tab,
|
| 5 |
+
search_leaderboard,
|
| 6 |
+
update_columns_to_show,
|
| 7 |
+
)
|
| 8 |
from utils import load_json_results
|
|
|
|
| 9 |
|
| 10 |
# Constants
|
| 11 |
RERANKER_ABOUT_SECTION = """
|
|
|
|
| 42 |
# Global variables
|
| 43 |
reranking_df = None
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
def load_reranking_leaderboard():
|
| 47 |
"""Load and prepare the reranking leaderboard data"""
|
| 48 |
global reranking_df
|
| 49 |
+
|
| 50 |
# Prepare reranking dataframe
|
| 51 |
+
dataframe_path = Path(__file__).parent / "results" / "reranking_results.json"
|
| 52 |
+
reranking_df = load_json_results(
|
| 53 |
+
dataframe_path,
|
| 54 |
+
prepare_for_display=True,
|
| 55 |
+
sort_col="Average Score",
|
| 56 |
+
drop_cols=["Revision", "Task"],
|
| 57 |
+
)
|
| 58 |
reranking_df.insert(0, "Rank", range(1, 1 + len(reranking_df)))
|
| 59 |
+
|
| 60 |
return reranking_df
|
| 61 |
|
| 62 |
+
|
| 63 |
def reranking_search_leaderboard(model_name, columns_to_show):
|
| 64 |
"""Search function for reranking leaderboard"""
|
| 65 |
return search_leaderboard(reranking_df, model_name, columns_to_show)
|
| 66 |
|
| 67 |
+
|
| 68 |
def update_reranker_columns_to_show(columns_to_show):
|
| 69 |
"""Update displayed columns for reranking leaderboard"""
|
| 70 |
return update_columns_to_show(reranking_df, columns_to_show)
|
| 71 |
|
| 72 |
+
|
| 73 |
def create_reranking_tab():
|
| 74 |
"""Create the complete reranking leaderboard tab"""
|
| 75 |
global reranking_df
|
| 76 |
+
|
| 77 |
# Load data if not already loaded
|
| 78 |
+
if reranking_df is None:
|
| 79 |
reranking_df = load_reranking_leaderboard()
|
| 80 |
+
|
| 81 |
# Define default columns to show
|
| 82 |
+
default_columns = [
|
| 83 |
+
"Rank",
|
| 84 |
+
"Model",
|
| 85 |
+
"Average Score",
|
| 86 |
+
"Model Size (MB)",
|
| 87 |
+
"Context Length",
|
| 88 |
+
"Embedding Dimension",
|
| 89 |
+
"Namaa Global Knowledge",
|
| 90 |
+
"Navid General Knowledge",
|
| 91 |
+
]
|
| 92 |
+
|
| 93 |
# Create and return the tab
|
| 94 |
return create_leaderboard_tab(
|
| 95 |
df=reranking_df,
|
|
|
|
| 97 |
search_function=reranking_search_leaderboard,
|
| 98 |
update_function=update_reranker_columns_to_show,
|
| 99 |
about_section=RERANKER_ABOUT_SECTION,
|
| 100 |
+
task_type="Reranker",
|
| 101 |
)
|
retrieval_leaderboard.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from utils import load_json_results
|
| 3 |
-
from leaderboard_tab import search_leaderboard, update_columns_to_show, create_leaderboard_tab
|
| 4 |
|
| 5 |
# Constants
|
| 6 |
RETRIEVAL_ABOUT_SECTION = """
|
|
@@ -37,45 +42,51 @@ The retrieval evaluation assesses a model's ability to find and retrieve relevan
|
|
| 37 |
# Global variables
|
| 38 |
retrieval_df = None
|
| 39 |
|
| 40 |
-
def load_retrieval_results(prepare_for_display=False, sort_col=None, drop_cols=None):
|
| 41 |
-
dataframe_path = Path(__file__).parent / "results" / "retrieval_results.json"
|
| 42 |
-
return load_json_results(
|
| 43 |
-
dataframe_path,
|
| 44 |
-
prepare_for_display=prepare_for_display,
|
| 45 |
-
sort_col=sort_col,
|
| 46 |
-
drop_cols=drop_cols
|
| 47 |
-
)
|
| 48 |
|
| 49 |
def load_retrieval_leaderboard():
|
| 50 |
"""Load and prepare the retrieval leaderboard data"""
|
| 51 |
global retrieval_df
|
| 52 |
-
|
| 53 |
# Prepare retrieval dataframe
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
retrieval_df.insert(0, "Rank", range(1, 1 + len(retrieval_df)))
|
| 56 |
-
|
| 57 |
return retrieval_df
|
| 58 |
|
|
|
|
| 59 |
def retrieval_search_leaderboard(model_name, columns_to_show):
|
| 60 |
"""Search function for retrieval leaderboard"""
|
| 61 |
return search_leaderboard(retrieval_df, model_name, columns_to_show)
|
| 62 |
|
|
|
|
| 63 |
def update_retrieval_columns_to_show(columns_to_show):
|
| 64 |
"""Update displayed columns for retrieval leaderboard"""
|
| 65 |
return update_columns_to_show(retrieval_df, columns_to_show)
|
| 66 |
|
|
|
|
| 67 |
def create_retrieval_tab():
|
| 68 |
"""Create the complete retrieval leaderboard tab"""
|
| 69 |
global retrieval_df
|
| 70 |
-
|
| 71 |
# Load data if not already loaded
|
| 72 |
if retrieval_df is None:
|
| 73 |
retrieval_df = load_retrieval_leaderboard()
|
| 74 |
-
|
| 75 |
# Define default columns to show
|
| 76 |
-
default_columns = [
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# Create and return the tab
|
| 80 |
return create_leaderboard_tab(
|
| 81 |
df=retrieval_df,
|
|
@@ -83,5 +94,5 @@ def create_retrieval_tab():
|
|
| 83 |
search_function=retrieval_search_leaderboard,
|
| 84 |
update_function=update_retrieval_columns_to_show,
|
| 85 |
about_section=RETRIEVAL_ABOUT_SECTION,
|
| 86 |
-
task_type="Retriever"
|
| 87 |
)
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
+
|
| 3 |
+
from leaderboard_tab import (
|
| 4 |
+
create_leaderboard_tab,
|
| 5 |
+
search_leaderboard,
|
| 6 |
+
update_columns_to_show,
|
| 7 |
+
)
|
| 8 |
from utils import load_json_results
|
|
|
|
| 9 |
|
| 10 |
# Constants
|
| 11 |
RETRIEVAL_ABOUT_SECTION = """
|
|
|
|
| 42 |
# Global variables
|
| 43 |
retrieval_df = None
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
def load_retrieval_leaderboard():
|
| 47 |
"""Load and prepare the retrieval leaderboard data"""
|
| 48 |
global retrieval_df
|
| 49 |
+
|
| 50 |
# Prepare retrieval dataframe
|
| 51 |
+
dataframe_path = Path(__file__).parent / "results" / "retrieval_results.json"
|
| 52 |
+
retrieval_df = load_json_results(
|
| 53 |
+
dataframe_path, True, "Average Score", drop_cols=["Revision", "Task"]
|
| 54 |
+
)
|
| 55 |
retrieval_df.insert(0, "Rank", range(1, 1 + len(retrieval_df)))
|
| 56 |
+
|
| 57 |
return retrieval_df
|
| 58 |
|
| 59 |
+
|
| 60 |
def retrieval_search_leaderboard(model_name, columns_to_show):
|
| 61 |
"""Search function for retrieval leaderboard"""
|
| 62 |
return search_leaderboard(retrieval_df, model_name, columns_to_show)
|
| 63 |
|
| 64 |
+
|
| 65 |
def update_retrieval_columns_to_show(columns_to_show):
|
| 66 |
"""Update displayed columns for retrieval leaderboard"""
|
| 67 |
return update_columns_to_show(retrieval_df, columns_to_show)
|
| 68 |
|
| 69 |
+
|
| 70 |
def create_retrieval_tab():
|
| 71 |
"""Create the complete retrieval leaderboard tab"""
|
| 72 |
global retrieval_df
|
| 73 |
+
|
| 74 |
# Load data if not already loaded
|
| 75 |
if retrieval_df is None:
|
| 76 |
retrieval_df = load_retrieval_leaderboard()
|
| 77 |
+
|
| 78 |
# Define default columns to show
|
| 79 |
+
default_columns = [
|
| 80 |
+
"Rank",
|
| 81 |
+
"Model",
|
| 82 |
+
"Average Score",
|
| 83 |
+
"Model Size (MB)",
|
| 84 |
+
"Context Length",
|
| 85 |
+
"Embedding Dimension",
|
| 86 |
+
"Web Search Dataset",
|
| 87 |
+
"Islamic Knowledge Dataset",
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
# Create and return the tab
|
| 91 |
return create_leaderboard_tab(
|
| 92 |
df=retrieval_df,
|
|
|
|
| 94 |
search_function=retrieval_search_leaderboard,
|
| 95 |
update_function=update_retrieval_columns_to_show,
|
| 96 |
about_section=RETRIEVAL_ABOUT_SECTION,
|
| 97 |
+
task_type="Retriever",
|
| 98 |
)
|