update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,33 @@ from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REP
|
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 29 |
from src.submission.submit import add_new_eval
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def restart_space():
|
| 32 |
API.restart_space(repo_id=REPO_ID)
|
| 33 |
|
|
@@ -55,6 +82,17 @@ print("LEADERBOARD_DF Columns:", LEADERBOARD_DF.columns.tolist()) # Debug
|
|
| 55 |
# Load the evaluation queue DataFrames
|
| 56 |
finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
demo = gr.Blocks(css=custom_css)
|
| 59 |
with demo:
|
| 60 |
gr.HTML(TITLE)
|
|
@@ -73,6 +111,24 @@ with demo:
|
|
| 73 |
default_selection.insert(0, "model_name")
|
| 74 |
print("Default Selection after ensuring 'model_name':", default_selection) # Debug
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
leaderboard = Leaderboard(
|
| 77 |
value=LEADERBOARD_DF,
|
| 78 |
datatype=[col.type for col in COLUMNS],
|
|
@@ -80,8 +136,9 @@ with demo:
|
|
| 80 |
default_selection=default_selection,
|
| 81 |
cant_deselect=[col.name for col in COLUMNS if col.never_hidden],
|
| 82 |
label="Select Columns to Display:",
|
|
|
|
| 83 |
),
|
| 84 |
-
search_columns=[col.name for col in COLUMNS if col.name in ["model_name", "license"]],
|
| 85 |
hide_columns=[col.name for col in COLUMNS if col.hidden],
|
| 86 |
filter_columns=[
|
| 87 |
ColumnFilter("model_type", type="checkboxgroup", label="Model types"),
|
|
@@ -93,7 +150,16 @@ with demo:
|
|
| 93 |
bool_checkboxgroup_label="Hide models",
|
| 94 |
interactive=False,
|
| 95 |
)
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 99 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
|
|
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 29 |
from src.submission.submit import add_new_eval
|
| 30 |
|
| 31 |
+
# Add this CSS to make column selection more compact
|
| 32 |
+
custom_css_additions = """
|
| 33 |
+
.select-columns-container {
|
| 34 |
+
max-height: 300px;
|
| 35 |
+
overflow-y: auto;
|
| 36 |
+
display: grid;
|
| 37 |
+
grid-template-columns: repeat(4, 1fr);
|
| 38 |
+
gap: 5px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.select-columns-container label {
|
| 42 |
+
font-size: 0.9em;
|
| 43 |
+
padding: 2px;
|
| 44 |
+
margin: 0;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.column-categories {
|
| 48 |
+
margin-bottom: 10px;
|
| 49 |
+
}
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
# Update your CSS
|
| 53 |
+
if 'custom_css' in locals():
|
| 54 |
+
custom_css += custom_css_additions
|
| 55 |
+
else:
|
| 56 |
+
custom_css = custom_css_additions
|
| 57 |
+
|
| 58 |
def restart_space():
|
| 59 |
API.restart_space(repo_id=REPO_ID)
|
| 60 |
|
|
|
|
| 82 |
# Load the evaluation queue DataFrames
|
| 83 |
finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
| 84 |
|
| 85 |
+
# Group columns by category for better organization
|
| 86 |
+
COLUMN_CATEGORIES = {
|
| 87 |
+
"Model Info": ["model_name", "model_type", "license", "likes", "base_model", "params", "precision", "weight_type", "still_on_hub", "average"],
|
| 88 |
+
"Academic Knowledge": ["abstract_algebra", "anatomy", "astronomy", "college_biology", "college_chemistry", "college_computer_science",
|
| 89 |
+
"college_mathematics", "college_medicine", "college_physics"],
|
| 90 |
+
"General Knowledge": ["business_ethics", "clinical_knowledge", "conceptual_physics", "econometrics", "electrical_engineering",
|
| 91 |
+
"elementary_mathematics", "formal_logic", "global_facts"],
|
| 92 |
+
"High School Subjects": ["high_school_biology", "high_school_chemistry", "high_school_computer_science",
|
| 93 |
+
"high_school_european_history", "high_school_geography", "high_school_government_and_politics"]
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
demo = gr.Blocks(css=custom_css)
|
| 97 |
with demo:
|
| 98 |
gr.HTML(TITLE)
|
|
|
|
| 111 |
default_selection.insert(0, "model_name")
|
| 112 |
print("Default Selection after ensuring 'model_name':", default_selection) # Debug
|
| 113 |
|
| 114 |
+
# Create an accordion for column selection
|
| 115 |
+
with gr.Accordion("Select Columns to Display", open=False):
|
| 116 |
+
column_selections = {}
|
| 117 |
+
|
| 118 |
+
for category, cols in COLUMN_CATEGORIES.items():
|
| 119 |
+
# Filter to only include columns that exist
|
| 120 |
+
available_cols = [c for c in cols if c in [col.name for col in COLUMNS]]
|
| 121 |
+
|
| 122 |
+
if available_cols:
|
| 123 |
+
with gr.Column(elem_classes="column-categories"):
|
| 124 |
+
gr.Markdown(f"**{category}**")
|
| 125 |
+
column_selections[category] = gr.CheckboxGroup(
|
| 126 |
+
choices=available_cols,
|
| 127 |
+
value=[c for c in available_cols if c in default_selection],
|
| 128 |
+
label=""
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
# Create the leaderboard with standard SelectColumns (it will be hidden via CSS)
|
| 132 |
leaderboard = Leaderboard(
|
| 133 |
value=LEADERBOARD_DF,
|
| 134 |
datatype=[col.type for col in COLUMNS],
|
|
|
|
| 136 |
default_selection=default_selection,
|
| 137 |
cant_deselect=[col.name for col in COLUMNS if col.never_hidden],
|
| 138 |
label="Select Columns to Display:",
|
| 139 |
+
render=False, # Don't render the built-in selector if this option is available
|
| 140 |
),
|
| 141 |
+
search_columns=[col.name for col in COLUMNS if col.name in ["model_name", "license"]],
|
| 142 |
hide_columns=[col.name for col in COLUMNS if col.hidden],
|
| 143 |
filter_columns=[
|
| 144 |
ColumnFilter("model_type", type="checkboxgroup", label="Model types"),
|
|
|
|
| 150 |
bool_checkboxgroup_label="Hide models",
|
| 151 |
interactive=False,
|
| 152 |
)
|
| 153 |
+
|
| 154 |
+
# Add event handlers to update visible columns when custom checkboxes are changed
|
| 155 |
+
for category, checkbox_group in column_selections.items():
|
| 156 |
+
# For each category, when checkboxes change, update the visible columns
|
| 157 |
+
# This might need adjustment based on how the Leaderboard component works
|
| 158 |
+
checkbox_group.change(
|
| 159 |
+
fn=lambda *values: leaderboard.update(visible_columns=sum(values, [])),
|
| 160 |
+
inputs=list(column_selections.values()),
|
| 161 |
+
outputs=[leaderboard]
|
| 162 |
+
)
|
| 163 |
|
| 164 |
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 165 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|