Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -1
- .gitignore +13 -0
- .pre-commit-config.yaml +53 -0
- Makefile +13 -0
- README.md +41 -7
- app.py +258 -0
- notes.txt +12 -0
- pyproject.toml +13 -0
- requirements.txt +17 -0
- src/about.py +73 -0
- src/display/css_html_js.py +135 -0
- src/display/formatting.py +29 -0
- src/display/utils.py +138 -0
- src/envs.py +25 -0
- src/leaderboard/read_evals.py +241 -0
- src/populate.py +59 -0
- src/result_samples/speech.json +0 -0
- src/result_samples/text.json +0 -0
- src/submission/check_validity.py +99 -0
- src/submission/submit.py +143 -0
- src/submission_samples/model_name_speech.csv +10 -0
- src/submission_samples/model_name_text.csv +10 -0
.gitattributes
CHANGED
|
@@ -25,7 +25,6 @@
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
@@ -33,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
scale-hf-logo.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
auto_evals/
|
| 2 |
+
venv/
|
| 3 |
+
__pycache__/
|
| 4 |
+
.env
|
| 5 |
+
.ipynb_checkpoints
|
| 6 |
+
*ipynb
|
| 7 |
+
.vscode/
|
| 8 |
+
.idea/
|
| 9 |
+
eval-queue/
|
| 10 |
+
eval-results/
|
| 11 |
+
eval-queue-bk/
|
| 12 |
+
eval-results-bk/
|
| 13 |
+
logs/
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
default_language_version:
|
| 16 |
+
python: python3
|
| 17 |
+
|
| 18 |
+
ci:
|
| 19 |
+
autofix_prs: true
|
| 20 |
+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
|
| 21 |
+
autoupdate_schedule: quarterly
|
| 22 |
+
|
| 23 |
+
repos:
|
| 24 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
| 25 |
+
rev: v4.3.0
|
| 26 |
+
hooks:
|
| 27 |
+
- id: check-yaml
|
| 28 |
+
- id: check-case-conflict
|
| 29 |
+
- id: detect-private-key
|
| 30 |
+
- id: check-added-large-files
|
| 31 |
+
args: ['--maxkb=1000']
|
| 32 |
+
- id: requirements-txt-fixer
|
| 33 |
+
- id: end-of-file-fixer
|
| 34 |
+
- id: trailing-whitespace
|
| 35 |
+
|
| 36 |
+
- repo: https://github.com/PyCQA/isort
|
| 37 |
+
rev: 5.12.0
|
| 38 |
+
hooks:
|
| 39 |
+
- id: isort
|
| 40 |
+
name: Format imports
|
| 41 |
+
|
| 42 |
+
- repo: https://github.com/psf/black
|
| 43 |
+
rev: 22.12.0
|
| 44 |
+
hooks:
|
| 45 |
+
- id: black
|
| 46 |
+
name: Format code
|
| 47 |
+
additional_dependencies: ['click==8.0.2']
|
| 48 |
+
|
| 49 |
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
| 50 |
+
# Ruff version.
|
| 51 |
+
rev: 'v0.0.267'
|
| 52 |
+
hooks:
|
| 53 |
+
- id: ruff
|
Makefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.PHONY: style format
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
style:
|
| 5 |
+
python -m black --line-length 119 .
|
| 6 |
+
python -m isort .
|
| 7 |
+
ruff check --fix .
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
quality:
|
| 11 |
+
python -m black --check --line-length 119 .
|
| 12 |
+
python -m isort --check-only .
|
| 13 |
+
ruff check .
|
README.md
CHANGED
|
@@ -1,12 +1,46 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.49.1
|
| 8 |
app_file: app.py
|
| 9 |
-
pinned:
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: mSTEB Leaderboard
|
| 3 |
+
emoji: 🥇
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: gradio
|
|
|
|
| 7 |
app_file: app.py
|
| 8 |
+
pinned: true
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
short_description: Leaderboard for mSTEB benchmark
|
| 11 |
+
sdk_version: 5.19.0
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Start the configuration
|
| 15 |
+
|
| 16 |
+
Most of the variables to change for a default leaderboard are in `src/env.py` (replace the path for your leaderboard) and `src/about.py` (for tasks).
|
| 17 |
+
|
| 18 |
+
Results files should have the following format and be stored as json files:
|
| 19 |
+
```json
|
| 20 |
+
{
|
| 21 |
+
"config": {
|
| 22 |
+
"model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
|
| 23 |
+
"model_name": "path of the model on the hub: org/model",
|
| 24 |
+
"model_sha": "revision on the hub",
|
| 25 |
+
},
|
| 26 |
+
"results": {
|
| 27 |
+
"task_name": {
|
| 28 |
+
"metric_name": score,
|
| 29 |
+
},
|
| 30 |
+
"task_name2": {
|
| 31 |
+
"metric_name": score,
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Request files are created automatically by this tool.
|
| 38 |
+
|
| 39 |
+
If you encounter problem on the space, don't hesitate to restart it to remove the create eval-queue, eval-queue-bk, eval-results and eval-results-bk created folder.
|
| 40 |
+
|
| 41 |
+
# Code logic for more complex edits
|
| 42 |
+
|
| 43 |
+
You'll find
|
| 44 |
+
- the main table' columns names and properties in `src/display/utils.py`
|
| 45 |
+
- the logic to read all results and request files, then convert them in dataframe lines, in `src/leaderboard/read_evals.py`, and `src/populate.py`
|
| 46 |
+
- the logic to allow or filter submissions in `src/submission/submit.py` and `src/submission/check_validity.py`
|
app.py
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
| 5 |
+
from huggingface_hub import snapshot_download
|
| 6 |
+
|
| 7 |
+
from src.about import (
|
| 8 |
+
CITATION_BUTTON_LABEL,
|
| 9 |
+
CITATION_BUTTON_TEXT,
|
| 10 |
+
EVALUATION_QUEUE_TEXT,
|
| 11 |
+
INTRODUCTION_TEXT,
|
| 12 |
+
LLM_BENCHMARKS_TEXT,
|
| 13 |
+
TITLE,
|
| 14 |
+
)
|
| 15 |
+
from src.display.css_html_js import custom_css
|
| 16 |
+
from src.display.utils import (
|
| 17 |
+
BENCHMARK_COLS,
|
| 18 |
+
SPEECH_BENCHMARK_COLS,
|
| 19 |
+
COLS,
|
| 20 |
+
COLS_SPEECH,
|
| 21 |
+
EVAL_COLS,
|
| 22 |
+
EVAL_TYPES,
|
| 23 |
+
AutoEvalColumn,
|
| 24 |
+
AutoEvalColumnSpeech,
|
| 25 |
+
ModelType,
|
| 26 |
+
fields,
|
| 27 |
+
WeightType,
|
| 28 |
+
Precision, REGION_MAP
|
| 29 |
+
)
|
| 30 |
+
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
| 31 |
+
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 32 |
+
from src.submission.submit import handle_csv_submission
|
| 33 |
+
|
| 34 |
+
text_sample_path = "src/submission_samples/model_name_text.csv"
|
| 35 |
+
speech_sample_path = "src/submission_samples/model_name_speech.csv"
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def restart_space():
|
| 39 |
+
API.restart_space(repo_id=REPO_ID)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
### Space initialisation
|
| 43 |
+
try:
|
| 44 |
+
print(EVAL_REQUESTS_PATH)
|
| 45 |
+
snapshot_download(
|
| 46 |
+
repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30,
|
| 47 |
+
token=TOKEN
|
| 48 |
+
)
|
| 49 |
+
except Exception:
|
| 50 |
+
restart_space()
|
| 51 |
+
try:
|
| 52 |
+
print(EVAL_RESULTS_PATH)
|
| 53 |
+
snapshot_download(
|
| 54 |
+
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30,
|
| 55 |
+
token=TOKEN
|
| 56 |
+
)
|
| 57 |
+
except Exception:
|
| 58 |
+
restart_space()
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
(
|
| 62 |
+
finished_eval_queue_df,
|
| 63 |
+
running_eval_queue_df,
|
| 64 |
+
pending_eval_queue_df,
|
| 65 |
+
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def init_leaderboard(dataframe, result_type='text'):
|
| 69 |
+
if dataframe is None or dataframe.empty:
|
| 70 |
+
raise ValueError("Leaderboard DataFrame is empty or None.")
|
| 71 |
+
column_class = AutoEvalColumn if result_type == "text" else AutoEvalColumnSpeech
|
| 72 |
+
|
| 73 |
+
return Leaderboard(
|
| 74 |
+
value=dataframe,
|
| 75 |
+
datatype=[c.type for c in fields(column_class)],
|
| 76 |
+
select_columns=SelectColumns(
|
| 77 |
+
default_selection=[c.name for c in fields(column_class) if c.displayed_by_default],
|
| 78 |
+
cant_deselect=[c.name for c in fields(column_class) if c.never_hidden],
|
| 79 |
+
label="Select Columns to Display:",
|
| 80 |
+
),
|
| 81 |
+
# search_columns=[AutoEvalColumn.model.name, AutoEvalColumn.license.name],
|
| 82 |
+
search_columns=[column_class.model.name],
|
| 83 |
+
hide_columns=[c.name for c in fields(column_class) if c.hidden],
|
| 84 |
+
filter_columns=[
|
| 85 |
+
# ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
| 86 |
+
# ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
|
| 87 |
+
# ColumnFilter(
|
| 88 |
+
# AutoEvalColumn.params.name,
|
| 89 |
+
# type="slider",
|
| 90 |
+
# min=0.01,
|
| 91 |
+
# max=150,
|
| 92 |
+
# label="Select the number of parameters (B)",
|
| 93 |
+
# ),
|
| 94 |
+
# ColumnFilter(
|
| 95 |
+
# AutoEvalColumn.still_on_hub.name, type="boolean", label="Deleted/incomplete", default=True
|
| 96 |
+
# ),
|
| 97 |
+
],
|
| 98 |
+
bool_checkboxgroup_label="Hide models",
|
| 99 |
+
interactive=False,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
leaderboard_dataframes = {
|
| 104 |
+
region: get_leaderboard_df(
|
| 105 |
+
EVAL_RESULTS_PATH,
|
| 106 |
+
EVAL_REQUESTS_PATH,
|
| 107 |
+
COLS,
|
| 108 |
+
BENCHMARK_COLS,
|
| 109 |
+
region if region != "All" else None,
|
| 110 |
+
result_type="text"
|
| 111 |
+
)
|
| 112 |
+
for region in REGION_MAP.values()
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
leaderboard_dataframes_speech = {
|
| 116 |
+
region: get_leaderboard_df(
|
| 117 |
+
EVAL_RESULTS_PATH,
|
| 118 |
+
EVAL_REQUESTS_PATH,
|
| 119 |
+
COLS_SPEECH,
|
| 120 |
+
SPEECH_BENCHMARK_COLS,
|
| 121 |
+
region if region != "All" else None,
|
| 122 |
+
result_type="speech"
|
| 123 |
+
)
|
| 124 |
+
for region in REGION_MAP.values()
|
| 125 |
+
}
|
| 126 |
+
# Preload leaderboard blocks
|
| 127 |
+
js_switch_code = """
|
| 128 |
+
(displayRegion) => {
|
| 129 |
+
const regionMap = {
|
| 130 |
+
"All": "All",
|
| 131 |
+
"Africa": "Africa",
|
| 132 |
+
"Americas/Oceania": "Americas_Oceania",
|
| 133 |
+
"Asia (S)": "Asia_S",
|
| 134 |
+
"Asia (SE)": "Asia_SE",
|
| 135 |
+
"Asia (W, C)": "Asia_W_C",
|
| 136 |
+
"Asia (E)": "Asia_E",
|
| 137 |
+
"Europe (W, N, S)": "Europe_W_N_S",
|
| 138 |
+
"Europe (E)": "Europe_E"
|
| 139 |
+
};
|
| 140 |
+
const region = regionMap[displayRegion];
|
| 141 |
+
document.querySelectorAll('[id^="leaderboard-"]').forEach(el => el.classList.remove("visible"));
|
| 142 |
+
const target = document.getElementById("leaderboard-" + region);
|
| 143 |
+
if (target) {
|
| 144 |
+
target.classList.add("visible");
|
| 145 |
+
// 🧠 Trigger reflow to fix row cutoff
|
| 146 |
+
void target.offsetHeight; // Trigger reflow
|
| 147 |
+
target.style.display = "none"; // Hide momentarily
|
| 148 |
+
requestAnimationFrame(() => {
|
| 149 |
+
target.style.display = "";
|
| 150 |
+
});
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
demo = gr.Blocks(css=custom_css)
|
| 156 |
+
with demo:
|
| 157 |
+
gr.HTML(TITLE)
|
| 158 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
| 159 |
+
|
| 160 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
| 161 |
+
with gr.TabItem("🏅 mSTEB Text Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
| 162 |
+
with gr.Row():
|
| 163 |
+
region_dropdown = gr.Dropdown(
|
| 164 |
+
choices=list(REGION_MAP.keys()),
|
| 165 |
+
label="Select Region",
|
| 166 |
+
value="All",
|
| 167 |
+
interactive=True,
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
# Region-specific leaderboard containers
|
| 171 |
+
for display_name, region_key in REGION_MAP.items():
|
| 172 |
+
with gr.Column(
|
| 173 |
+
elem_id=f"leaderboard-{region_key}",
|
| 174 |
+
elem_classes=["visible"] if region_key == "All" else []
|
| 175 |
+
):
|
| 176 |
+
init_leaderboard(leaderboard_dataframes[region_key], result_type="text")
|
| 177 |
+
|
| 178 |
+
# JS hook to toggle visible leaderboard
|
| 179 |
+
region_dropdown.change(None, js=js_switch_code, inputs=[region_dropdown])
|
| 180 |
+
|
| 181 |
+
with gr.TabItem("🗣️ mSTEB Speech Benchmark", elem_id="speech-benchmark-tab-table", id=1):
|
| 182 |
+
with gr.Row():
|
| 183 |
+
speech_region_dropdown = gr.Dropdown(
|
| 184 |
+
choices=list(REGION_MAP.keys()),
|
| 185 |
+
label="Select Region",
|
| 186 |
+
value="All",
|
| 187 |
+
interactive=True,
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
for display_name, region_key in REGION_MAP.items():
|
| 191 |
+
with gr.Column(
|
| 192 |
+
elem_id=f"speech-leaderboard-{region_key}",
|
| 193 |
+
elem_classes=["visible"] if region_key == "All" else []
|
| 194 |
+
):
|
| 195 |
+
init_leaderboard(leaderboard_dataframes_speech[region_key], result_type='speech')
|
| 196 |
+
|
| 197 |
+
speech_region_dropdown.change(
|
| 198 |
+
None,
|
| 199 |
+
js=js_switch_code.replace("leaderboard-", "speech-leaderboard-"),
|
| 200 |
+
inputs=[speech_region_dropdown]
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 204 |
+
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
| 205 |
+
|
| 206 |
+
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
| 207 |
+
with gr.Column():
|
| 208 |
+
with gr.Row():
|
| 209 |
+
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
| 210 |
+
|
| 211 |
+
with gr.Row():
|
| 212 |
+
gr.File(
|
| 213 |
+
label="📄 Sample Text CSV",
|
| 214 |
+
value=text_sample_path,
|
| 215 |
+
interactive=False,
|
| 216 |
+
file_types=[".csv"]
|
| 217 |
+
)
|
| 218 |
+
gr.File(
|
| 219 |
+
label="📄 Sample Speech CSV",
|
| 220 |
+
value=speech_sample_path,
|
| 221 |
+
interactive=False,
|
| 222 |
+
file_types=[".csv"]
|
| 223 |
+
)
|
| 224 |
+
with gr.Row():
|
| 225 |
+
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
| 226 |
+
|
| 227 |
+
with gr.Column():
|
| 228 |
+
model_name_textbox = gr.Textbox(label="Model name")
|
| 229 |
+
result_type = gr.Radio(choices=["text", "speech"], label="Result Type", value="text")
|
| 230 |
+
csv_file = gr.File(label="Upload CSV File", file_types=[".csv"])
|
| 231 |
+
|
| 232 |
+
submit_button = gr.Button("Submit Eval")
|
| 233 |
+
submission_result = gr.Markdown()
|
| 234 |
+
|
| 235 |
+
submit_button.click(
|
| 236 |
+
handle_csv_submission,
|
| 237 |
+
[
|
| 238 |
+
model_name_textbox,
|
| 239 |
+
csv_file,
|
| 240 |
+
result_type,
|
| 241 |
+
],
|
| 242 |
+
submission_result,
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
+
with gr.Row():
|
| 246 |
+
with gr.Accordion("📙 Citation", open=False):
|
| 247 |
+
citation_button = gr.Textbox(
|
| 248 |
+
value=CITATION_BUTTON_TEXT,
|
| 249 |
+
label=CITATION_BUTTON_LABEL,
|
| 250 |
+
lines=20,
|
| 251 |
+
elem_id="citation-button",
|
| 252 |
+
show_copy_button=True,
|
| 253 |
+
)
|
| 254 |
+
|
| 255 |
+
scheduler = BackgroundScheduler()
|
| 256 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
| 257 |
+
scheduler.start()
|
| 258 |
+
demo.queue(default_concurrency_limit=40).launch()
|
notes.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The submission flow for the project is as follows:
|
| 2 |
+
|
| 3 |
+
When a csv is submitted, we store the csv in the msteb requests dataset in the folder that's appropriate
|
| 4 |
+
based on text or speech results.
|
| 5 |
+
|
| 6 |
+
Then this csv result is in the same flow converted into a json file and uploaded to results dataset.
|
| 7 |
+
|
| 8 |
+
This helps the leaderboard parse those results and display it.
|
| 9 |
+
|
| 10 |
+
There are validation checks for the csv being formatted correctly and that at least one result value is present.
|
| 11 |
+
|
| 12 |
+
|
pyproject.toml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.ruff]
|
| 2 |
+
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
|
| 3 |
+
select = ["E", "F"]
|
| 4 |
+
ignore = ["E501"] # line too long (black is taking care of this)
|
| 5 |
+
line-length = 119
|
| 6 |
+
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
|
| 7 |
+
|
| 8 |
+
[tool.isort]
|
| 9 |
+
profile = "black"
|
| 10 |
+
line_length = 119
|
| 11 |
+
|
| 12 |
+
[tool.black]
|
| 13 |
+
line-length = 119
|
requirements.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
APScheduler
|
| 2 |
+
black
|
| 3 |
+
datasets
|
| 4 |
+
gradio
|
| 5 |
+
gradio[oauth]
|
| 6 |
+
gradio_leaderboard==0.0.13
|
| 7 |
+
gradio_client
|
| 8 |
+
huggingface-hub>=0.18.0
|
| 9 |
+
matplotlib
|
| 10 |
+
numpy
|
| 11 |
+
pandas
|
| 12 |
+
python-dateutil
|
| 13 |
+
tqdm
|
| 14 |
+
transformers
|
| 15 |
+
tokenizers>=0.15.0
|
| 16 |
+
sentencepiece
|
| 17 |
+
pydantic==2.10.6
|
src/about.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
from enum import Enum
|
| 3 |
+
|
| 4 |
+
@dataclass
|
| 5 |
+
class Task:
|
| 6 |
+
benchmark: str
|
| 7 |
+
metric: str
|
| 8 |
+
col_name: str
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# Select your tasks here
|
| 12 |
+
# ---------------------------------------------------
|
| 13 |
+
class Tasks(Enum):
|
| 14 |
+
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
| 15 |
+
task0 = Task("lid", "acc", "LID")
|
| 16 |
+
task1 = Task("topic_classification", "acc", "TC")
|
| 17 |
+
task2 = Task("rc_qa", "acc", "RC-QA")
|
| 18 |
+
task3 = Task("nli", "acc", "NLI")
|
| 19 |
+
task4 = Task("machine_translation_xx_eng", "chrf", "MT (xx-en)")
|
| 20 |
+
task5 = Task("machine_translation_eng_xx", "chrf", "MT (en-xx)")
|
| 21 |
+
|
| 22 |
+
class SpeechTasks(Enum):
|
| 23 |
+
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
| 24 |
+
task0 = Task("lid", "acc", "LID")
|
| 25 |
+
task1 = Task("topic_classification", "acc", "TC")
|
| 26 |
+
task2 = Task("rc_qa", "acc", "RC-QA")
|
| 27 |
+
task3 = Task("asr", "cer", "ASR")
|
| 28 |
+
task4 = Task("s2tt_xx_eng", "chrf", "S2TT (xx-en)")
|
| 29 |
+
#task5 = Task("s2tt_eng_xx", "chrf", "S2TT (en-xx)")
|
| 30 |
+
|
| 31 |
+
NUM_FEWSHOT = 0 # Change with your few shot
|
| 32 |
+
# ---------------------------------------------------
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
# Your leaderboard name
|
| 37 |
+
TITLE = """<h1 align="center" id="space-title">mSTEB Leaderboard</h1>"""
|
| 38 |
+
|
| 39 |
+
# What does your leaderboard evaluate?
|
| 40 |
+
INTRODUCTION_TEXT = """
|
| 41 |
+
This leaderboard has the results of evaluation of models on mSTEB benchmark.
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
# Which evaluations are you running? how can people reproduce what you have?
|
| 45 |
+
LLM_BENCHMARKS_TEXT = f"""
|
| 46 |
+
## Reproducibility
|
| 47 |
+
To reproduce our results please look at the github page for mSTEB:
|
| 48 |
+
|
| 49 |
+
https://github.com/McGill-NLP/mSTEB
|
| 50 |
+
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
EVALUATION_QUEUE_TEXT = """
|
| 54 |
+
## Submit your results
|
| 55 |
+
Please provide the model name, csv file and select the appropriate result type to upload your evaluation results for mSTEB.
|
| 56 |
+
|
| 57 |
+
Kindly format the results in the same way as provided in the sample csv files below.
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
| 61 |
+
CITATION_BUTTON_TEXT = r"""
|
| 62 |
+
@misc{beyene2025mstebmassivelymultilingualevaluation,
|
| 63 |
+
title = {mSTEB: Massively Multilingual Evaluation of LLMs on Speech and Text Tasks},
|
| 64 |
+
author = {Luel Hagos Beyene and Vivek Verma and Min Ma and Jesujoba O. Alabi
|
| 65 |
+
and Fabian David Schmidt and Joyce Nakatumba-Nabende and
|
| 66 |
+
David Ifeoluwa Adelani},
|
| 67 |
+
year = {2025},
|
| 68 |
+
eprint = {2506.08400},
|
| 69 |
+
archivePrefix = {arXiv},
|
| 70 |
+
primaryClass = {cs.CL},
|
| 71 |
+
url = {https://arxiv.org/abs/2506.08400}
|
| 72 |
+
}
|
| 73 |
+
"""
|
src/display/css_html_js.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
custom_css = """
|
| 2 |
+
|
| 3 |
+
.markdown-text {
|
| 4 |
+
font-size: 16px !important;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
#models-to-add-text {
|
| 8 |
+
font-size: 18px !important;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
#citation-button span {
|
| 12 |
+
font-size: 16px !important;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
#citation-button textarea {
|
| 16 |
+
font-size: 16px !important;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
#citation-button > label > button {
|
| 20 |
+
margin: 6px;
|
| 21 |
+
transform: scale(1.3);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
#leaderboard-table {
|
| 25 |
+
margin-top: 15px
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
#leaderboard-table-lite {
|
| 29 |
+
margin-top: 15px
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
#search-bar-table-box > div:first-child {
|
| 33 |
+
background: none;
|
| 34 |
+
border: none;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
#search-bar {
|
| 38 |
+
padding: 0px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Limit the width of the first AutoEvalColumn so that names don't expand too much */
|
| 42 |
+
#leaderboard-table td:nth-child(2),
|
| 43 |
+
#leaderboard-table th:nth-child(2) {
|
| 44 |
+
max-width: 400px;
|
| 45 |
+
overflow: auto;
|
| 46 |
+
white-space: nowrap;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.tab-buttons button {
|
| 50 |
+
font-size: 20px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
#scale-logo {
|
| 54 |
+
border-style: none !important;
|
| 55 |
+
box-shadow: none;
|
| 56 |
+
display: block;
|
| 57 |
+
margin-left: auto;
|
| 58 |
+
margin-right: auto;
|
| 59 |
+
max-width: 600px;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
#scale-logo .download {
|
| 63 |
+
display: none;
|
| 64 |
+
}
|
| 65 |
+
#filter_type{
|
| 66 |
+
border: 0;
|
| 67 |
+
padding-left: 0;
|
| 68 |
+
padding-top: 0;
|
| 69 |
+
}
|
| 70 |
+
#filter_type label {
|
| 71 |
+
display: flex;
|
| 72 |
+
}
|
| 73 |
+
#filter_type label > span{
|
| 74 |
+
margin-top: var(--spacing-lg);
|
| 75 |
+
margin-right: 0.5em;
|
| 76 |
+
}
|
| 77 |
+
#filter_type label > .wrap{
|
| 78 |
+
width: 103px;
|
| 79 |
+
}
|
| 80 |
+
#filter_type label > .wrap .wrap-inner{
|
| 81 |
+
padding: 2px;
|
| 82 |
+
}
|
| 83 |
+
#filter_type label > .wrap .wrap-inner input{
|
| 84 |
+
width: 1px
|
| 85 |
+
}
|
| 86 |
+
#filter-columns-type{
|
| 87 |
+
border:0;
|
| 88 |
+
padding:0.5;
|
| 89 |
+
}
|
| 90 |
+
#filter-columns-size{
|
| 91 |
+
border:0;
|
| 92 |
+
padding:0.5;
|
| 93 |
+
}
|
| 94 |
+
#box-filter > .form{
|
| 95 |
+
border: 0
|
| 96 |
+
}
|
| 97 |
+
[id^="leaderboard-"] {
|
| 98 |
+
display: none;
|
| 99 |
+
}
|
| 100 |
+
#leaderboard-All.visible,
|
| 101 |
+
#leaderboard-Africa.visible,
|
| 102 |
+
#leaderboard-Americas_Oceania.visible,
|
| 103 |
+
#leaderboard-Asia_S.visible,
|
| 104 |
+
#leaderboard-Asia_SE.visible,
|
| 105 |
+
#leaderboard-Asia_W_C.visible,
|
| 106 |
+
#leaderboard-Asia_E.visible,
|
| 107 |
+
#leaderboard-Europe_W_N_S.visible,
|
| 108 |
+
#leaderboard-Europe_E.visible {
|
| 109 |
+
display: block;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
[id^="speech-leaderboard-"] {
|
| 114 |
+
display: none;
|
| 115 |
+
}
|
| 116 |
+
#speech-leaderboard-All.visible,
|
| 117 |
+
#speech-leaderboard-Africa.visible,
|
| 118 |
+
#speech-leaderboard-Americas_Oceania.visible,
|
| 119 |
+
#speech-leaderboard-Asia_S.visible,
|
| 120 |
+
#speech-leaderboard-Asia_SE.visible,
|
| 121 |
+
#speech-leaderboard-Asia_W_C.visible,
|
| 122 |
+
#speech-leaderboard-Asia_E.visible,
|
| 123 |
+
#speech-leaderboard-Europe_W_N_S.visible,
|
| 124 |
+
#speech-leaderboard-Europe_E.visible {
|
| 125 |
+
display: block;
|
| 126 |
+
}
|
| 127 |
+
"""
|
| 128 |
+
|
| 129 |
+
get_window_url_params = """
|
| 130 |
+
function(url_params) {
|
| 131 |
+
const params = new URLSearchParams(window.location.search);
|
| 132 |
+
url_params = Object.fromEntries(params);
|
| 133 |
+
return url_params;
|
| 134 |
+
}
|
| 135 |
+
"""
|
src/display/formatting.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def model_hyperlink(link, model_name):
|
| 2 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def make_clickable_model(model_name):
|
| 6 |
+
link = f"https://huggingface.co/{model_name}"
|
| 7 |
+
return model_hyperlink(link, model_name)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def styled_error(error):
|
| 11 |
+
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def styled_warning(warn):
|
| 15 |
+
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def styled_message(message):
|
| 19 |
+
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def has_no_nan_values(df, columns):
|
| 23 |
+
return df[columns].notna().all(axis=1)
|
| 24 |
+
|
| 25 |
+
def has_at_least_one_benchmark(df, columns):
|
| 26 |
+
return df[columns].notna().any(axis=1)
|
| 27 |
+
|
| 28 |
+
def has_nan_values(df, columns):
|
| 29 |
+
return df[columns].isna().any(axis=1)
|
src/display/utils.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass, make_dataclass
|
| 2 |
+
from enum import Enum
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
from src.about import Tasks
|
| 7 |
+
from src.about import SpeechTasks
|
| 8 |
+
|
| 9 |
+
def fields(raw_class):
|
| 10 |
+
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# These classes are for user facing column names,
|
| 14 |
+
# to avoid having to change them all around the code
|
| 15 |
+
# when a modif is needed
|
| 16 |
+
@dataclass
|
| 17 |
+
class ColumnContent:
|
| 18 |
+
name: str
|
| 19 |
+
type: str
|
| 20 |
+
displayed_by_default: bool
|
| 21 |
+
hidden: bool = False
|
| 22 |
+
never_hidden: bool = False
|
| 23 |
+
|
| 24 |
+
## Leaderboard columns
|
| 25 |
+
auto_eval_column_dict = []
|
| 26 |
+
# Init
|
| 27 |
+
# auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("Model Type", "str", True, never_hidden=True)])
|
| 28 |
+
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
| 29 |
+
#Scores
|
| 30 |
+
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️ (Class. Tasks)", "number", True)])
|
| 31 |
+
for task in Tasks:
|
| 32 |
+
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
| 33 |
+
|
| 34 |
+
### Speech leaderboard columns
|
| 35 |
+
auto_eval_column_dict_speech = []
|
| 36 |
+
# Init
|
| 37 |
+
# auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("Model Type", "str", True, never_hidden=True)])
|
| 38 |
+
auto_eval_column_dict_speech.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
| 39 |
+
#Scores
|
| 40 |
+
auto_eval_column_dict_speech.append(["average", ColumnContent, ColumnContent("Average ⬆️ (Class. Tasks)", "number", True)])
|
| 41 |
+
for task in SpeechTasks:
|
| 42 |
+
auto_eval_column_dict_speech.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# Model information
|
| 46 |
+
# auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
| 47 |
+
# auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
| 48 |
+
# auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
| 49 |
+
# auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
| 50 |
+
# auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
| 51 |
+
# auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
| 52 |
+
# auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
| 53 |
+
# auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
| 54 |
+
# auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
| 55 |
+
|
| 56 |
+
# We use make dataclass to dynamically fill the scores from Tasks
|
| 57 |
+
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
| 58 |
+
AutoEvalColumnSpeech = make_dataclass("AutoEvalColumnSpeech", auto_eval_column_dict_speech, frozen=True)
|
| 59 |
+
|
| 60 |
+
## For the queue columns in the submission tab
|
| 61 |
+
@dataclass(frozen=True)
|
| 62 |
+
class EvalQueueColumn: # Queue column
|
| 63 |
+
model = ColumnContent("model", "markdown", True)
|
| 64 |
+
revision = ColumnContent("revision", "str", True)
|
| 65 |
+
private = ColumnContent("private", "bool", True)
|
| 66 |
+
precision = ColumnContent("precision", "str", True)
|
| 67 |
+
weight_type = ColumnContent("weight_type", "str", "Original")
|
| 68 |
+
status = ColumnContent("status", "str", True)
|
| 69 |
+
|
| 70 |
+
## All the model information that we might need
|
| 71 |
+
@dataclass
|
| 72 |
+
class ModelDetails:
|
| 73 |
+
name: str
|
| 74 |
+
display_name: str = ""
|
| 75 |
+
symbol: str = "" # emoji
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class ModelType(Enum):
|
| 79 |
+
PT = ModelDetails(name="pretrained", symbol="🟢")
|
| 80 |
+
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
| 81 |
+
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
| 82 |
+
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
| 83 |
+
Unknown = ModelDetails(name="", symbol="?")
|
| 84 |
+
|
| 85 |
+
def to_str(self, separator=" "):
|
| 86 |
+
return f"{self.value.symbol}{separator}{self.value.name}"
|
| 87 |
+
|
| 88 |
+
@staticmethod
|
| 89 |
+
def from_str(type):
|
| 90 |
+
if "fine-tuned" in type or "🔶" in type:
|
| 91 |
+
return ModelType.FT
|
| 92 |
+
if "pretrained" in type or "🟢" in type:
|
| 93 |
+
return ModelType.PT
|
| 94 |
+
if "RL-tuned" in type or "🟦" in type:
|
| 95 |
+
return ModelType.RL
|
| 96 |
+
if "instruction-tuned" in type or "⭕" in type:
|
| 97 |
+
return ModelType.IFT
|
| 98 |
+
return ModelType.Unknown
|
| 99 |
+
|
| 100 |
+
class WeightType(Enum):
|
| 101 |
+
Adapter = ModelDetails("Adapter")
|
| 102 |
+
Original = ModelDetails("Original")
|
| 103 |
+
Delta = ModelDetails("Delta")
|
| 104 |
+
|
| 105 |
+
class Precision(Enum):
|
| 106 |
+
float16 = ModelDetails("float16")
|
| 107 |
+
bfloat16 = ModelDetails("bfloat16")
|
| 108 |
+
Unknown = ModelDetails("?")
|
| 109 |
+
|
| 110 |
+
def from_str(precision):
|
| 111 |
+
if precision in ["torch.float16", "float16"]:
|
| 112 |
+
return Precision.float16
|
| 113 |
+
if precision in ["torch.bfloat16", "bfloat16"]:
|
| 114 |
+
return Precision.bfloat16
|
| 115 |
+
return Precision.Unknown
|
| 116 |
+
|
| 117 |
+
# Column selection
|
| 118 |
+
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
| 119 |
+
COLS_SPEECH = [c.name for c in fields(AutoEvalColumnSpeech) if not c.hidden]
|
| 120 |
+
|
| 121 |
+
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
| 122 |
+
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
| 123 |
+
|
| 124 |
+
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
| 125 |
+
SPEECH_BENCHMARK_COLS = [t.value.col_name for t in SpeechTasks]
|
| 126 |
+
|
| 127 |
+
REGION_MAP = {
|
| 128 |
+
"All": "All",
|
| 129 |
+
"Africa": "Africa",
|
| 130 |
+
"Americas/Oceania": "Americas_Oceania",
|
| 131 |
+
"Asia (S)": "Asia_S",
|
| 132 |
+
"Asia (SE)": "Asia_SE",
|
| 133 |
+
"Asia (W, C)": "Asia_W_C",
|
| 134 |
+
"Asia (E)": "Asia_E",
|
| 135 |
+
"Europe (W, N, S)": "Europe_W_N_S",
|
| 136 |
+
"Europe (E)": "Europe_E",
|
| 137 |
+
}
|
| 138 |
+
|
src/envs.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from huggingface_hub import HfApi
|
| 4 |
+
|
| 5 |
+
# Info to change for your repository
|
| 6 |
+
# ----------------------------------
|
| 7 |
+
TOKEN = os.environ.get("HF_TOKEN") # A read/write token for your org
|
| 8 |
+
|
| 9 |
+
OWNER = "McGill-NLP" # Change to your org - don't forget to create a results and request dataset, with the correct format!
|
| 10 |
+
# ----------------------------------
|
| 11 |
+
|
| 12 |
+
REPO_ID = f"{OWNER}/msteb_leaderboard"
|
| 13 |
+
QUEUE_REPO = f"{OWNER}/msteb_requests"
|
| 14 |
+
RESULTS_REPO = f"{OWNER}/msteb_results"
|
| 15 |
+
|
| 16 |
+
# If you setup a cache later, just change HF_HOME
|
| 17 |
+
CACHE_PATH=os.getenv("HF_HOME", ".")
|
| 18 |
+
|
| 19 |
+
# Local caches
|
| 20 |
+
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
| 21 |
+
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
| 22 |
+
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
|
| 23 |
+
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
|
| 24 |
+
|
| 25 |
+
API = HfApi(token=TOKEN)
|
src/leaderboard/read_evals.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import glob
|
| 2 |
+
import json
|
| 3 |
+
import math
|
| 4 |
+
import os
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
|
| 7 |
+
import dateutil
|
| 8 |
+
import numpy as np
|
| 9 |
+
|
| 10 |
+
from src.display.formatting import make_clickable_model
|
| 11 |
+
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType, SpeechTasks
|
| 12 |
+
from src.submission.check_validity import is_model_on_hub
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@dataclass
|
| 16 |
+
class EvalResult:
|
| 17 |
+
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
| 18 |
+
"""
|
| 19 |
+
eval_name: str # org_model_precision (uid)
|
| 20 |
+
full_model: str # org/model (path on hub)
|
| 21 |
+
org: str
|
| 22 |
+
model: str
|
| 23 |
+
revision: str # commit hash, "" if main
|
| 24 |
+
results: dict
|
| 25 |
+
precision: Precision = Precision.Unknown
|
| 26 |
+
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
| 27 |
+
weight_type: WeightType = WeightType.Original # Original or Adapter
|
| 28 |
+
architecture: str = "Unknown"
|
| 29 |
+
license: str = "?"
|
| 30 |
+
likes: int = 0
|
| 31 |
+
num_params: int = 0
|
| 32 |
+
date: str = "" # submission date of request file
|
| 33 |
+
still_on_hub: bool = False
|
| 34 |
+
regions: dict = None
|
| 35 |
+
|
| 36 |
+
@classmethod
|
| 37 |
+
def init_from_json_file(self, json_filepath, result_type='speech'):
|
| 38 |
+
"""Inits the result from the specific model result file"""
|
| 39 |
+
with open(json_filepath) as fp:
|
| 40 |
+
data = json.load(fp)
|
| 41 |
+
|
| 42 |
+
config = data.get("config")
|
| 43 |
+
regions = data.get("regions", {}) # Parse regions from JSON
|
| 44 |
+
|
| 45 |
+
# Precision
|
| 46 |
+
precision = Precision.from_str(config.get("model_dtype"))
|
| 47 |
+
|
| 48 |
+
# Get model and org
|
| 49 |
+
org_and_model = config.get("model_name", config.get("model_args", None))
|
| 50 |
+
org_and_model = org_and_model.split("/", 1)
|
| 51 |
+
|
| 52 |
+
if len(org_and_model) == 1:
|
| 53 |
+
org = None
|
| 54 |
+
model = org_and_model[0]
|
| 55 |
+
result_key = f"{model}_{precision.value.name}"
|
| 56 |
+
else:
|
| 57 |
+
org = org_and_model[0]
|
| 58 |
+
model = org_and_model[1]
|
| 59 |
+
result_key = f"{org}_{model}_{precision.value.name}"
|
| 60 |
+
full_model = "/".join(org_and_model)
|
| 61 |
+
|
| 62 |
+
still_on_hub, _, model_config = is_model_on_hub(
|
| 63 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
| 64 |
+
)
|
| 65 |
+
architecture = "?"
|
| 66 |
+
if model_config is not None:
|
| 67 |
+
architectures = getattr(model_config, "architectures", None)
|
| 68 |
+
if architectures:
|
| 69 |
+
architecture = ";".join(architectures)
|
| 70 |
+
|
| 71 |
+
# Extract results available in this file (some results are split in several files)
|
| 72 |
+
results = {}
|
| 73 |
+
|
| 74 |
+
task_enum = Tasks if result_type == "text" else SpeechTasks
|
| 75 |
+
|
| 76 |
+
for task in task_enum:
|
| 77 |
+
task = task.value
|
| 78 |
+
|
| 79 |
+
# We average all scores of a given metric (not all metrics are present in all files)
|
| 80 |
+
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
| 81 |
+
if accs.size == 0 or any([acc is None for acc in accs]):
|
| 82 |
+
continue
|
| 83 |
+
|
| 84 |
+
mean_acc = np.mean(accs) * 100.0
|
| 85 |
+
results[task.benchmark] = mean_acc
|
| 86 |
+
|
| 87 |
+
regions_processed_results = {}
|
| 88 |
+
for region, region_results in regions.items():
|
| 89 |
+
processed = {}
|
| 90 |
+
for task in task_enum:
|
| 91 |
+
task = task.value
|
| 92 |
+
|
| 93 |
+
# We average all scores of a given metric (not all metrics are present in all files)
|
| 94 |
+
accs = np.array([v.get(task.metric, None) for k, v in region_results.items() if task.benchmark == k])
|
| 95 |
+
if accs.size == 0 or any([acc is None for acc in accs]):
|
| 96 |
+
continue
|
| 97 |
+
|
| 98 |
+
mean_acc = np.mean(accs) * 100.0
|
| 99 |
+
processed[task.benchmark] = mean_acc
|
| 100 |
+
regions_processed_results[region] = processed
|
| 101 |
+
return self(
|
| 102 |
+
eval_name=result_key,
|
| 103 |
+
full_model=full_model,
|
| 104 |
+
org=org,
|
| 105 |
+
model=model,
|
| 106 |
+
results=results,
|
| 107 |
+
precision=precision,
|
| 108 |
+
revision= config.get("model_sha", ""),
|
| 109 |
+
still_on_hub=still_on_hub,
|
| 110 |
+
architecture=architecture,
|
| 111 |
+
regions=regions_processed_results
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
def update_with_request_file(self, requests_path):
|
| 115 |
+
"""Finds the relevant request file for the current model and updates info with it"""
|
| 116 |
+
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
| 117 |
+
|
| 118 |
+
try:
|
| 119 |
+
with open(request_file, "r") as f:
|
| 120 |
+
request = json.load(f)
|
| 121 |
+
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
| 122 |
+
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
| 123 |
+
self.license = request.get("license", "?")
|
| 124 |
+
self.likes = request.get("likes", 0)
|
| 125 |
+
self.num_params = request.get("params", 0)
|
| 126 |
+
self.date = request.get("submitted_time", "")
|
| 127 |
+
except Exception:
|
| 128 |
+
print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
|
| 129 |
+
|
| 130 |
+
def to_dict(self, region=None, result_type='text'):
|
| 131 |
+
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
| 132 |
+
# print(self.results)
|
| 133 |
+
task_enum = Tasks if result_type == "text" else SpeechTasks
|
| 134 |
+
|
| 135 |
+
results = self.results if region is None else self.regions.get(region, {})
|
| 136 |
+
acc_values = [
|
| 137 |
+
results[task.value.benchmark]
|
| 138 |
+
for task in task_enum
|
| 139 |
+
if task.value.metric == "acc" and task.value.benchmark in results
|
| 140 |
+
]
|
| 141 |
+
# print(acc_values)
|
| 142 |
+
|
| 143 |
+
average = sum(acc_values) / len(acc_values) if acc_values else None
|
| 144 |
+
|
| 145 |
+
# average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
| 146 |
+
data_dict = {
|
| 147 |
+
"eval_name": self.eval_name, # not a column, just a save name,
|
| 148 |
+
# AutoEvalColumn.precision.name: self.precision.value.name,
|
| 149 |
+
# AutoEvalColumn.model_type.name: self.model_type.value.name,
|
| 150 |
+
# # AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
| 151 |
+
# AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
| 152 |
+
# AutoEvalColumn.architecture.name: self.architecture,
|
| 153 |
+
AutoEvalColumn.model.name: self.full_model,
|
| 154 |
+
# AutoEvalColumn.revision.name: self.revision,
|
| 155 |
+
AutoEvalColumn.average.name: average,
|
| 156 |
+
# AutoEvalColumn.license.name: self.license,
|
| 157 |
+
# AutoEvalColumn.likes.name: self.likes,
|
| 158 |
+
# AutoEvalColumn.params.name: self.num_params,
|
| 159 |
+
# AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
for task in task_enum:
|
| 163 |
+
if task.value.benchmark in results:
|
| 164 |
+
data_dict[task.value.col_name] = results[task.value.benchmark]
|
| 165 |
+
else:
|
| 166 |
+
data_dict[task.value.col_name] = None # or np.nan if preferred
|
| 167 |
+
|
| 168 |
+
return data_dict
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def get_request_file_for_model(requests_path, model_name, precision):
|
| 172 |
+
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
| 173 |
+
request_files = os.path.join(
|
| 174 |
+
requests_path,
|
| 175 |
+
f"{model_name}_eval_request_*.json",
|
| 176 |
+
)
|
| 177 |
+
request_files = glob.glob(request_files)
|
| 178 |
+
|
| 179 |
+
# Select correct request file (precision)
|
| 180 |
+
request_file = ""
|
| 181 |
+
request_files = sorted(request_files, reverse=True)
|
| 182 |
+
for tmp_request_file in request_files:
|
| 183 |
+
with open(tmp_request_file, "r") as f:
|
| 184 |
+
req_content = json.load(f)
|
| 185 |
+
if (
|
| 186 |
+
req_content["status"] in ["FINISHED"]
|
| 187 |
+
and req_content["precision"] == precision.split(".")[-1]
|
| 188 |
+
):
|
| 189 |
+
request_file = tmp_request_file
|
| 190 |
+
return request_file
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def get_raw_eval_results(results_path: str, requests_path: str, result_type: str = "text") -> list[EvalResult]:
|
| 194 |
+
"""From the path of the results folder root, extract all needed info for results"""
|
| 195 |
+
# result type
|
| 196 |
+
model_result_filepaths = []
|
| 197 |
+
|
| 198 |
+
for root, _, files in os.walk(results_path):
|
| 199 |
+
# We should only have json files in model results
|
| 200 |
+
if result_type == "text" and "msteb_text_results" not in root:
|
| 201 |
+
continue
|
| 202 |
+
if result_type == "speech" and "msteb_speech_results" not in root:
|
| 203 |
+
continue
|
| 204 |
+
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
| 205 |
+
continue
|
| 206 |
+
|
| 207 |
+
# Sort the files by date
|
| 208 |
+
try:
|
| 209 |
+
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
| 210 |
+
except dateutil.parser._parser.ParserError:
|
| 211 |
+
files = [files[-1]]
|
| 212 |
+
|
| 213 |
+
for file in files:
|
| 214 |
+
model_result_filepaths.append(os.path.join(root, file))
|
| 215 |
+
|
| 216 |
+
eval_results = {}
|
| 217 |
+
for model_result_filepath in model_result_filepaths:
|
| 218 |
+
# Creation of result
|
| 219 |
+
eval_result = EvalResult.init_from_json_file(model_result_filepath,result_type)
|
| 220 |
+
# print('testing this one')
|
| 221 |
+
# print(eval_result)
|
| 222 |
+
eval_result.update_with_request_file(requests_path)
|
| 223 |
+
|
| 224 |
+
# Store results of same eval together
|
| 225 |
+
eval_name = eval_result.eval_name
|
| 226 |
+
if eval_name in eval_results.keys():
|
| 227 |
+
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
| 228 |
+
else:
|
| 229 |
+
eval_results[eval_name] = eval_result
|
| 230 |
+
|
| 231 |
+
results = []
|
| 232 |
+
for v in eval_results.values():
|
| 233 |
+
try:
|
| 234 |
+
v.to_dict() # we test if the dict version is complete
|
| 235 |
+
results.append(v)
|
| 236 |
+
except KeyError: # not all eval values present
|
| 237 |
+
continue
|
| 238 |
+
# print('results')
|
| 239 |
+
# print(results)
|
| 240 |
+
|
| 241 |
+
return results
|
src/populate.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
from src.display.formatting import has_no_nan_values, make_clickable_model, has_at_least_one_benchmark
|
| 7 |
+
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
| 8 |
+
from src.leaderboard.read_evals import get_raw_eval_results
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list, region=None, result_type="text") -> pd.DataFrame:
|
| 12 |
+
"""Creates a dataframe from all the individual experiment results"""
|
| 13 |
+
raw_data = get_raw_eval_results(results_path, requests_path, result_type=result_type)
|
| 14 |
+
# this here if region is none gets main results. I have to pass region value here to get region based results
|
| 15 |
+
# and they should come.
|
| 16 |
+
all_data_json = [v.to_dict(region, result_type) for v in raw_data]
|
| 17 |
+
# print('all_data_json', all_data_json)
|
| 18 |
+
df = pd.DataFrame.from_records(all_data_json)
|
| 19 |
+
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
| 20 |
+
df = df[cols].round(decimals=2)
|
| 21 |
+
# filter out if any of the benchmarks have not been produced
|
| 22 |
+
df = df[has_at_least_one_benchmark(df, benchmark_cols)]
|
| 23 |
+
return df
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
| 27 |
+
"""Creates the different dataframes for the evaluation queues requestes"""
|
| 28 |
+
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
| 29 |
+
all_evals = []
|
| 30 |
+
|
| 31 |
+
for entry in entries:
|
| 32 |
+
if ".json" in entry:
|
| 33 |
+
file_path = os.path.join(save_path, entry)
|
| 34 |
+
with open(file_path) as fp:
|
| 35 |
+
data = json.load(fp)
|
| 36 |
+
|
| 37 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
| 38 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
| 39 |
+
|
| 40 |
+
all_evals.append(data)
|
| 41 |
+
elif ".md" not in entry:
|
| 42 |
+
# this is a folder
|
| 43 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
|
| 44 |
+
for sub_entry in sub_entries:
|
| 45 |
+
file_path = os.path.join(save_path, entry, sub_entry)
|
| 46 |
+
with open(file_path) as fp:
|
| 47 |
+
data = json.load(fp)
|
| 48 |
+
|
| 49 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
| 50 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
| 51 |
+
all_evals.append(data)
|
| 52 |
+
|
| 53 |
+
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
| 54 |
+
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
| 55 |
+
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
| 56 |
+
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
| 57 |
+
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
| 58 |
+
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
| 59 |
+
return df_finished[cols], df_running[cols], df_pending[cols]
|
src/result_samples/speech.json
ADDED
|
File without changes
|
src/result_samples/text.json
ADDED
|
File without changes
|
src/submission/check_validity.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import re
|
| 4 |
+
from collections import defaultdict
|
| 5 |
+
from datetime import datetime, timedelta, timezone
|
| 6 |
+
|
| 7 |
+
import huggingface_hub
|
| 8 |
+
from huggingface_hub import ModelCard
|
| 9 |
+
from huggingface_hub.hf_api import ModelInfo
|
| 10 |
+
from transformers import AutoConfig
|
| 11 |
+
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
| 12 |
+
|
| 13 |
+
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
| 14 |
+
"""Checks if the model card and license exist and have been filled"""
|
| 15 |
+
try:
|
| 16 |
+
card = ModelCard.load(repo_id)
|
| 17 |
+
except huggingface_hub.utils.EntryNotFoundError:
|
| 18 |
+
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
| 19 |
+
|
| 20 |
+
# Enforce license metadata
|
| 21 |
+
if card.data.license is None:
|
| 22 |
+
if not ("license_name" in card.data and "license_link" in card.data):
|
| 23 |
+
return False, (
|
| 24 |
+
"License not found. Please add a license to your model card using the `license` metadata or a"
|
| 25 |
+
" `license_name`/`license_link` pair."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Enforce card content
|
| 29 |
+
if len(card.text) < 200:
|
| 30 |
+
return False, "Please add a description to your model card, it is too short."
|
| 31 |
+
|
| 32 |
+
return True, ""
|
| 33 |
+
|
| 34 |
+
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
| 35 |
+
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
| 36 |
+
try:
|
| 37 |
+
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
| 38 |
+
if test_tokenizer:
|
| 39 |
+
try:
|
| 40 |
+
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
| 41 |
+
except ValueError as e:
|
| 42 |
+
return (
|
| 43 |
+
False,
|
| 44 |
+
f"uses a tokenizer which is not in a transformers release: {e}",
|
| 45 |
+
None
|
| 46 |
+
)
|
| 47 |
+
except Exception as e:
|
| 48 |
+
return (False, "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?", None)
|
| 49 |
+
return True, None, config
|
| 50 |
+
|
| 51 |
+
except ValueError:
|
| 52 |
+
return (
|
| 53 |
+
False,
|
| 54 |
+
"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",
|
| 55 |
+
None
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
except Exception as e:
|
| 59 |
+
return False, "was not found on hub!", None
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def get_model_size(model_info: ModelInfo, precision: str):
|
| 63 |
+
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
| 64 |
+
try:
|
| 65 |
+
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
| 66 |
+
except (AttributeError, TypeError):
|
| 67 |
+
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
| 68 |
+
|
| 69 |
+
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
| 70 |
+
model_size = size_factor * model_size
|
| 71 |
+
return model_size
|
| 72 |
+
|
| 73 |
+
def get_model_arch(model_info: ModelInfo):
|
| 74 |
+
"""Gets the model architecture from the configuration"""
|
| 75 |
+
return model_info.config.get("architectures", "Unknown")
|
| 76 |
+
|
| 77 |
+
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
| 78 |
+
"""Gather a list of already submitted models to avoid duplicates"""
|
| 79 |
+
depth = 1
|
| 80 |
+
file_names = []
|
| 81 |
+
users_to_submission_dates = defaultdict(list)
|
| 82 |
+
|
| 83 |
+
for root, _, files in os.walk(requested_models_dir):
|
| 84 |
+
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
|
| 85 |
+
if current_depth == depth:
|
| 86 |
+
for file in files:
|
| 87 |
+
if not file.endswith(".json"):
|
| 88 |
+
continue
|
| 89 |
+
with open(os.path.join(root, file), "r") as f:
|
| 90 |
+
info = json.load(f)
|
| 91 |
+
file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
|
| 92 |
+
|
| 93 |
+
# Select organisation
|
| 94 |
+
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
| 95 |
+
continue
|
| 96 |
+
organisation, _ = info["model"].split("/")
|
| 97 |
+
users_to_submission_dates[organisation].append(info["submitted_time"])
|
| 98 |
+
|
| 99 |
+
return set(file_names), users_to_submission_dates
|
src/submission/submit.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from datetime import datetime, timezone
|
| 5 |
+
|
| 6 |
+
from src.about import Tasks, SpeechTasks
|
| 7 |
+
from src.display.formatting import styled_error, styled_message, styled_warning
|
| 8 |
+
from src.display.utils import REGION_MAP
|
| 9 |
+
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO, RESULTS_REPO, EVAL_RESULTS_PATH
|
| 10 |
+
|
| 11 |
+
REQUESTED_MODELS = None
|
| 12 |
+
USERS_TO_SUBMISSION_DATES = None
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def handle_csv_submission(
|
| 16 |
+
model_name: str,
|
| 17 |
+
csv_file, # uploaded file path
|
| 18 |
+
result_type: str,
|
| 19 |
+
):
|
| 20 |
+
if model_name == "" or model_name is None:
|
| 21 |
+
return styled_error("Please provide a model name.")
|
| 22 |
+
if csv_file is None:
|
| 23 |
+
return styled_error("Please provide a CSV file with results.")
|
| 24 |
+
|
| 25 |
+
df = pd.read_csv(csv_file)
|
| 26 |
+
|
| 27 |
+
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
| 28 |
+
|
| 29 |
+
# Save uploaded CSV
|
| 30 |
+
subdir = os.path.join(EVAL_REQUESTS_PATH, result_type)
|
| 31 |
+
os.makedirs(subdir, exist_ok=True)
|
| 32 |
+
|
| 33 |
+
filename = f"{current_time}_{model_name}_{result_type}_results.csv"
|
| 34 |
+
remote_path = f"msteb_{result_type}_requests/{filename}"
|
| 35 |
+
|
| 36 |
+
csv_save_path = os.path.join(subdir,filename)
|
| 37 |
+
df.to_csv(csv_save_path, index=False)
|
| 38 |
+
|
| 39 |
+
print(f"Uploading to {QUEUE_REPO}/{remote_path}")
|
| 40 |
+
API.upload_file(
|
| 41 |
+
path_or_fileobj=csv_save_path,
|
| 42 |
+
path_in_repo=remote_path,
|
| 43 |
+
repo_id=QUEUE_REPO,
|
| 44 |
+
repo_type="dataset", # or "model" if you made the repo that way
|
| 45 |
+
commit_message=f"Add {result_type} request for {model_name} at {current_time}",
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Remove the local file
|
| 49 |
+
os.remove(csv_save_path)
|
| 50 |
+
# this converts dataframe to json and uploads it to results
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
try:
|
| 54 |
+
convert_csv_to_json_and_upload(df, model_name, result_type)
|
| 55 |
+
except ValueError as e:
|
| 56 |
+
return styled_error(f"{str(e)}")
|
| 57 |
+
return styled_message(f"Results CSV successfully submitted for `{model_name}`!")
|
| 58 |
+
|
| 59 |
+
def find_task_by_col_name(col_name, enum_cls):
|
| 60 |
+
for task in enum_cls:
|
| 61 |
+
if task.value.col_name == col_name:
|
| 62 |
+
return task
|
| 63 |
+
return None
|
| 64 |
+
def convert_csv_to_json_and_upload(df: pd.DataFrame, model_name: str, result_type: str):
|
| 65 |
+
task_enum = Tasks if result_type == "text" else SpeechTasks
|
| 66 |
+
|
| 67 |
+
task_display_names = {t.value.col_name for t in task_enum}
|
| 68 |
+
region_names = df["Region"].tolist()
|
| 69 |
+
average_row = "Average (Micro)"
|
| 70 |
+
|
| 71 |
+
# --- Validation ---
|
| 72 |
+
df_columns = set(df.columns[1:]) # exclude Region column
|
| 73 |
+
if not df_columns.issubset(task_display_names):
|
| 74 |
+
extra = df_columns - task_display_names
|
| 75 |
+
raise ValueError(f"Extra columns in CSV: {extra}")
|
| 76 |
+
if average_row not in df["Region"].values:
|
| 77 |
+
raise ValueError("Missing row for 'Average (Micro)'")
|
| 78 |
+
|
| 79 |
+
data_region_names = [r for r in region_names if r != average_row]
|
| 80 |
+
|
| 81 |
+
for region in data_region_names:
|
| 82 |
+
if region not in REGION_MAP:
|
| 83 |
+
raise ValueError(f"Region '{region}' not found in REGION_MAP keys.")
|
| 84 |
+
|
| 85 |
+
# --- Build JSON ---
|
| 86 |
+
# I go over the regions in the CSV and create a JSON object.
|
| 87 |
+
model_json = {
|
| 88 |
+
"config": {"model_name": model_name},
|
| 89 |
+
"results": {},
|
| 90 |
+
"regions": {},
|
| 91 |
+
}
|
| 92 |
+
at_least_one_number = False
|
| 93 |
+
|
| 94 |
+
for _, row in df.iterrows():
|
| 95 |
+
region_display = row["Region"]
|
| 96 |
+
|
| 97 |
+
if region_display == average_row:
|
| 98 |
+
for col, val in row.items():
|
| 99 |
+
if col == "Region":
|
| 100 |
+
continue
|
| 101 |
+
task = find_task_by_col_name(col, task_enum)
|
| 102 |
+
if val is not None and not pd.isna(val) and isinstance(val, (int, float)):
|
| 103 |
+
print(f" value {val}")
|
| 104 |
+
at_least_one_number = True
|
| 105 |
+
model_json["results"][task.value.benchmark] = {task.value.metric: val/100}
|
| 106 |
+
else:
|
| 107 |
+
model_json["regions"][REGION_MAP[region_display]] = {}
|
| 108 |
+
for col, val in row.items():
|
| 109 |
+
if col == "Region":
|
| 110 |
+
continue
|
| 111 |
+
task = find_task_by_col_name(col, task_enum)
|
| 112 |
+
if val is not None and not pd.isna(val) and isinstance(val, (int, float)):
|
| 113 |
+
model_json["regions"][REGION_MAP[region_display]][task.value.benchmark] = {task.value.metric: val/100}
|
| 114 |
+
|
| 115 |
+
# Check if at least one number is present in the results
|
| 116 |
+
print(at_least_one_number)
|
| 117 |
+
if at_least_one_number is False:
|
| 118 |
+
raise ValueError("No valid numeric results found in the CSV. Please check your input.")
|
| 119 |
+
|
| 120 |
+
# --- Save locally ---
|
| 121 |
+
subdir = os.path.join(EVAL_RESULTS_PATH, result_type)
|
| 122 |
+
os.makedirs(subdir, exist_ok=True)
|
| 123 |
+
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
| 124 |
+
filename = f"{current_time}_{model_name}_{result_type}.json"
|
| 125 |
+
json_save_path = os.path.join(subdir,filename)
|
| 126 |
+
|
| 127 |
+
with open(json_save_path, "w") as f:
|
| 128 |
+
json.dump(model_json, f, indent=2)
|
| 129 |
+
|
| 130 |
+
# --- Upload to HF Hub ---
|
| 131 |
+
remote_path = f"msteb_leaderboard/msteb_{result_type}_results/{filename}"
|
| 132 |
+
API.upload_file(
|
| 133 |
+
path_or_fileobj=json_save_path,
|
| 134 |
+
path_in_repo=remote_path,
|
| 135 |
+
repo_id=RESULTS_REPO,
|
| 136 |
+
repo_type="dataset",
|
| 137 |
+
commit_message=f"Upload results for {model_name} ({result_type}) at {current_time}",
|
| 138 |
+
)
|
| 139 |
+
os.remove(json_save_path)
|
| 140 |
+
|
| 141 |
+
print(f"Uploaded to {RESULTS_REPO}/{current_time}")
|
| 142 |
+
|
| 143 |
+
return f"Uploaded to {RESULTS_REPO}/{current_time}"
|
src/submission_samples/model_name_speech.csv
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Region,LID,TC,RC-QA,ASR,S2TT (xx-en),S2TT (en-xx)
|
| 2 |
+
Africa,,,,,
|
| 3 |
+
Americas/Oceania,,,,,
|
| 4 |
+
Asia (S),,,,,
|
| 5 |
+
Asia (SE),,,,,
|
| 6 |
+
"Asia (W, C)",,,,,
|
| 7 |
+
Asia (E),,,,,
|
| 8 |
+
"Europe (W, N, S)",,,,,
|
| 9 |
+
Europe (E),,,,,
|
| 10 |
+
Average (Micro),,,,,
|
src/submission_samples/model_name_text.csv
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Region,LID,TC,RC-QA,NLI,MT (xx-en),MT (en-xx)
|
| 2 |
+
Africa,,,,,,
|
| 3 |
+
Americas/Oceania,,,,,,
|
| 4 |
+
Asia (S),,,,,,
|
| 5 |
+
Asia (SE),,,,,,
|
| 6 |
+
"Asia (W, C)",,,,,,
|
| 7 |
+
Asia (E),,,,,,
|
| 8 |
+
"Europe (W, N, S)",,,,,,
|
| 9 |
+
Europe (E),,,,,,
|
| 10 |
+
Average (Micro),,,,,,
|