Spaces:
Running
Running
openhands
openhands
commited on
Commit
·
d731ad4
1
Parent(s):
315feb4
Connect 'Mark systems by' selector to Evolution and Size charts
Browse files- Update visualizations.py to import get_marker_icon and MARK_BY_DEFAULT
- Add mark_by parameter to create_evolution_over_time_chart()
- Add mark_by parameter to create_accuracy_by_size_chart()
- Update main_page.py to connect mark_by_dropdown to all charts
- Evolution and Size charts now update when mark_by selection changes
Co-authored-by: openhands <openhands@all-hands.dev>
- main_page.py +31 -15
- visualizations.py +23 -10
main_page.py
CHANGED
|
@@ -20,6 +20,8 @@ from visualizations import (
|
|
| 20 |
create_accuracy_by_size_chart
|
| 21 |
)
|
| 22 |
|
|
|
|
|
|
|
| 23 |
# --- Global State for Viewers (simple caching) ---
|
| 24 |
CACHED_VIEWERS = {}
|
| 25 |
CACHED_TAG_MAPS = {}
|
|
@@ -68,9 +70,8 @@ def build_page():
|
|
| 68 |
gr.HTML('<h2>Evolution Over Time</h2>', elem_id="evolution-header")
|
| 69 |
gr.Markdown("Track how model performance has improved over time based on release dates.")
|
| 70 |
|
| 71 |
-
# Create
|
| 72 |
-
evolution_fig_all = create_evolution_over_time_chart(test_df)
|
| 73 |
-
evolution_fig_open = create_evolution_over_time_chart(test_df_open)
|
| 74 |
|
| 75 |
evolution_component = gr.Plot(value=evolution_fig_all, elem_id="evolution-chart")
|
| 76 |
|
|
@@ -80,21 +81,36 @@ def build_page():
|
|
| 80 |
gr.HTML('<h2>Open Model Accuracy by Size</h2>', elem_id="size-accuracy-header")
|
| 81 |
gr.Markdown("Compare open-weights model performance against their parameter count.")
|
| 82 |
|
| 83 |
-
size_fig = create_accuracy_by_size_chart(test_df)
|
| 84 |
-
gr.Plot(value=size_fig, elem_id="size-accuracy-chart")
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
show_open_only_checkbox.change(
|
| 95 |
-
fn=
|
| 96 |
-
inputs=[show_open_only_checkbox],
|
| 97 |
-
outputs=[winners_component, evolution_component]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
else:
|
|
|
|
| 20 |
create_accuracy_by_size_chart
|
| 21 |
)
|
| 22 |
|
| 23 |
+
from constants import MARK_BY_DEFAULT
|
| 24 |
+
|
| 25 |
# --- Global State for Viewers (simple caching) ---
|
| 26 |
CACHED_VIEWERS = {}
|
| 27 |
CACHED_TAG_MAPS = {}
|
|
|
|
| 70 |
gr.HTML('<h2>Evolution Over Time</h2>', elem_id="evolution-header")
|
| 71 |
gr.Markdown("Track how model performance has improved over time based on release dates.")
|
| 72 |
|
| 73 |
+
# Create initial evolution chart with default mark_by
|
| 74 |
+
evolution_fig_all = create_evolution_over_time_chart(test_df, MARK_BY_DEFAULT)
|
|
|
|
| 75 |
|
| 76 |
evolution_component = gr.Plot(value=evolution_fig_all, elem_id="evolution-chart")
|
| 77 |
|
|
|
|
| 81 |
gr.HTML('<h2>Open Model Accuracy by Size</h2>', elem_id="size-accuracy-header")
|
| 82 |
gr.Markdown("Compare open-weights model performance against their parameter count.")
|
| 83 |
|
| 84 |
+
size_fig = create_accuracy_by_size_chart(test_df, MARK_BY_DEFAULT)
|
| 85 |
+
size_component = gr.Plot(value=size_fig, elem_id="size-accuracy-chart")
|
| 86 |
|
| 87 |
+
# Update function for Winners, Evolution, and Size charts based on filters
|
| 88 |
+
def update_extra_sections(show_open_only, mark_by):
|
| 89 |
+
# Select the appropriate dataframe based on open_only filter
|
| 90 |
+
df_to_use = test_df_open if show_open_only else test_df
|
| 91 |
+
|
| 92 |
+
# Winners HTML (not affected by mark_by, only open_only)
|
| 93 |
+
winners_html = winners_html_open if show_open_only else winners_html_all
|
| 94 |
+
|
| 95 |
+
# Regenerate charts with current mark_by setting
|
| 96 |
+
evolution_fig = create_evolution_over_time_chart(df_to_use, mark_by)
|
| 97 |
+
size_fig = create_accuracy_by_size_chart(test_df, mark_by) # Size chart always uses full df (filters internally)
|
| 98 |
|
| 99 |
+
return winners_html, evolution_fig, size_fig
|
| 100 |
+
|
| 101 |
+
# Connect both checkbox and dropdown to update all extra sections
|
| 102 |
+
if show_open_only_checkbox is not None:
|
| 103 |
show_open_only_checkbox.change(
|
| 104 |
+
fn=update_extra_sections,
|
| 105 |
+
inputs=[show_open_only_checkbox, mark_by_dropdown],
|
| 106 |
+
outputs=[winners_component, evolution_component, size_component]
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
if mark_by_dropdown is not None:
|
| 110 |
+
mark_by_dropdown.change(
|
| 111 |
+
fn=update_extra_sections,
|
| 112 |
+
inputs=[show_open_only_checkbox if show_open_only_checkbox else gr.State(value=False), mark_by_dropdown],
|
| 113 |
+
outputs=[winners_component, evolution_component, size_component]
|
| 114 |
)
|
| 115 |
|
| 116 |
else:
|
visualizations.py
CHANGED
|
@@ -11,8 +11,9 @@ import aliases
|
|
| 11 |
from constants import FONT_FAMILY, FONT_FAMILY_SHORT
|
| 12 |
|
| 13 |
# Import company logo mapping from leaderboard_transformer
|
| 14 |
-
from leaderboard_transformer import get_company_from_model
|
| 15 |
from ui_components import get_svg_as_data_uri
|
|
|
|
| 16 |
|
| 17 |
# Standard layout configuration matching existing charts
|
| 18 |
# Colors aligned with OpenHands brand
|
|
@@ -131,17 +132,20 @@ def add_branding_to_figure(fig: go.Figure) -> go.Figure:
|
|
| 131 |
return fig
|
| 132 |
|
| 133 |
|
| 134 |
-
def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
| 135 |
"""
|
| 136 |
Create a chart showing model performance evolution over release dates.
|
| 137 |
Uses company logos as markers to match the existing chart styling.
|
| 138 |
|
| 139 |
Args:
|
| 140 |
df: DataFrame with columns including 'release_date' or 'Release_Date', 'Language Model', 'average score', 'openness'
|
|
|
|
| 141 |
|
| 142 |
Returns:
|
| 143 |
Plotly figure showing score evolution over time
|
| 144 |
"""
|
|
|
|
|
|
|
| 145 |
# Handle different column name formats
|
| 146 |
release_date_col = None
|
| 147 |
for col in ['release_date', 'Release_Date', 'Release Date']:
|
|
@@ -284,13 +288,15 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 284 |
)
|
| 285 |
))
|
| 286 |
|
| 287 |
-
# Add
|
| 288 |
layout_images = []
|
|
|
|
| 289 |
|
| 290 |
for _, row in plot_df.iterrows():
|
| 291 |
model_name = row.get(model_col, '')
|
| 292 |
-
|
| 293 |
-
|
|
|
|
| 294 |
|
| 295 |
# Read the SVG file and encode as base64 data URI
|
| 296 |
if os.path.exists(logo_path):
|
|
@@ -370,7 +376,7 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 370 |
return fig
|
| 371 |
|
| 372 |
|
| 373 |
-
def create_accuracy_by_size_chart(df: pd.DataFrame) -> go.Figure:
|
| 374 |
"""
|
| 375 |
Create a scatter plot showing accuracy vs parameter count for open-weights models.
|
| 376 |
Uses company logos as markers to match the Cost/Performance chart styling.
|
|
@@ -379,12 +385,16 @@ def create_accuracy_by_size_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 379 |
Args:
|
| 380 |
df: DataFrame with columns including 'parameter_count_b' or 'Parameter_Count_B',
|
| 381 |
'average score', 'openness', 'Language Model'
|
|
|
|
| 382 |
|
| 383 |
Returns:
|
| 384 |
Plotly figure showing accuracy vs model size (total parameters)
|
| 385 |
"""
|
| 386 |
import numpy as np
|
| 387 |
|
|
|
|
|
|
|
|
|
|
| 388 |
# Handle different column name formats for parameter count
|
| 389 |
param_col = None
|
| 390 |
for col in ['parameter_count_b', 'Parameter_Count_B', 'Parameter Count B']:
|
|
@@ -465,6 +475,7 @@ def create_accuracy_by_size_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 465 |
total_params = row[param_col]
|
| 466 |
model_name = row.get(model_col, 'Unknown')
|
| 467 |
score = row[score_col]
|
|
|
|
| 468 |
|
| 469 |
# Use total params for x-axis
|
| 470 |
x_val = total_params
|
|
@@ -480,7 +491,8 @@ def create_accuracy_by_size_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 480 |
'y': score,
|
| 481 |
'model_name': model_name,
|
| 482 |
'hover_text': hover_text,
|
| 483 |
-
'total_params': total_params
|
|
|
|
| 484 |
})
|
| 485 |
|
| 486 |
x_values = [p['x'] for p in data_points]
|
|
@@ -539,16 +551,17 @@ def create_accuracy_by_size_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 539 |
)
|
| 540 |
))
|
| 541 |
|
| 542 |
-
# Add
|
| 543 |
layout_images = []
|
| 544 |
|
| 545 |
for point in data_points:
|
| 546 |
x_val = point['x']
|
| 547 |
y_val = point['y']
|
| 548 |
model_name = point['model_name']
|
|
|
|
| 549 |
|
| 550 |
-
|
| 551 |
-
logo_path =
|
| 552 |
|
| 553 |
# Read the SVG file and encode as base64 data URI
|
| 554 |
if os.path.exists(logo_path):
|
|
|
|
| 11 |
from constants import FONT_FAMILY, FONT_FAMILY_SHORT
|
| 12 |
|
| 13 |
# Import company logo mapping from leaderboard_transformer
|
| 14 |
+
from leaderboard_transformer import get_company_from_model, get_marker_icon
|
| 15 |
from ui_components import get_svg_as_data_uri
|
| 16 |
+
from constants import MARK_BY_DEFAULT
|
| 17 |
|
| 18 |
# Standard layout configuration matching existing charts
|
| 19 |
# Colors aligned with OpenHands brand
|
|
|
|
| 132 |
return fig
|
| 133 |
|
| 134 |
|
| 135 |
+
def create_evolution_over_time_chart(df: pd.DataFrame, mark_by: str = None) -> go.Figure:
|
| 136 |
"""
|
| 137 |
Create a chart showing model performance evolution over release dates.
|
| 138 |
Uses company logos as markers to match the existing chart styling.
|
| 139 |
|
| 140 |
Args:
|
| 141 |
df: DataFrame with columns including 'release_date' or 'Release_Date', 'Language Model', 'average score', 'openness'
|
| 142 |
+
mark_by: One of "Company", "Openness", or "Country" - controls which icon to display
|
| 143 |
|
| 144 |
Returns:
|
| 145 |
Plotly figure showing score evolution over time
|
| 146 |
"""
|
| 147 |
+
if mark_by is None:
|
| 148 |
+
mark_by = MARK_BY_DEFAULT
|
| 149 |
# Handle different column name formats
|
| 150 |
release_date_col = None
|
| 151 |
for col in ['release_date', 'Release_Date', 'Release Date']:
|
|
|
|
| 288 |
)
|
| 289 |
))
|
| 290 |
|
| 291 |
+
# Add marker icon images for each data point using data coordinates
|
| 292 |
layout_images = []
|
| 293 |
+
openness_col = 'Openness' if 'Openness' in plot_df.columns else 'openness'
|
| 294 |
|
| 295 |
for _, row in plot_df.iterrows():
|
| 296 |
model_name = row.get(model_col, '')
|
| 297 |
+
openness = row.get(openness_col, '')
|
| 298 |
+
marker_info = get_marker_icon(model_name, openness, mark_by)
|
| 299 |
+
logo_path = marker_info['path']
|
| 300 |
|
| 301 |
# Read the SVG file and encode as base64 data URI
|
| 302 |
if os.path.exists(logo_path):
|
|
|
|
| 376 |
return fig
|
| 377 |
|
| 378 |
|
| 379 |
+
def create_accuracy_by_size_chart(df: pd.DataFrame, mark_by: str = None) -> go.Figure:
|
| 380 |
"""
|
| 381 |
Create a scatter plot showing accuracy vs parameter count for open-weights models.
|
| 382 |
Uses company logos as markers to match the Cost/Performance chart styling.
|
|
|
|
| 385 |
Args:
|
| 386 |
df: DataFrame with columns including 'parameter_count_b' or 'Parameter_Count_B',
|
| 387 |
'average score', 'openness', 'Language Model'
|
| 388 |
+
mark_by: One of "Company", "Openness", or "Country" - controls which icon to display
|
| 389 |
|
| 390 |
Returns:
|
| 391 |
Plotly figure showing accuracy vs model size (total parameters)
|
| 392 |
"""
|
| 393 |
import numpy as np
|
| 394 |
|
| 395 |
+
if mark_by is None:
|
| 396 |
+
mark_by = MARK_BY_DEFAULT
|
| 397 |
+
|
| 398 |
# Handle different column name formats for parameter count
|
| 399 |
param_col = None
|
| 400 |
for col in ['parameter_count_b', 'Parameter_Count_B', 'Parameter Count B']:
|
|
|
|
| 475 |
total_params = row[param_col]
|
| 476 |
model_name = row.get(model_col, 'Unknown')
|
| 477 |
score = row[score_col]
|
| 478 |
+
openness = row.get(openness_col, '')
|
| 479 |
|
| 480 |
# Use total params for x-axis
|
| 481 |
x_val = total_params
|
|
|
|
| 491 |
'y': score,
|
| 492 |
'model_name': model_name,
|
| 493 |
'hover_text': hover_text,
|
| 494 |
+
'total_params': total_params,
|
| 495 |
+
'openness': openness
|
| 496 |
})
|
| 497 |
|
| 498 |
x_values = [p['x'] for p in data_points]
|
|
|
|
| 551 |
)
|
| 552 |
))
|
| 553 |
|
| 554 |
+
# Add marker icon images for each data point (uniform size like Cost/Performance chart)
|
| 555 |
layout_images = []
|
| 556 |
|
| 557 |
for point in data_points:
|
| 558 |
x_val = point['x']
|
| 559 |
y_val = point['y']
|
| 560 |
model_name = point['model_name']
|
| 561 |
+
openness = point['openness']
|
| 562 |
|
| 563 |
+
marker_info = get_marker_icon(model_name, openness, mark_by)
|
| 564 |
+
logo_path = marker_info['path']
|
| 565 |
|
| 566 |
# Read the SVG file and encode as base64 data URI
|
| 567 |
if os.path.exists(logo_path):
|