Commit
·
d05d9d8
1
Parent(s):
1ef58ee
fix: Bugs related to filtering, change theme, add descriptions
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import pandas as pd
|
|
| 9 |
from pydantic import BaseModel
|
| 10 |
import gradio as gr
|
| 11 |
import requests
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
class Task(BaseModel):
|
|
@@ -179,9 +180,13 @@ def main() -> None:
|
|
| 179 |
for model_id in df.index
|
| 180 |
})
|
| 181 |
|
| 182 |
-
with gr.Blocks() as demo:
|
| 183 |
gr.Markdown("# Radial Plot Generator")
|
| 184 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
with gr.Row():
|
| 186 |
with gr.Column():
|
| 187 |
language_names_dropdown = gr.Dropdown(
|
|
@@ -203,6 +208,10 @@ def main() -> None:
|
|
| 203 |
value=True,
|
| 204 |
interactive=True,
|
| 205 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
with gr.Column():
|
| 207 |
plot = gr.Plot(
|
| 208 |
value=produce_radial_plot(
|
|
@@ -263,17 +272,28 @@ def update_model_ids_dropdown(
|
|
| 263 |
if results_dfs is None or len(language_names) == 0:
|
| 264 |
return gr.update(choices=[], value=[])
|
| 265 |
|
| 266 |
-
|
| 267 |
-
|
| 268 |
for language, df in results_dfs.items()
|
| 269 |
-
for model_id in df.index
|
| 270 |
if language.name in language_names
|
| 271 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
if len(filtered_models) == 0:
|
| 274 |
return gr.update(choices=[], value=[])
|
| 275 |
|
| 276 |
-
return gr.update(choices=filtered_models, value=filtered_models
|
| 277 |
|
| 278 |
|
| 279 |
def produce_radial_plot(
|
|
|
|
| 9 |
from pydantic import BaseModel
|
| 10 |
import gradio as gr
|
| 11 |
import requests
|
| 12 |
+
import random
|
| 13 |
|
| 14 |
|
| 15 |
class Task(BaseModel):
|
|
|
|
| 180 |
for model_id in df.index
|
| 181 |
})
|
| 182 |
|
| 183 |
+
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 184 |
gr.Markdown("# Radial Plot Generator")
|
| 185 |
+
gr.Markdown(
|
| 186 |
+
"This demo allows you to generate a radial plot comparing the performance "
|
| 187 |
+
"of different language models on different tasks. It is based on the "
|
| 188 |
+
"generative results from the [ScandEval benchmark](https://scandeval.com)."
|
| 189 |
+
)
|
| 190 |
with gr.Row():
|
| 191 |
with gr.Column():
|
| 192 |
language_names_dropdown = gr.Dropdown(
|
|
|
|
| 208 |
value=True,
|
| 209 |
interactive=True,
|
| 210 |
)
|
| 211 |
+
gr.Markdown(
|
| 212 |
+
"<center>Produced with ❤️ by the <a href=\"https://alexandra.dk\">"
|
| 213 |
+
"Alexandra Institute</a>.</center>"
|
| 214 |
+
)
|
| 215 |
with gr.Column():
|
| 216 |
plot = gr.Plot(
|
| 217 |
value=produce_radial_plot(
|
|
|
|
| 272 |
if results_dfs is None or len(language_names) == 0:
|
| 273 |
return gr.update(choices=[], value=[])
|
| 274 |
|
| 275 |
+
filtered_results_dfs = {
|
| 276 |
+
language: df
|
| 277 |
for language, df in results_dfs.items()
|
|
|
|
| 278 |
if language.name in language_names
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
unique_models = {
|
| 282 |
+
model_id
|
| 283 |
+
for df in filtered_results_dfs.values()
|
| 284 |
+
for model_id in df.index
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
filtered_models = [
|
| 288 |
+
model_id
|
| 289 |
+
for model_id in unique_models
|
| 290 |
+
if all(model_id in df.index for df in filtered_results_dfs.values())
|
| 291 |
+
]
|
| 292 |
|
| 293 |
if len(filtered_models) == 0:
|
| 294 |
return gr.update(choices=[], value=[])
|
| 295 |
|
| 296 |
+
return gr.update(choices=filtered_models, value=random.sample(filtered_models, k=1))
|
| 297 |
|
| 298 |
|
| 299 |
def produce_radial_plot(
|