Implementation:Lm sys FastChat Monitor Dashboard
| Knowledge Sources | |
|---|---|
| Domains | Model_Evaluation, Web_Interface |
| Last Updated | 2026-02-07 06:00 GMT |
Overview
monitor.py implements the main Gradio-based web dashboard for the Chatbot Arena leaderboard, providing interactive tabs for arena rankings, full leaderboard views, category breakdowns, and statistical visualizations.
Description
The monitor.py module is the largest and most user-facing component of the FastChat monitoring system at 1191 lines. It constructs a comprehensive Gradio application that serves as the public interface for the Chatbot Arena leaderboard. The dashboard presents model rankings, statistical plots, and interactive filtering options to researchers, developers, and the broader AI community.
The module is organized around several tab-building functions. The build_leaderboard_tab function creates the primary leaderboard view, loading precomputed Elo results and model metadata from cached files and rendering them as interactive tables with sorting and filtering. The build_arena_tab function constructs the arena-specific view showing pairwise battle statistics, win-rate heatmaps, and confidence interval plots. The build_full_leaderboard_tab and build_category_leaderboard_tab functions provide alternative leaderboard views: the full table includes all models with extended metadata, while the category view allows filtering rankings by conversation topic.
Supporting these tab builders are several helper functions. The load_leaderboard_table_csv function parses cached leaderboard data from CSV files. The recompute_final_ranking function recalculates ordinal rankings when filters are applied. The get_arena_table and get_full_table functions format DataFrames for display. The update_worker function handles background data refresh, polling for new battle results and recomputing rankings periodically. The top-level build_demo function assembles all tabs into a single Gradio Blocks application, and load_demo handles initialization with optional mirror mode for serving from alternative endpoints.
Usage
Use this module to launch or embed the Chatbot Arena leaderboard dashboard. It is deployed as a standalone Gradio application in production and can also be embedded within larger FastChat serving configurations. Developers extending the leaderboard with new tabs or visualizations should modify this module.
Code Reference
Source Location
- Repository: Lm_sys_FastChat
- File: fastchat/serve/monitor/monitor.py
- Lines: 1-1191
Signature
def build_leaderboard_tab(
elo_results_file: str,
leaderboard_table_file: str,
arena_hard_leaderboard: str = None,
show_plot: bool = False,
mirror: bool = False,
) -> gr.Blocks:
"""Build the primary leaderboard tab with Elo rankings."""
...
def build_demo(
elo_results_file: str,
leaderboard_table_file: str,
arena_hard_leaderboard: str = None,
) -> gr.Blocks:
"""Assemble the complete Gradio dashboard with all tabs."""
...
def build_arena_tab(
elo_results: dict,
model_table_df: pd.DataFrame,
default_md: str,
show_plot: bool = True,
vision: bool = False,
) -> gr.Blocks:
"""Build the arena statistics tab with heatmaps and plots."""
...
def build_full_leaderboard_tab(
elo_results: dict,
model_table_df: pd.DataFrame,
) -> gr.Blocks:
"""Build the full leaderboard tab with all models and extended metadata."""
...
def build_category_leaderboard_tab(
elo_results: dict,
model_table_df: pd.DataFrame,
categories: list[str],
) -> gr.Blocks:
"""Build the category-filtered leaderboard tab."""
...
def load_leaderboard_table_csv(leaderboard_table_file: str) -> pd.DataFrame:
"""Load and parse the leaderboard table from a CSV file."""
...
def recompute_final_ranking(df: pd.DataFrame) -> pd.DataFrame:
"""Recalculate ordinal rankings after filtering."""
...
def get_arena_table(arena_df: pd.DataFrame, model_table_df: pd.DataFrame) -> pd.DataFrame:
"""Format arena data for dashboard display."""
...
def get_full_table(elo_results: dict, model_table_df: pd.DataFrame) -> pd.DataFrame:
"""Format full leaderboard data for dashboard display."""
...
def update_worker(elo_results_file: str, leaderboard_table_file: str) -> None:
"""Background worker that polls for new data and refreshes rankings."""
...
def load_demo(
elo_results_file: str,
leaderboard_table_file: str,
arena_hard_leaderboard: str = None,
) -> gr.Blocks:
"""Initialize and return the Gradio demo application."""
...
Import
from fastchat.serve.monitor.monitor import build_leaderboard_tab, build_demo
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| elo_results_file | str |
Yes | Path to JSON file containing precomputed Elo results |
| leaderboard_table_file | str |
Yes | Path to CSV file containing leaderboard model metadata |
| arena_hard_leaderboard | str |
No | Path to Arena-Hard leaderboard data for comparison display |
| show_plot | bool |
No | Whether to render matplotlib plots in the dashboard (default: False)
|
| mirror | bool |
No | Whether to serve in mirror mode for alternative endpoints (default: False)
|
| elo_results | dict |
Yes (for tab builders) | Precomputed Elo results dictionary |
| model_table_df | pd.DataFrame |
Yes (for tab builders) | Model metadata DataFrame |
| vision | bool |
No | Whether to show vision-specific leaderboard data (default: False)
|
| categories | list[str] |
Yes (for category tab) | List of category names for the category leaderboard filter |
Outputs
| Name | Type | Description |
|---|---|---|
| demo | gr.Blocks |
Gradio Blocks application object ready to be launched or mounted |
| leaderboard_tab | gr.Blocks |
Individual Gradio tab component for embedding |
| arena_table | pd.DataFrame |
Formatted leaderboard table for display |
Usage Examples
from fastchat.serve.monitor.monitor import build_demo, build_leaderboard_tab
# Launch the full dashboard
demo = build_demo(
elo_results_file="elo_results.json",
leaderboard_table_file="leaderboard_table.csv",
arena_hard_leaderboard="arena_hard_results.json",
)
demo.launch(server_name="0.0.0.0", server_port=7860)
# Or embed just the leaderboard tab in a larger application
import gradio as gr
with gr.Blocks() as app:
gr.Markdown("# My Custom Arena Dashboard")
leaderboard = build_leaderboard_tab(
elo_results_file="elo_results.json",
leaderboard_table_file="leaderboard_table.csv",
show_plot=True,
)
app.launch()
Related Pages
- Principle:Lm_sys_FastChat_Leaderboard_Dashboard_Rendering
- Implements: Principle:Lm_sys_FastChat_Leaderboard_Dashboard_Rendering
- Environment:Lm_sys_FastChat_GPU_CUDA_Inference
- Lm_sys_FastChat_Elo_Analysis - Produces the Elo results consumed by the dashboard
- Lm_sys_FastChat_Rating_Systems - Provides rating computation methods used in leaderboard
- Lm_sys_FastChat_Clean_Battle_Data - Preprocesses data before Elo computation
- Lm_sys_FastChat_Category_Classifier - Enables category-filtered leaderboard views