import os from pathlib import Path def patch_gradio_leaderboard(): """Patch gradio_leaderboard JS to fix crash on tab switch with Gradio 5.x.""" import gradio_leaderboard pkg_dir = Path(gradio_leaderboard.__file__).parent js_file = pkg_dir / "templates" / "component" / "Index-CzS_eGV6.js" if not js_file.exists(): return src = js_file.read_text() patches = [ # Fix 1 & 2: Guard r[39]/a[39] filter callback (undefined during Svelte outro) ( 'r[0].filter(\n /*func*/\n r[39]\n ).map(qd)', '(r[39] ? r[0].filter(r[39]) : r[0]).map(qd)', ), ( 'a[0].filter(\n /*func*/\n a[39]\n ).map(qd))', '(a[39] ? a[0].filter(a[39]) : a[0]).map(qd))', ), # Fix 3: Lx (Boolean) extracted from Rx (globals) which is undefined in Gradio 5 ( '{ Boolean: Lx } = Rx,', 'Lx = (Rx && Rx.Boolean) || Boolean,', ), ] patched = False for old, new in patches: if old in src: src = src.replace(old, new) patched = True if patched: js_file.write_text(src) patch_gradio_leaderboard() import gradio as gr import pandas as pd from apscheduler.schedulers.background import BackgroundScheduler from gradio_leaderboard import ColumnFilter, Leaderboard, SelectColumns from huggingface_hub import HfApi from src.analytics import ( MATRIX_METRICS, RANKING_METRICS, TRADEOFF_METRICS, benchmarks_for_category, coverage_summary, cross_benchmark_ranking_df, enrich_analysis_df, filter_category, matrix_df, ranking_df, ) from src.charts import ( clean_markdown_link, create_coverage_matrix_plot, create_leaderboard_benchmark_plot, create_matrix_plot, create_performance_vs_resource_plot, create_ranking_plot, create_tradeoff_plot, ) from src.display.text_blocks import ( HOW_TO_USE_TEXT, INTRODUCTION_TEXT, LLM_BENCHMARKS_TEXT, ) from src.leaderboard import ( EFFICIENCY_RESOURCE_METRICS, get_analysis_df, get_benchmark_names, get_benchmark_run_df, get_efficiency_df, ) from src.rankings import EXCLUDED_BENCHMARKS, RANK_BY_OPTIONS, load_and_rank from src.version import __version__ REPO_ID = "red-hat-emerging-technologies/coding-agent-leaderboard" TOKEN = os.environ.get("HF_TOKEN") API = HfApi(token=TOKEN) COLOR_BY_CHOICES = ["Model", "Harness"] EFFICIENCY_COLOR_BY_CHOICES = ["Model", "Harness"] COLOR_PALETTE_CHOICES = ["Citrus", "Okabe-Ito", "High contrast", "Rainbow"] DEFAULT_COLOR_PALETTE = "Citrus" PLOT_BACKGROUND_CHOICES = ["Dark", "White"] DEFAULT_PLOT_BACKGROUND = "Dark" RESPONSIVE_PLOT_MIN_HEIGHT_PX = 420 TABLE_MAX_HEIGHT_PX = 720 RESPONSIVE_PLOT_CSS = f""" """ FORCE_DARK_MODE_HEAD = ( """ """ + RESPONSIVE_PLOT_CSS ) def restart_space(): API.restart_space(repo_id=REPO_ID) BENCHMARK_NAMES = get_benchmark_names() DEFAULT_BENCHMARK = BENCHMARK_NAMES[0] if BENCHMARK_NAMES else None BENCHMARK_RUN_DF = get_benchmark_run_df() ANALYSIS_DF = get_analysis_df() PR2_DF = enrich_analysis_df(ANALYSIS_DF) CODING_BENCHMARKS = benchmarks_for_category(PR2_DF, "Coding") GENERALIST_BENCHMARKS = benchmarks_for_category(PR2_DF, "Generalist") def render_leaderboard_benchmark_plot( benchmark_name, color_by, color_palette=DEFAULT_COLOR_PALETTE, plot_background=DEFAULT_PLOT_BACKGROUND, ): return create_leaderboard_benchmark_plot( BENCHMARK_RUN_DF, benchmark_name=benchmark_name, color_by=color_by, palette_name=color_palette, background_name=plot_background, ) def render_efficiency( benchmark_name, token_metric, color_by, x_scale, show_pareto_frontier, show_labels, color_palette=DEFAULT_COLOR_PALETTE, plot_background=DEFAULT_PLOT_BACKGROUND, ): plot_df = get_efficiency_df( benchmark_name=benchmark_name, resource_metric=token_metric, analysis_df=ANALYSIS_DF, ) exclusion_count = plot_df.attrs.get("exclusion_count", 0) note = ( f"{exclusion_count} runs excluded for this benchmark because " f"{token_metric.lower()} was missing or non-positive." ) figure = create_performance_vs_resource_plot( plot_df, resource_metric=token_metric, color_by=color_by, x_scale=x_scale, show_pareto_frontier=show_pareto_frontier, show_labels=show_labels, palette_name=color_palette, background_name=plot_background, ) return figure, note PAGE_TABLE_COLUMNS = [ "Model", "Harness", "Benchmark", "Score (%)", "Within-Benchmark Rank", "Within-Benchmark Percentile", "Total Tokens Per Task", "Cost Per Task", "Total Time Per Task", "Agent Time Per Task", "Execution Error Rate (%)", "Tokens Per Successful Task", "Cost Per Successful Task", "Time Per Successful Task", ] PAGE_TABLE_SORT_COLUMNS = { "Score": "Score (%)", "Rank": "Within-Benchmark Rank", "Percentile": "Within-Benchmark Percentile", "Total tokens": "Total Tokens Per Task", "Cost": "Cost Per Task", "Response time": "Total Time Per Task", "Agent time": "Agent Time Per Task", "Execution error rate": "Execution Error Rate (%)", } PAGE_TABLE_HIGHER_IS_BETTER = { "Score": True, "Rank": False, "Percentile": True, "Total tokens": False, "Cost": False, "Response time": False, "Agent time": False, "Execution error rate": False, } def render_page_table(benchmark, sort_metric="Score", sort_order="Best first"): """One compact table per page with all metrics relevant to ranking/trade-off views.""" data = PR2_DF.copy() if benchmark and benchmark != "All benchmarks": data = data[data["Benchmark"] == benchmark].copy() columns = [column for column in PAGE_TABLE_COLUMNS if column in data.columns] data = data[columns].copy() if data.empty: return data data["_agent"] = data["Model"].astype(str) + " / " + data["Harness"].astype(str) if sort_order == "Alphabetical (A–Z)": data = data.sort_values(["_agent", "Benchmark"], ascending=[True, True], kind="mergesort") elif sort_order == "Alphabetical (Z–A)": data = data.sort_values(["_agent", "Benchmark"], ascending=[False, True], kind="mergesort") else: sort_column = PAGE_TABLE_SORT_COLUMNS.get(sort_metric, "Score (%)") values = pd.to_numeric(data.get(sort_column), errors="coerce") data["_sort_value"] = values if sort_order == "Best first": ascending = not PAGE_TABLE_HIGHER_IS_BETTER.get(sort_metric, True) elif sort_order == "Best last": ascending = PAGE_TABLE_HIGHER_IS_BETTER.get(sort_metric, True) else: ascending = sort_order == "Lowest value first" data = data.sort_values( ["_sort_value", "_agent", "Benchmark"], ascending=[ascending, True, True], na_position="last", kind="mergesort", ).drop(columns="_sort_value") data = data.drop(columns="_agent").reset_index(drop=True) # Metrics displayed to 2 decimal places decimal_columns = [ "Score (%)", "Within-Benchmark Percentile", "Execution Error Rate (%)", "Cost Per Successful Task", ] for column in decimal_columns: if column in data.columns: data[column] = pd.to_numeric(data[column], errors="coerce").round(2) # Token and time metrics displayed as whole numbers whole_number_columns = [ "Total Tokens Per Task", "Total Time Per Task", "Agent Time Per Task", "Tokens Per Successful Task", "Time Per Successful Task", ] for column in whole_number_columns: if column in data.columns: data[column] = pd.to_numeric(data[column], errors="coerce").round(0) return data def render_ranking( metric, benchmark, color_by="Model", color_palette=DEFAULT_COLOR_PALETTE, plot_background=DEFAULT_PLOT_BACKGROUND, sort_order="Best first", ): def sort_table(table, metric_column, higher_is_better): if table is None or table.empty: return table work = table.copy() work["_agent"] = work["Model"].astype(str) + " / " + work["Harness"].astype(str) if sort_order == "Alphabetical (A–Z)": work = work.sort_values("_agent", ascending=True, kind="mergesort") elif sort_order == "Alphabetical (Z–A)": work = work.sort_values("_agent", ascending=False, kind="mergesort") elif sort_order in {"Best first", "Best last"}: ascending = not higher_is_better if sort_order == "Best last": ascending = not ascending work = work.sort_values( [metric_column, "_agent"], ascending=[ascending, True], kind="mergesort", ) elif sort_order == "Lowest value first": work = work.sort_values( [metric_column, "_agent"], ascending=[True, True], kind="mergesort", ) else: work = work.sort_values( [metric_column, "_agent"], ascending=[False, True], kind="mergesort", ) return work.drop(columns="_agent").reset_index(drop=True) table = ranking_df(PR2_DF, metric, benchmark=benchmark) spec = RANKING_METRICS[metric] table = sort_table(table, spec.column, spec.higher_is_better) figure = create_ranking_plot( table, spec.column, spec.label, spec.higher_is_better, color_by=color_by, palette_name=color_palette, background_name=plot_background, sort_order=sort_order, ) return figure, table TRADEOFF_PAIRS = { "Score vs cost": ("Cost Per Task", "Score (%)", "Cost per task (USD)", "Score (%)", True, True), "Score vs tokens": ("Total Tokens Per Task", "Score (%)", "Total tokens per task", "Score (%)", True, True), "Score vs total time": ("Total Time Per Task", "Score (%)", "Total time per task (seconds)", "Score (%)", True, True), "Score vs agent time": ("Agent Time Per Task", "Score (%)", "Agent time per task (seconds)", "Score (%)", True, True), "Score vs execution error rate": ( "Execution Error Rate (%)", "Score (%)", "Execution error rate (%)", "Score (%)", True, True ), "Tokens vs cost": ("Total Tokens Per Task", "Cost Per Task", "Total tokens per task", "Cost per task (USD)", True, False), "Cost vs total time": ("Cost Per Task", "Total Time Per Task", "Cost per task (USD)", "Total time per task (seconds)", True, False), } def render_tradeoff( pair, benchmark, color_by, show_labels, x_scale, show_pareto, color_palette, plot_background, ): x_column, y_column, x_label, y_label, lower_x, higher_y = TRADEOFF_PAIRS[pair] data = PR2_DF[PR2_DF["Benchmark"] == benchmark].copy() figure = create_tradeoff_plot( data, x_column=x_column, y_column=y_column, x_label=x_label, y_label=y_label, color_by=color_by, show_labels=show_labels, x_scale=x_scale, show_pareto_frontier=show_pareto, lower_x_is_better=lower_x, higher_y_is_better=higher_y, palette_name=color_palette, background_name=plot_background, ) valid = data[[x_column, y_column]].apply(pd.to_numeric, errors="coerce").dropna() note = f"{len(valid)} comparable runs shown for {benchmark}; missing metrics are omitted, not treated as zero." return figure, note def render_matrix( metric, category, include_incomplete, sort_by, show_values, reverse_scale, plot_background, ): category_filter = None if category == "All" else category matrix = matrix_df( PR2_DF, metric, category=category_filter, include_incomplete=include_incomplete, sort_by=sort_by, ) if metric == "Coverage": return create_coverage_matrix_plot(matrix, plot_background) spec = MATRIX_METRICS[metric] display_matrix = None display_metric_label = None if metric == "Within-benchmark percentile": display_matrix = matrix_df( PR2_DF, "Score", category=category_filter, include_incomplete=include_incomplete, sort_by=sort_by, ).reindex(index=matrix.index, columns=matrix.columns) display_metric_label = "Benchmark score (%)" return create_matrix_plot( matrix, f"{metric} matrix", spec.label, higher_is_better=spec.higher_is_better, show_values=show_values, reverse_scale=reverse_scale, background_name=plot_background, display_matrix=display_matrix, display_metric_label=display_metric_label, ) def category_leaderboard(category): data = filter_category(PR2_DF, category) if data.empty: return pd.DataFrame() normalized = cross_benchmark_ranking_df(data, minimum_coverage=0) return normalized def render_category_tradeoff(category, benchmark, metric, color_by, show_labels, plot_background): data = filter_category(PR2_DF, category) data = data[data["Benchmark"] == benchmark] spec = TRADEOFF_METRICS[metric] return create_tradeoff_plot( data, x_column=spec.column, y_column="Score (%)", x_label=spec.label, y_label="Score (%)", color_by=color_by, show_labels=show_labels, show_pareto_frontier=metric != "Execution error rate", lower_x_is_better=True, higher_y_is_better=True, background_name=plot_background, ) def render_category_matrix(category, metric, show_values, plot_background): matrix = matrix_df(PR2_DF, metric, category=category, include_incomplete=True) if metric == "Coverage": return create_coverage_matrix_plot(matrix, plot_background) spec = MATRIX_METRICS[metric] display_matrix = None display_metric_label = None if metric == "Within-benchmark percentile": display_matrix = matrix_df( PR2_DF, "Score", category=category, include_incomplete=True ).reindex(index=matrix.index, columns=matrix.columns) display_metric_label = "Benchmark score (%)" return create_matrix_plot( matrix, f"{category} — {metric}", spec.label, higher_is_better=spec.higher_is_better, show_values=show_values, background_name=plot_background, display_matrix=display_matrix, display_metric_label=display_metric_label, ) def build_header_html(df): summary = coverage_summary(PR2_DF) return f"""

Coding Agent Leaderboard v{__version__}

Performance, efficiency, coverage, and reliability across coding-agent benchmarks. Each result is one model + harness run on one benchmark.

{summary['results']}benchmark results
{summary['models']}models
{summary['harnesses']}harnesses
{summary['benchmarks']}benchmarks
{summary['token_coverage_pct']:.0f}%token coverage
{summary['cost_coverage_pct']:.0f}%cost coverage
{summary['time_coverage_pct']:.0f}%timing coverage

Cross-benchmark ordering uses within-benchmark percentiles rather than averaging incompatible raw score scales. Missing metrics remain missing and reduce coverage; they are never converted to zero.

""" def build_overview_html(): summary = coverage_summary(PR2_DF) return f"""
{summary['results']}benchmark results
{summary['models']}models
{summary['harnesses']}harnesses
{summary['benchmarks']}benchmarks
{summary['token_coverage_pct']:.0f}%token coverage
{summary['cost_coverage_pct']:.0f}%cost coverage
{summary['time_coverage_pct']:.0f}%timing coverage
""" def init_benchmark_runs(dataframe): if dataframe is None or dataframe.empty: raise ValueError("Leaderboard DataFrame is empty or None.") label_choices = [("🟠 Fully FOSS", "🟠"), ("🔶 Proprietary", "🔶")] benchmark_choices = sorted({(clean_markdown_link(v), v) for v in dataframe["Benchmark"]}) model_choices = sorted({(clean_markdown_link(v), v) for v in dataframe["Model"]}) harness_choices = sorted({(clean_markdown_link(v), v) for v in dataframe["Harness"]}) return Leaderboard( value=dataframe, select_columns=SelectColumns( default_selection=[ " ", "Model", "Harness", "Benchmark", "Score", "Avg Cost Per Task (USD)", ], label="Select Columns to Display:", ), datatype="markdown", search_columns=[ "Benchmark", "Harness", "Model", ], filter_columns=[ ColumnFilter(label="Category", column=" ", type="checkboxgroup", choices=label_choices), ColumnFilter(label="Benchmark", column="Benchmark", type="checkboxgroup", choices=benchmark_choices), ColumnFilter(label="Model", column="Model", type="checkboxgroup", choices=model_choices), ColumnFilter(label="Harness", column="Harness", type="checkboxgroup", choices=harness_choices), ColumnFilter(label="Number of Parameters (B)", column="Model Num Params (B)", type="slider"), ColumnFilter(label="Precision", column="Precision", type="checkboxgroup"), ], interactive=False, ) def add_category_section(category, benchmarks): if not benchmarks: gr.Markdown(f"No active benchmarks are currently classified as **{category}**.") return gr.Markdown( f"Results classified as **{category}**. Cross-benchmark ordering uses within-benchmark " "percentiles and reports coverage; raw benchmark scores are not averaged together." ) gr.Markdown("#### Trade-offs") with gr.Row(): benchmark = gr.Dropdown(choices=benchmarks, value=benchmarks[0], label="Benchmark") metric = gr.Dropdown( choices=["Cost per task", "Total tokens per task", "Total time per task", "Execution error rate"], value="Cost per task", label="X metric", ) color_by = gr.Radio(choices=COLOR_BY_CHOICES, value="Model", label="Color by") labels = gr.Checkbox(value=False, label="Show point labels") background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) plot = gr.Plot( value=render_category_tradeoff(category, benchmarks[0], "Cost per task", "Model", False, "Dark"), show_label=False, elem_classes="responsive-plot", ) controls = [benchmark, metric, color_by, labels, background] for control in controls: control.change( fn=lambda b, m, c, l, bg, cat=category: render_category_tradeoff(cat, b, m, c, l, bg), inputs=controls, outputs=plot, ) gr.Markdown("#### Matrix") with gr.Row(): matrix_metric = gr.Dropdown( choices=[ "Score", "Within-benchmark percentile", "Within-benchmark rank", "Total tokens", "Cost", "Total time", "Agent time", "Execution error rate", "Coverage" ], value="Within-benchmark percentile", label="Metric", ) matrix_values = gr.Checkbox(value=True, label="Show cell values") matrix_background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) matrix_plot = gr.Plot( value=render_category_matrix(category, "Within-benchmark percentile", True, "Dark"), show_label=False, elem_classes="responsive-plot", ) matrix_controls = [matrix_metric, matrix_values, matrix_background] for control in matrix_controls: control.change( fn=lambda m, v, bg, cat=category: render_category_matrix(cat, m, v, bg), inputs=matrix_controls, outputs=matrix_plot, ) gr.Markdown("#### Category ranking data") gr.Dataframe( value=category_leaderboard(category), interactive=False, show_label=False, max_height=TABLE_MAX_HEIGHT_PX ) demo = gr.Blocks(theme="citrus", head=FORCE_DARK_MODE_HEAD) with demo: # Overview is deliberately always visible above the page navigation. gr.HTML(build_header_html(BENCHMARK_RUN_DF)) with gr.Tabs(): with gr.Tab("Rankings"): gr.Markdown( "### Rankings\n" "Paired comparisons are shown first, followed by benchmark-specific metric rankings." ) gr.Markdown("### Paired Comparisons") gr.Markdown( "Rankings computed from head-to-head benchmark results using " "a Bradley–Terry paired-comparison model. " "Handles missing data and inconsistent orderings." ) rank_csv = pd.read_csv("results.csv") rank_csv = rank_csv.dropna(subset=["metrics.score"]) rank_csv = rank_csv.loc[~rank_csv["benchmark.name"].isin(EXCLUDED_BENCHMARKS)] rank_model_choices = sorted(rank_csv["model.name"].unique().tolist()) rank_harness_choices = sorted(rank_csv["harness.name"].unique().tolist()) rank_benchmark_choices = sorted(rank_csv["benchmark.name"].unique().tolist()) with gr.Row(): rank_by = gr.Dropdown( choices=list(RANK_BY_OPTIONS.keys()), value="Benchmark Score", label="Rank by", ) rank_oss_models = gr.Checkbox(value=False, label="Open models only") rank_oss_harnesses = gr.Checkbox(value=False, label="Open harnesses only") with gr.Row(): rank_benchmark_filter = gr.CheckboxGroup( choices=rank_benchmark_choices, value=rank_benchmark_choices, label="Benchmarks", ) with gr.Row(): rank_model_filter = gr.CheckboxGroup( choices=rank_model_choices, value=rank_model_choices, label="Models", ) with gr.Row(): rank_harness_filter = gr.CheckboxGroup( choices=rank_harness_choices, value=rank_harness_choices, label="Harnesses", ) harness_df_init, model_df_init, pair_df_init = load_and_rank("results.csv") gr.Markdown("#### Harness ranking") harness_table = gr.Dataframe(value=harness_df_init, interactive=False) gr.Markdown("#### Model ranking") model_table = gr.Dataframe(value=model_df_init, interactive=False) gr.Markdown("#### Model + harness ranking") pair_table = gr.Dataframe(value=pair_df_init, interactive=False) def update_rankings(rank_by_val, oss_models, oss_harnesses, benchmarks, models, harnesses): return load_and_rank( "results.csv", open_models_only=oss_models, open_harnesses_only=oss_harnesses, benchmarks=benchmarks, models=models, harnesses=harnesses, rank_by=rank_by_val, ) ranking_inputs = [ rank_by, rank_oss_models, rank_oss_harnesses, rank_benchmark_filter, rank_model_filter, rank_harness_filter, ] for control in ranking_inputs: control.change( fn=update_rankings, inputs=ranking_inputs, outputs=[harness_table, model_table, pair_table], ) gr.Markdown( "### Metric rankings\n" "Use the shared display controls below, then choose a benchmark for each metric. " "Tables are capped to a scrollable height so the visualizations stay primary." ) with gr.Row(): ranking_color = gr.Radio(choices=COLOR_BY_CHOICES, value="Model", label="Color by") ranking_sort = gr.Dropdown( choices=[ "Best first", "Best last", "Alphabetical (A–Z)", "Alphabetical (Z–A)", ], value="Best first", label="Chart order", ) ranking_palette = gr.Dropdown( choices=COLOR_PALETTE_CHOICES, value=DEFAULT_COLOR_PALETTE, label="Color palette" ) ranking_background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) ranking_sections = [("Score", "Score", BENCHMARK_NAMES, DEFAULT_BENCHMARK)] ranking_sections += [ ("Token usage", "Total tokens", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Cost", "Cost", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Response time", "Response time", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Reliability", "Reliability", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Tokens per successful task", "Tokens per successful task", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Cost per successful task", "Cost per successful task", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ("Time per successful task", "Time per successful task", BENCHMARK_NAMES, DEFAULT_BENCHMARK), ] shared_ranking_controls = [ranking_color, ranking_palette, ranking_background, ranking_sort] for section_label, metric_name, benchmark_choices, default_benchmark in ranking_sections: spec = RANKING_METRICS[metric_name] gr.Markdown(f"#### {section_label}\n{spec.label}. {'Higher' if spec.higher_is_better else 'Lower'} is better.") benchmark = gr.Dropdown( choices=benchmark_choices, value=default_benchmark, label="Benchmark" ) initial = render_ranking( metric_name, default_benchmark, "Model", DEFAULT_COLOR_PALETTE, DEFAULT_PLOT_BACKGROUND, "Best first", ) plot = gr.Plot(value=initial[0], show_label=False, elem_classes="responsive-plot") controls = [benchmark, *shared_ranking_controls] for control in controls: control.change( fn=lambda b, c, p, bg, so, m=metric_name: render_ranking(m, b, c, p, bg, so)[0], inputs=controls, outputs=plot, ) gr.Markdown( "### Ranking data\n" "One table for the page, placed after all charts. It includes the score, resource, timing, " "reliability, and per-success values for the selected benchmark." ) with gr.Row(): ranking_table_benchmark = gr.Dropdown( choices=BENCHMARK_NAMES, value=DEFAULT_BENCHMARK, label="Table benchmark" ) ranking_table_metric = gr.Dropdown( choices=list(PAGE_TABLE_SORT_COLUMNS), value="Score", label="Sort table by" ) ranking_table_order = gr.Dropdown( choices=[ "Best first", "Best last", "Alphabetical (A–Z)", "Alphabetical (Z–A)", ], value="Best first", label="Table order", ) ranking_page_table = gr.Dataframe( value=render_page_table(DEFAULT_BENCHMARK, "Score", "Best first"), interactive=False, show_label=False, max_height=TABLE_MAX_HEIGHT_PX, ) ranking_table_controls = [ranking_table_benchmark, ranking_table_metric, ranking_table_order] for control in ranking_table_controls: control.change( fn=render_page_table, inputs=ranking_table_controls, outputs=ranking_page_table, ) with gr.Tab("Trade-offs"): gr.Markdown( "### Trade-offs\n" "Efficiency and metric-pair views are displayed together. Pareto frontiers support both maximize and " "minimize directions, so a checked frontier is shown whenever valid comparable points exist." ) gr.Markdown("#### Efficiency") with gr.Row(): efficiency_benchmark = gr.Dropdown( choices=BENCHMARK_NAMES, value=DEFAULT_BENCHMARK, label="Benchmark" ) efficiency_metric = gr.Dropdown( choices=list(EFFICIENCY_RESOURCE_METRICS), value="Total tokens", label="Resource metric" ) efficiency_color_by = gr.Radio( choices=EFFICIENCY_COLOR_BY_CHOICES, value="Model", label="Color by" ) efficiency_scale = gr.Radio(choices=["Log", "Linear"], value="Log", label="X-axis scale") with gr.Row(): efficiency_pareto = gr.Checkbox(value=True, label="Show Pareto frontier") efficiency_labels = gr.Checkbox(value=False, label="Show point labels") efficiency_palette = gr.Dropdown( choices=COLOR_PALETTE_CHOICES, value=DEFAULT_COLOR_PALETTE, label="Color palette" ) efficiency_background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) initial_efficiency = render_efficiency( DEFAULT_BENCHMARK, "Total tokens", "Model", "Log", True, False, DEFAULT_COLOR_PALETTE, DEFAULT_PLOT_BACKGROUND, ) efficiency_note = gr.Markdown(initial_efficiency[1]) efficiency_plot = gr.Plot( value=initial_efficiency[0], show_label=False, elem_classes="responsive-plot" ) efficiency_controls = [ efficiency_benchmark, efficiency_metric, efficiency_color_by, efficiency_scale, efficiency_pareto, efficiency_labels, efficiency_palette, efficiency_background, ] for control in efficiency_controls: control.change( fn=render_efficiency, inputs=efficiency_controls, outputs=[efficiency_plot, efficiency_note], ) gr.Markdown("#### Metric pairs") with gr.Row(): tradeoff_pair = gr.Dropdown( choices=list(TRADEOFF_PAIRS), value="Score vs cost", label="Trade-off" ) tradeoff_benchmark = gr.Dropdown( choices=BENCHMARK_NAMES, value=DEFAULT_BENCHMARK, label="Benchmark" ) tradeoff_color = gr.Radio(choices=COLOR_BY_CHOICES, value="Model", label="Color by") tradeoff_scale = gr.Radio(choices=["Linear", "Log"], value="Linear", label="X-axis scale") with gr.Row(): tradeoff_labels = gr.Checkbox(value=False, label="Show point labels") tradeoff_pareto = gr.Checkbox(value=True, label="Show Pareto frontier") tradeoff_palette = gr.Dropdown( choices=COLOR_PALETTE_CHOICES, value=DEFAULT_COLOR_PALETTE, label="Color palette" ) tradeoff_background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) initial_tradeoff = render_tradeoff( "Score vs cost", DEFAULT_BENCHMARK, "Model", False, "Linear", True, DEFAULT_COLOR_PALETTE, DEFAULT_PLOT_BACKGROUND, ) tradeoff_note = gr.Markdown(initial_tradeoff[1]) tradeoff_plot = gr.Plot( value=initial_tradeoff[0], show_label=False, elem_classes="responsive-plot" ) tradeoff_controls = [ tradeoff_pair, tradeoff_benchmark, tradeoff_color, tradeoff_labels, tradeoff_scale, tradeoff_pareto, tradeoff_palette, tradeoff_background, ] for control in tradeoff_controls: control.change( fn=render_tradeoff, inputs=tradeoff_controls, outputs=[tradeoff_plot, tradeoff_note], ) gr.Markdown( "### Trade-off data\n" "A single table for this page appears after both charts and includes every metric used by the trade-off views." ) with gr.Row(): tradeoff_table_benchmark = gr.Dropdown( choices=BENCHMARK_NAMES, value=DEFAULT_BENCHMARK, label="Table benchmark" ) tradeoff_table_metric = gr.Dropdown( choices=list(PAGE_TABLE_SORT_COLUMNS), value="Score", label="Sort table by" ) tradeoff_table_order = gr.Dropdown( choices=[ "Largest value first", "Lowest value first", "Alphabetical (A–Z)", "Alphabetical (Z–A)", ], value="Largest value first", label="Table order", ) tradeoff_page_table = gr.Dataframe( value=render_page_table(DEFAULT_BENCHMARK, "Score", "Largest value first"), interactive=False, show_label=False, max_height=TABLE_MAX_HEIGHT_PX, ) tradeoff_table_controls = [tradeoff_table_benchmark, tradeoff_table_metric, tradeoff_table_order] for control in tradeoff_table_controls: control.change( fn=render_page_table, inputs=tradeoff_table_controls, outputs=tradeoff_page_table, ) with gr.Tab("Matrices"): gr.Markdown( "### Model × benchmark matrices\n" "The within-benchmark percentile controls the color scale, while cell labels show the actual benchmark " "score. Missing cells stay missing." ) with gr.Row(): matrix_metric = gr.Dropdown( choices=[*MATRIX_METRICS.keys(), "Coverage"], value="Within-benchmark percentile", label="Metric", ) matrix_category = gr.Dropdown( choices=["All", "Coding", "Generalist"], value="All", label="Benchmark category" ) matrix_sort = gr.Dropdown( choices=[ "Normalized performance (high to low)", "Normalized performance (low to high)", "Coverage (high to low)", "Coverage (low to high)", "Alphabetical", "Alphabetical (Z–A)", ], value="Normalized performance (high to low)", label="Sort rows", ) matrix_background = gr.Dropdown( choices=PLOT_BACKGROUND_CHOICES, value=DEFAULT_PLOT_BACKGROUND, label="Image background" ) with gr.Row(): matrix_incomplete = gr.Checkbox(value=True, label="Include incomplete rows") matrix_values = gr.Checkbox(value=True, label="Show cell values") matrix_reverse = gr.Checkbox(value=False, label="Reverse color scale") initial_matrix = render_matrix( "Within-benchmark percentile", "All", True, "Normalized performance (high to low)", True, False, "Dark" ) matrix_plot = gr.Plot(value=initial_matrix, show_label=False, elem_classes="responsive-plot") matrix_controls = [ matrix_metric, matrix_category, matrix_incomplete, matrix_sort, matrix_values, matrix_reverse, matrix_background, ] for control in matrix_controls: control.change(fn=render_matrix, inputs=matrix_controls, outputs=matrix_plot) with gr.Tab("Coding"): gr.Markdown( "### Coding\n" "Coding benchmarks are defined centrally in the benchmark catalog. The aggregate leaderboard uses " "within-benchmark percentiles and displays benchmark coverage." ) add_category_section("Coding", CODING_BENCHMARKS) with gr.Tab("Generalist"): gr.Markdown( "### Terminal & Generalist\n" "This category reflects active terminal/generalist benchmarks present in the repository." ) add_category_section("Generalist", GENERALIST_BENCHMARKS) with gr.Tab("Results Explorer"): gr.Markdown("### Benchmark runs") benchmark_runs = init_benchmark_runs(BENCHMARK_RUN_DF) gr.Markdown("### Methodology") gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text") gr.Markdown( "### Analytics methodology notes\n" "- **Normalized ordering:** rank/percentile is calculated independently inside each benchmark, then " "aggregated by model + harness with coverage shown beside it.\n" "- **Execution error rate:** recorded errors divided by recorded task count; unresolved tasks are not " "relabeled as errors.\n" "- **Missing metrics:** omitted from metric-specific comparisons and preserved as missing matrix cells.\n" "- **Pareto frontier:** benchmark-specific and direction-aware for maximize/minimize metric pairs." ) gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text") gr.Markdown(HOW_TO_USE_TEXT, elem_classes="markdown-text") scheduler = BackgroundScheduler() scheduler.add_job(restart_space, "interval", seconds=1800) scheduler.start() demo.queue(default_concurrency_limit=40).launch()