David Pomerenke
commited on
Commit
·
d597fe1
1
Parent(s):
175993f
Add scatterplot
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import json
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
|
|
5 |
|
6 |
# Load and process results
|
7 |
with open("results.json") as f:
|
@@ -43,6 +44,37 @@ def create_model_comparison_plot(results):
|
|
43 |
)
|
44 |
return fig
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
def create_results_df(results):
|
47 |
# Create a list to store flattened data
|
48 |
flat_data = []
|
@@ -68,9 +100,11 @@ with gr.Blocks(title="AI Language Translation Benchmark") as demo:
|
|
68 |
gr.Markdown("Comparing translation performance across different AI models and languages")
|
69 |
|
70 |
df = create_results_df(results)
|
71 |
-
|
|
|
72 |
|
73 |
-
gr.DataFrame(value=df, label="Translation Results")
|
74 |
-
gr.Plot(value=
|
|
|
75 |
|
76 |
demo.launch()
|
|
|
2 |
import json
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
5 |
+
from plotly.subplots import make_subplots
|
6 |
|
7 |
# Load and process results
|
8 |
with open("results.json") as f:
|
|
|
44 |
)
|
45 |
return fig
|
46 |
|
47 |
+
def create_scatter_plot(results):
|
48 |
+
fig = go.Figure()
|
49 |
+
|
50 |
+
x_vals = [lang["speakers"] / 1_000_000 for lang in results] # Convert to millions
|
51 |
+
y_vals = [lang["bleu"] for lang in results]
|
52 |
+
labels = [lang["language_name"] for lang in results]
|
53 |
+
|
54 |
+
fig.add_trace(go.Scatter(
|
55 |
+
x=x_vals,
|
56 |
+
y=y_vals,
|
57 |
+
mode='markers+text',
|
58 |
+
text=labels,
|
59 |
+
textposition="top center",
|
60 |
+
hovertemplate="<b>%{text}</b><br>" +
|
61 |
+
"Speakers: %{x:.1f}M<br>" +
|
62 |
+
"BLEU Score: %{y:.3f}<extra></extra>"
|
63 |
+
))
|
64 |
+
|
65 |
+
fig.update_layout(
|
66 |
+
title="Language Coverage: Speakers vs BLEU Score",
|
67 |
+
xaxis_title="Number of Speakers (Millions)",
|
68 |
+
yaxis_title="Average BLEU Score",
|
69 |
+
height=500,
|
70 |
+
showlegend=False
|
71 |
+
)
|
72 |
+
|
73 |
+
# Use log scale for x-axis since speaker numbers vary widely
|
74 |
+
fig.update_xaxes(type="log")
|
75 |
+
|
76 |
+
return fig
|
77 |
+
|
78 |
def create_results_df(results):
|
79 |
# Create a list to store flattened data
|
80 |
flat_data = []
|
|
|
100 |
gr.Markdown("Comparing translation performance across different AI models and languages")
|
101 |
|
102 |
df = create_results_df(results)
|
103 |
+
bar_plot = create_model_comparison_plot(results)
|
104 |
+
scatter_plot = create_scatter_plot(results)
|
105 |
|
106 |
+
gr.DataFrame(value=df, label="Translation Results", show_search="search")
|
107 |
+
gr.Plot(value=bar_plot, label="Model Comparison")
|
108 |
+
gr.Plot(value=scatter_plot, label="Language Coverage")
|
109 |
|
110 |
demo.launch()
|