Skip to content

Commit

Permalink
added visualizer option
Browse files Browse the repository at this point in the history
  • Loading branch information
ygtangg committed Dec 10, 2024
1 parent 251a745 commit 892aaee
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 47 deletions.
43 changes: 0 additions & 43 deletions fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,49 +792,6 @@ def get_model_description_md(models):
return model_description_md


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 = """
## *Price Control Data Visualizations*
Below are scatter-plots depicting a model's arena score against its cost effectiveness
and output token price.
"""
gr.Markdown(price_markdown)


def build_about():
about_markdown = """
Expand Down
58 changes: 54 additions & 4 deletions fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
set_global_vars,
block_css,
build_single_model_ui,
build_visualizer,
build_about,
get_model_list,
load_demo_single,
Expand All @@ -55,6 +54,50 @@
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 = """
## *Price Control Data Visualizations*
Below are scatter-plots depicting a model's arena score against its cost effectiveness
and output token price.
"""
gr.Markdown(price_markdown)


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 @@ -200,9 +243,10 @@ def build_demo(
arena_hard_table,
show_plot=True,
)

with gr.Tab("🔍 Data Visualizer", id=5):
build_visualizer()

if args.show_visualizer:
with gr.Tab("🔍 Data Visualizer", id=5):
build_visualizer()

with gr.Tab("ℹ️ About Us", id=4):
about = build_about()
Expand Down Expand Up @@ -309,6 +353,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

0 comments on commit 892aaee

Please sign in to comment.