Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data Explorer Tab #3632

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pickle
import time
from typing import List

import gradio as gr

from fastchat.serve.gradio_block_arena_anony import (
Expand Down Expand Up @@ -54,6 +53,65 @@
logger = build_logger("gradio_web_server_multi", "gradio_web_server_multi.log")


def build_visualizer():
visualizer_markdown = """
# 🔍 Arena Visualizer
Data explorer provides interactive tools to explore and draw insights from our leaderboard data.
"""

gr.Markdown(visualizer_markdown, elem_id="visualizer_markdown")

with gr.Tabs():
with gr.Tab("Topic Explorer", id=0):
topic_markdown = """
## *Welcome to the Topic Explorer*
This tool lets you dive into user-submitted prompts, organized into general
categories and detailed subcategories. Using the sunburst chart, you can easily
explore the data and understand how different topics are distributed.

### How to Use:
- Hover Over Segments: View the category name, the number of prompts, and their percentage.
- Click to Explore:
- Click on a main category to see its subcategories.
- Click on subcategories to see example prompts in the sidebar.
- Undo and Reset: Click the center of the chart to return to the top level.

Start exploring and discover interesting trends in the data!

"""
gr.Markdown(topic_markdown)

frame = """
<iframe width="100%" scrolling="no" style="height: 800px; border: 1px solid lightgrey; border-radius: 10px;"
src="https://storage.googleapis.com/public-arena-no-cors/index.html">
</iframe>
"""
gr.HTML(frame)

with gr.Tab("Price Analysis", id=1):
price_markdown = """
## *Welcome to the Price Explorer*
This scatterplot displays a selection of the arena's models, showing their scores plotted against their cost-effectiveness. Using the plot, you can easily explore the model's price and compare it with their arena score.

### How to Use:
- Hover Over Points: View the model's price, arena score, and organization.
- Click to Explore:
- Double-click a legend point to show only that organization's models on the scatterplot.
- Single-click a legend point to hide that organization's models from the scatterplot.

Start exploring and discover interesting trends in the data!
"""

gr.Markdown(price_markdown)
frame = """
<iframe width="100%" scrolling="no" style="height: 1050px; border: 1px solid lightgrey; border-radius: 10px;"
src="https://storage.googleapis.com/public-arena-no-cors/2024-12-20-figure.html">
</iframe>
"""
gr.HTML(frame)



def load_demo(context: Context, request: gr.Request):
ip = get_ip(request)
logger.info(f"load_demo. ip: {ip}. params: {request.query_params}")
Expand Down Expand Up @@ -199,6 +257,9 @@ def build_demo(
arena_hard_table,
show_plot=True,
)
if args.show_visualizer:
with gr.Tab("🔍 Arena Visualizer", id=5):
build_visualizer()

with gr.Tab("ℹ️ About Us", id=4):
about = build_about()
Expand Down Expand Up @@ -305,6 +366,12 @@ def build_demo(
type=str,
help="Set the password for the gradio web server",
)
parser.add_argument(
"--show-visualizer",
action="store_true",
default=False,
help="Show the Data Visualizer tab",
)
args = parser.parse_args()
logger.info(f"args: {args}")

Expand Down
Loading