Spaces:
Running
Running
openhands openhands commited on
Commit ·
800e404
1
Parent(s): b1f3e49
Add company logos to graphs and tables, label frontier points with model names
Browse files- Created SVG logo files for major AI companies (Anthropic, OpenAI, Google, Meta, Mistral, DeepSeek, xAI, Cohere, Alibaba, Moonshot)
- Added company logo mapping based on model name patterns
- Added Company logo column to both main leaderboard and benchmark tables
- Added company logo images on scatter plots at each data point
- Added model name labels to Pareto frontier points on graphs
- Updated column widths to accommodate new Company column
Co-authored-by: openhands <openhands@all-hands.dev>
Files changed (13)
- assets/logo-alibaba.svgAdded
- assets/logo-anthropic.svgAdded
- assets/logo-cohere.svgAdded
- assets/logo-deepseek.svgAdded
- assets/logo-google.svgAdded
- assets/logo-meta.svgAdded
- assets/logo-mistral.svgAdded
- assets/logo-moonshot.svgAdded
- assets/logo-openai.svgAdded
- assets/logo-unknown.svgAdded
- assets/logo-xai.svgAdded
- leaderboard_transformer.py+132-3
- ui_components.py+81-5
4 unmodified lines56789101112131415407 unmodified lines4234244254264274283 unmodified lines43243343443543643758 unmodified lines49649749849950050150215 unmodified lines51851952052152252311 unmodified lines5355365375385395405415425435446 unmodified lines5515525535545555564 unmodified linesfrom typing import Optionalimport base64import htmlimport aliaseslogger = logging.getLogger(__name__)INFORMAL_TO_FORMAL_NAME_MAP = {# Short Names"lit": "Literature Understanding",407 unmodified linesreturn fig# --- Section 4: Calculate and Draw Pareto Frontier ---if x_col_to_use and y_col_to_use:sorted_data = data_plot.sort_values(by=[x_col_to_use, y_col_to_use], ascending=[True, False])frontier_points = []3 unmodified linesscore = row[y_col_to_use]if score >= max_score_so_far:frontier_points.append({'x': row[x_col_to_use], 'y': score})max_score_so_far = scoreif frontier_points:58 unmodified lines# Use consistent shape for all points (no tooling distinction)data_plot['shape_symbol'] = default_shape# --- Section 6: Plot Markers by "Openness" Category ---for category in category_order:group = data_plot[data_plot['Openness'] == category]if group.empty:15 unmodified linesline=dict(width=1, color='deeppink'))))# --- Section 8: Configure Layout ---xaxis_config = dict(title=x_axis_label, rangemode="tozero")11 unmodified linesxaxis_config['range'] = [-0.2, (max_reported_cost + (max_reported_cost / 4))]fig.update_layout(template="plotly_white",title=f"OpenHands Index {name} Leaderboard",xaxis=xaxis_config, # Use the updated configyaxis=dict(title="Average (mean) score", range=[-0.2, None]),legend=dict(bgcolor='#FAF2E9',6 unmodified linesfont_color="#d3dedc",),)return fig4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465407 unmodified lines4734744754764774784793 unmodified lines48348448548648748848958 unmodified lines54854955055155255355455555655715 unmodified lines57357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464511 unmodified lines6576586596606616626636646656666676 unmodified lines6746756766776786796806816826836846854 unmodified linesfrom typing import Optionalimport base64import htmlimport osimport aliaseslogger = logging.getLogger(__name__)# Company logo mapping for graphs - maps model name patterns to company logo filesCOMPANY_LOGO_MAP = {"anthropic": {"path": "assets/logo-anthropic.svg", "name": "Anthropic"},"claude": {"path": "assets/logo-anthropic.svg", "name": "Anthropic"},"openai": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"gpt": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"o1": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"o3": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"google": {"path": "assets/logo-google.svg", "name": "Google"},"gemini": {"path": "assets/logo-google.svg", "name": "Google"},"gemma": {"path": "assets/logo-google.svg", "name": "Google"},"meta": {"path": "assets/logo-meta.svg", "name": "Meta"},"llama": {"path": "assets/logo-meta.svg", "name": "Meta"},"mistral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"mixtral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"codestral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"deepseek": {"path": "assets/logo-deepseek.svg", "name": "DeepSeek"},"xai": {"path": "assets/logo-xai.svg", "name": "xAI"},"grok": {"path": "assets/logo-xai.svg", "name": "xAI"},"cohere": {"path": "assets/logo-cohere.svg", "name": "Cohere"},"command": {"path": "assets/logo-cohere.svg", "name": "Cohere"},"qwen": {"path": "assets/logo-alibaba.svg", "name": "Alibaba"},"alibaba": {"path": "assets/logo-alibaba.svg", "name": "Alibaba"},"kimi": {"path": "assets/logo-moonshot.svg", "name": "Moonshot"},"moonshot": {"path": "assets/logo-moonshot.svg", "name": "Moonshot"},}def get_company_from_model_name(model_name: str) -> dict:"""Gets the company info (logo path and name) from a model name.Returns default unknown logo if no match found."""if not model_name:return {"path": "assets/logo-unknown.svg", "name": "Unknown"}# Handle list of models - use the first oneif isinstance(model_name, list):model_name = model_name[0] if model_name else ""model_lower = str(model_name).lower()# Check each patternfor pattern, company_info in COMPANY_LOGO_MAP.items():if pattern in model_lower:return company_inforeturn {"path": "assets/logo-unknown.svg", "name": "Unknown"}INFORMAL_TO_FORMAL_NAME_MAP = {# Short Names"lit": "Literature Understanding",407 unmodified linesreturn fig# --- Section 4: Calculate and Draw Pareto Frontier ---frontier_rows = [] # Store entire rows for frontier points to access model namesif x_col_to_use and y_col_to_use:sorted_data = data_plot.sort_values(by=[x_col_to_use, y_col_to_use], ascending=[True, False])frontier_points = []3 unmodified linesscore = row[y_col_to_use]if score >= max_score_so_far:frontier_points.append({'x': row[x_col_to_use], 'y': score})frontier_rows.append(row)max_score_so_far = scoreif frontier_points:58 unmodified lines# Use consistent shape for all points (no tooling distinction)data_plot['shape_symbol'] = default_shape# --- Section 6: Plot Markers by "Openness" Category with Company Logos ---# Collect layout images for company logoslayout_images = []for category in category_order:group = data_plot[data_plot['Openness'] == category]if group.empty:15 unmodified linesline=dict(width=1, color='deeppink'))))# Add company logo images for each point in this groupfor _, row in group.iterrows():model_name = row.get('Language Model', '')company_info = get_company_from_model_name(model_name)logo_path = company_info['path']# Read the SVG file and encode as base64 data URIif os.path.exists(logo_path):try:with open(logo_path, 'rb') as f:encoded_logo = base64.b64encode(f.read()).decode('utf-8')logo_uri = f"data:image/svg+xml;base64,{encoded_logo}"# Add image at data point position with small offsetlayout_images.append(dict(source=logo_uri,xref="x",yref="y",x=row[x_col_to_use],y=row[y_col_to_use],sizex=max_reported_cost * 0.06 if max_reported_cost > 0 else 0.5, # Scale relative to datasizey=3, # Fixed y size in data unitsxanchor="center",yanchor="bottom",layer="above"))except Exception as e:logger.warning(f"Could not load logo {logo_path}: {e}")# --- Section 7: Add Model Name Labels to Frontier Points ---if frontier_rows:frontier_x = []frontier_y = []frontier_labels = []for row in frontier_rows:frontier_x.append(row[x_col_to_use])frontier_y.append(row[y_col_to_use])# Get the model name for the labelmodel_name = row.get('Language Model', '')if isinstance(model_name, list):model_name = model_name[0] if model_name else ''# Clean the model name (remove path prefixes)model_name = str(model_name).split('/')[-1]# Truncate long namesif len(model_name) > 25:model_name = model_name[:22] + '...'frontier_labels.append(model_name)# Add text labels for frontier pointsfig.add_trace(go.Scatter(x=frontier_x,y=frontier_y,mode='text',name='Frontier Labels',showlegend=False,text=frontier_labels,textposition='top center',textfont=dict(size=10,color='#032629',family='Manrope'),hoverinfo='skip'))# --- Section 8: Configure Layout ---xaxis_config = dict(title=x_axis_label, rangemode="tozero")11 unmodified linesxaxis_config['range'] = [-0.2, (max_reported_cost + (max_reported_cost / 4))]# Build layout configurationlayout_config = dict(template="plotly_white",title=f"OpenHands Index {name} Leaderboard",xaxis=xaxis_config,yaxis=dict(title="Average (mean) score", range=[-0.2, None]),legend=dict(bgcolor='#FAF2E9',6 unmodified linesfont_color="#d3dedc",),)# Add company logo images to the layout if any were collectedif layout_images:layout_config['images'] = layout_imagesfig.update_layout(**layout_config)return fig
2 unmodified lines34567827 unmodified lines363738394041342 unmodified lines38438538638738838913 unmodified lines4034044054064074084 unmodified lines41341441541641741821 unmodified lines440441442443444445446447448449450451147 unmodified lines59960060160260360428 unmodified lines63363463563663763811 unmodified lines6506516526536546556566576586593 unmodified lines66366466566666766866919 unmodified lines6896906916926936946952 unmodified linesimport plotly.graph_objects as goimport osimport base64from huggingface_hub import HfApi27 unmodified linesapi = HfApi()os.makedirs(EXTRACTED_DATA_DIR, exist_ok=True)# Simplified icon map (no tooling distinction, only openness)# Not actually used since we removed icons from the table, but keeping for potential future useOPENNESS_ICON_MAP = {342 unmodified linesreturn f'<img src="{uri}" alt="{openness_val}" title="{openness_val}" style="width:24px; height:24px;">'df_display['Icon'] = df_display.apply(get_openness_icon_html, axis=1)for col in df_display.columns:if "Cost" in col:13 unmodified lines)all_cols = df_display.columns.tolist()all_cols.insert(0, all_cols.pop(all_cols.index('Icon')))all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))df_display = df_display[all_cols]4 unmodified linesheader_rename_map = {"Pareto": "","Icon": "",}df_display = df_display.rename(columns=header_rename_map)21 unmodified linesfor col in df_headers:if col == "Logs" or "Cost" in col or "Score" in col:df_datatypes.append("markdown")elif col in ["SDK Version","Language Model", ""]: # "" for renamed Pareto/Icon columnsdf_datatypes.append("html")else:df_datatypes.append("str")# Dynamically set widths for the DataFrame columnsfixed_start_widths = [40, 40, 200, 100, 200]num_score_cost_cols = 0remaining_headers = df_headers[len(fixed_start_widths):]for col in remaining_headers:147 unmodified linesreturn f'<img src="{uri}" alt="{openness_val}" title="{openness_val}" style="width:24px; height:24px;">'benchmark_table_df['Icon'] = benchmark_table_df.apply(get_openness_icon_html, axis=1)#Make pretty and format the Language Model columnbenchmark_table_df['Language Model'] = benchmark_table_df['Language Model'].apply(clean_llm_base_list)28 unmodified linesdesired_cols_in_order = ['Pareto','Icon','Language Model','SDK Version','Attempted Benchmark',11 unmodified linesbenchmark_score_col: 'Score',benchmark_cost_col: 'Cost',}, inplace=True)# Remove Pareto and Icon column headers (rename to empty string)header_rename_map = {"Pareto": "","Icon": "",}benchmark_table_df = benchmark_table_df.rename(columns=header_rename_map)3 unmodified linesfor col in df_headers:if "Logs" in col or "Cost" in col or "Score" in col:df_datatypes.append("markdown")elif col in ["SDK Version", "Language Model", ""]: # "" for renamed Pareto/Icon columnsdf_datatypes.append("html")else:df_datatypes.append("str")19 unmodified linesdatatype=df_datatypes,interactive=False,wrap=True,column_widths=[40, 40, 200, 150, 175, 85, 100, 100, 80, 40],show_search="search",elem_classes=["wrap-header-df"])2 unmodified lines345678927 unmodified lines373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104342 unmodified lines44744844945045145245345445513 unmodified lines4694704714724734744754764774 unmodified lines48248348448548648748821 unmodified lines510511512513514515516517518519520521522147 unmodified lines67067167267367467567667767828 unmodified lines70770870971071171271311 unmodified lines7257267277287297307317327337347353 unmodified lines73974074174274374474519 unmodified lines7657667677687697707712 unmodified linesimport plotly.graph_objects as goimport osimport base64import refrom huggingface_hub import HfApi27 unmodified linesapi = HfApi()os.makedirs(EXTRACTED_DATA_DIR, exist_ok=True)# Company logo mapping - maps model name patterns to company logo filesCOMPANY_LOGO_MAP = {"anthropic": {"path": "assets/logo-anthropic.svg", "name": "Anthropic"},"claude": {"path": "assets/logo-anthropic.svg", "name": "Anthropic"},"openai": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"gpt": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"o1": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"o3": {"path": "assets/logo-openai.svg", "name": "OpenAI"},"google": {"path": "assets/logo-google.svg", "name": "Google"},"gemini": {"path": "assets/logo-google.svg", "name": "Google"},"gemma": {"path": "assets/logo-google.svg", "name": "Google"},"meta": {"path": "assets/logo-meta.svg", "name": "Meta"},"llama": {"path": "assets/logo-meta.svg", "name": "Meta"},"mistral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"mixtral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"codestral": {"path": "assets/logo-mistral.svg", "name": "Mistral"},"deepseek": {"path": "assets/logo-deepseek.svg", "name": "DeepSeek"},"xai": {"path": "assets/logo-xai.svg", "name": "xAI"},"grok": {"path": "assets/logo-xai.svg", "name": "xAI"},"cohere": {"path": "assets/logo-cohere.svg", "name": "Cohere"},"command": {"path": "assets/logo-cohere.svg", "name": "Cohere"},"qwen": {"path": "assets/logo-alibaba.svg", "name": "Alibaba"},"alibaba": {"path": "assets/logo-alibaba.svg", "name": "Alibaba"},"kimi": {"path": "assets/logo-moonshot.svg", "name": "Moonshot"},"moonshot": {"path": "assets/logo-moonshot.svg", "name": "Moonshot"},}def get_company_from_model(model_name: str) -> dict:"""Gets the company info (logo path and name) from a model name.Returns default unknown logo if no match found."""if not model_name:return {"path": "assets/logo-unknown.svg", "name": "Unknown"}# Handle list of models - use the first oneif isinstance(model_name, list):model_name = model_name[0] if model_name else ""model_lower = str(model_name).lower()# Check each patternfor pattern, company_info in COMPANY_LOGO_MAP.items():if pattern in model_lower:return company_inforeturn {"path": "assets/logo-unknown.svg", "name": "Unknown"}def get_company_logo_html(model_name: str) -> str:"""Generates HTML for a company logo based on the model name."""company_info = get_company_from_model(model_name)uri = get_svg_as_data_uri(company_info["path"])if uri:return f'<img src="{uri}" alt="{company_info["name"]}" title="{company_info["name"]}" style="width:20px; height:20px; vertical-align: middle;">'return ""# Simplified icon map (no tooling distinction, only openness)# Not actually used since we removed icons from the table, but keeping for potential future useOPENNESS_ICON_MAP = {342 unmodified linesreturn f'<img src="{uri}" alt="{openness_val}" title="{openness_val}" style="width:24px; height:24px;">'df_display['Icon'] = df_display.apply(get_openness_icon_html, axis=1)# Add company logo column based on the Language Modeldf_display['Company'] = df_display['Language Model'].apply(get_company_logo_html)for col in df_display.columns:if "Cost" in col:13 unmodified lines)all_cols = df_display.columns.tolist()# Move Company logo column after Iconif 'Company' in all_cols:all_cols.insert(0, all_cols.pop(all_cols.index('Company')))all_cols.insert(0, all_cols.pop(all_cols.index('Icon')))all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))df_display = df_display[all_cols]4 unmodified linesheader_rename_map = {"Pareto": "","Icon": "","Company": "",}df_display = df_display.rename(columns=header_rename_map)21 unmodified linesfor col in df_headers:if col == "Logs" or "Cost" in col or "Score" in col:df_datatypes.append("markdown")elif col in ["SDK Version","Language Model", ""]: # "" for renamed Pareto/Icon/Company columnsdf_datatypes.append("html")else:df_datatypes.append("str")# Dynamically set widths for the DataFrame columns# Order: Pareto, Icon, Company, Language Model, SDK Version, ...fixed_start_widths = [40, 40, 40, 200, 100, 200]num_score_cost_cols = 0remaining_headers = df_headers[len(fixed_start_widths):]for col in remaining_headers:147 unmodified linesreturn f'<img src="{uri}" alt="{openness_val}" title="{openness_val}" style="width:24px; height:24px;">'benchmark_table_df['Icon'] = benchmark_table_df.apply(get_openness_icon_html, axis=1)# Add company logo column based on the Language Modelbenchmark_table_df['Company'] = benchmark_table_df['Language Model'].apply(get_company_logo_html)#Make pretty and format the Language Model columnbenchmark_table_df['Language Model'] = benchmark_table_df['Language Model'].apply(clean_llm_base_list)28 unmodified linesdesired_cols_in_order = ['Pareto','Icon','Company','Language Model','SDK Version','Attempted Benchmark',11 unmodified linesbenchmark_score_col: 'Score',benchmark_cost_col: 'Cost',}, inplace=True)# Remove Pareto, Icon, and Company column headers (rename to empty string)header_rename_map = {"Pareto": "","Icon": "","Company": "",}benchmark_table_df = benchmark_table_df.rename(columns=header_rename_map)3 unmodified linesfor col in df_headers:if "Logs" in col or "Cost" in col or "Score" in col:df_datatypes.append("markdown")elif col in ["SDK Version", "Language Model", ""]: # "" for renamed Pareto/Icon/Company columnsdf_datatypes.append("html")else:df_datatypes.append("str")19 unmodified linesdatatype=df_datatypes,interactive=False,wrap=True,column_widths=[40, 40, 40, 200, 150, 175, 85, 100, 100, 80, 40],show_search="search",elem_classes=["wrap-header-df"])
assets/logo-alibaba.svgAdded
assets/logo-anthropic.svgAdded
assets/logo-cohere.svgAdded
assets/logo-deepseek.svgAdded
assets/logo-google.svgAdded
assets/logo-meta.svgAdded
assets/logo-mistral.svgAdded
assets/logo-moonshot.svgAdded
assets/logo-openai.svgAdded
assets/logo-unknown.svgAdded
assets/logo-xai.svgAdded
leaderboard_transformer.py+132-3
ui_components.py+81-5