Spaces:
Running
Running
yuhangzang
commited on
Commit
·
7100ab3
1
Parent(s):
d8f5b82
Init the leaderboard
Browse files- .gitignore +212 -0
- Makefile +13 -0
- README.md +41 -8
- app.py +85 -0
- leaderboard_data.json +94 -0
- pyproject.toml +13 -0
- requirements.txt +16 -0
- src/about.py +103 -0
- src/display/css_html_js.py +270 -0
- src/display/formatting.py +27 -0
- src/display/utils.py +110 -0
- src/envs.py +25 -0
- src/json_leaderboard.py +76 -0
- src/leaderboard/read_evals.py +196 -0
- src/populate.py +117 -0
- src/submission/check_validity.py +99 -0
- src/submission/submit.py +119 -0
.gitignore
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.DS_Store
|
2 |
+
|
3 |
+
# Byte-compiled / optimized / DLL files
|
4 |
+
__pycache__/
|
5 |
+
*.py[codz]
|
6 |
+
*$py.class
|
7 |
+
|
8 |
+
# C extensions
|
9 |
+
*.so
|
10 |
+
|
11 |
+
# Distribution / packaging
|
12 |
+
.Python
|
13 |
+
build/
|
14 |
+
develop-eggs/
|
15 |
+
dist/
|
16 |
+
downloads/
|
17 |
+
eggs/
|
18 |
+
.eggs/
|
19 |
+
lib/
|
20 |
+
lib64/
|
21 |
+
parts/
|
22 |
+
sdist/
|
23 |
+
var/
|
24 |
+
wheels/
|
25 |
+
share/python-wheels/
|
26 |
+
*.egg-info/
|
27 |
+
.installed.cfg
|
28 |
+
*.egg
|
29 |
+
MANIFEST
|
30 |
+
|
31 |
+
# PyInstaller
|
32 |
+
# Usually these files are written by a python script from a template
|
33 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
34 |
+
*.manifest
|
35 |
+
*.spec
|
36 |
+
|
37 |
+
# Installer logs
|
38 |
+
pip-log.txt
|
39 |
+
pip-delete-this-directory.txt
|
40 |
+
|
41 |
+
# Unit test / coverage reports
|
42 |
+
htmlcov/
|
43 |
+
.tox/
|
44 |
+
.nox/
|
45 |
+
.coverage
|
46 |
+
.coverage.*
|
47 |
+
.cache
|
48 |
+
nosetests.xml
|
49 |
+
coverage.xml
|
50 |
+
*.cover
|
51 |
+
*.py.cover
|
52 |
+
.hypothesis/
|
53 |
+
.pytest_cache/
|
54 |
+
cover/
|
55 |
+
|
56 |
+
# Translations
|
57 |
+
*.mo
|
58 |
+
*.pot
|
59 |
+
|
60 |
+
# Django stuff:
|
61 |
+
*.log
|
62 |
+
local_settings.py
|
63 |
+
db.sqlite3
|
64 |
+
db.sqlite3-journal
|
65 |
+
|
66 |
+
# Flask stuff:
|
67 |
+
instance/
|
68 |
+
.webassets-cache
|
69 |
+
|
70 |
+
# Scrapy stuff:
|
71 |
+
.scrapy
|
72 |
+
|
73 |
+
# Sphinx documentation
|
74 |
+
docs/_build/
|
75 |
+
|
76 |
+
# PyBuilder
|
77 |
+
.pybuilder/
|
78 |
+
target/
|
79 |
+
|
80 |
+
# Jupyter Notebook
|
81 |
+
.ipynb_checkpoints
|
82 |
+
|
83 |
+
# IPython
|
84 |
+
profile_default/
|
85 |
+
ipython_config.py
|
86 |
+
|
87 |
+
# pyenv
|
88 |
+
# For a library or package, you might want to ignore these files since the code is
|
89 |
+
# intended to run in multiple environments; otherwise, check them in:
|
90 |
+
# .python-version
|
91 |
+
|
92 |
+
# pipenv
|
93 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
94 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
95 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
96 |
+
# install all needed dependencies.
|
97 |
+
#Pipfile.lock
|
98 |
+
|
99 |
+
# UV
|
100 |
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
101 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
102 |
+
# commonly ignored for libraries.
|
103 |
+
#uv.lock
|
104 |
+
|
105 |
+
# poetry
|
106 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
107 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
108 |
+
# commonly ignored for libraries.
|
109 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
110 |
+
#poetry.lock
|
111 |
+
#poetry.toml
|
112 |
+
|
113 |
+
# pdm
|
114 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
115 |
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
116 |
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
117 |
+
#pdm.lock
|
118 |
+
#pdm.toml
|
119 |
+
.pdm-python
|
120 |
+
.pdm-build/
|
121 |
+
|
122 |
+
# pixi
|
123 |
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
124 |
+
#pixi.lock
|
125 |
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
126 |
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
127 |
+
.pixi
|
128 |
+
|
129 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
130 |
+
__pypackages__/
|
131 |
+
|
132 |
+
# Celery stuff
|
133 |
+
celerybeat-schedule
|
134 |
+
celerybeat.pid
|
135 |
+
|
136 |
+
# SageMath parsed files
|
137 |
+
*.sage.py
|
138 |
+
|
139 |
+
# Environments
|
140 |
+
.env
|
141 |
+
.envrc
|
142 |
+
.venv
|
143 |
+
env/
|
144 |
+
venv/
|
145 |
+
ENV/
|
146 |
+
env.bak/
|
147 |
+
venv.bak/
|
148 |
+
|
149 |
+
# Spyder project settings
|
150 |
+
.spyderproject
|
151 |
+
.spyproject
|
152 |
+
|
153 |
+
# Rope project settings
|
154 |
+
.ropeproject
|
155 |
+
|
156 |
+
# mkdocs documentation
|
157 |
+
/site
|
158 |
+
|
159 |
+
# mypy
|
160 |
+
.mypy_cache/
|
161 |
+
.dmypy.json
|
162 |
+
dmypy.json
|
163 |
+
|
164 |
+
# Pyre type checker
|
165 |
+
.pyre/
|
166 |
+
|
167 |
+
# pytype static type analyzer
|
168 |
+
.pytype/
|
169 |
+
|
170 |
+
# Cython debug symbols
|
171 |
+
cython_debug/
|
172 |
+
|
173 |
+
# PyCharm
|
174 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
175 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
176 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
177 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
178 |
+
#.idea/
|
179 |
+
|
180 |
+
# Abstra
|
181 |
+
# Abstra is an AI-powered process automation framework.
|
182 |
+
# Ignore directories containing user credentials, local state, and settings.
|
183 |
+
# Learn more at https://abstra.io/docs
|
184 |
+
.abstra/
|
185 |
+
|
186 |
+
# Visual Studio Code
|
187 |
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
188 |
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
189 |
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
190 |
+
# you could uncomment the following to ignore the entire vscode folder
|
191 |
+
# .vscode/
|
192 |
+
|
193 |
+
# Ruff stuff:
|
194 |
+
.ruff_cache/
|
195 |
+
|
196 |
+
# PyPI configuration file
|
197 |
+
.pypirc
|
198 |
+
|
199 |
+
# Cursor
|
200 |
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
201 |
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
202 |
+
# refer to https://docs.cursor.com/context/ignore-files
|
203 |
+
.cursorignore
|
204 |
+
.cursorindexingignore
|
205 |
+
|
206 |
+
# Marimo
|
207 |
+
marimo/_static/
|
208 |
+
marimo/_lsp/
|
209 |
+
__marimo__/
|
210 |
+
|
211 |
+
# Streamlit
|
212 |
+
.streamlit/secrets.toml
|
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,13 +1,46 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.35.0
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
-
license:
|
|
|
|
|
11 |
---
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: MMLongBench Doc
|
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: A long-context, multimodal document understanding 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,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
from src.json_leaderboard import create_leaderboard_df, get_leaderboard_stats
|
6 |
+
from src.about import (
|
7 |
+
CITATION_BUTTON_LABEL,
|
8 |
+
CITATION_BUTTON_TEXT,
|
9 |
+
INTRODUCTION_TEXT,
|
10 |
+
LLM_BENCHMARKS_TEXT,
|
11 |
+
LINKS_AND_INFO,
|
12 |
+
TITLE,
|
13 |
+
)
|
14 |
+
from src.display.css_html_js import custom_css
|
15 |
+
|
16 |
+
|
17 |
+
def create_simple_leaderboard():
|
18 |
+
"""Create a simple leaderboard from JSON data"""
|
19 |
+
json_path = Path(__file__).parent / "leaderboard_data.json"
|
20 |
+
df = create_leaderboard_df(str(json_path))
|
21 |
+
|
22 |
+
if df.empty:
|
23 |
+
return gr.Dataframe(value=pd.DataFrame({"Error": ["No data available"]}))
|
24 |
+
|
25 |
+
return gr.Dataframe(
|
26 |
+
value=df,
|
27 |
+
headers=list(df.columns),
|
28 |
+
datatype=["html", "str", "html", "str", "str", "str", "str"],
|
29 |
+
interactive=False,
|
30 |
+
wrap=True
|
31 |
+
)
|
32 |
+
|
33 |
+
|
34 |
+
def get_stats_display():
|
35 |
+
"""Get formatted statistics for display"""
|
36 |
+
json_path = Path(__file__).parent / "leaderboard_data.json"
|
37 |
+
stats = get_leaderboard_stats(str(json_path))
|
38 |
+
|
39 |
+
if not stats:
|
40 |
+
return "No statistics available"
|
41 |
+
|
42 |
+
stats_text = f"""
|
43 |
+
### 📊 Leaderboard Statistics
|
44 |
+
- **Total Models**: {stats['total_models']}
|
45 |
+
- **Best Score**: {stats['max_acc']:.1f}
|
46 |
+
- **Lowest Score**: {stats['min_acc']:.1f}
|
47 |
+
"""
|
48 |
+
|
49 |
+
return stats_text
|
50 |
+
|
51 |
+
|
52 |
+
# Create the Gradio interface
|
53 |
+
demo = gr.Blocks(css=custom_css, title="MMLongBench-Doc Leaderboard")
|
54 |
+
|
55 |
+
with demo:
|
56 |
+
gr.HTML(TITLE)
|
57 |
+
gr.HTML(LINKS_AND_INFO)
|
58 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
59 |
+
|
60 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
61 |
+
with gr.TabItem("🏅 Leaderboard", elem_id="llm-benchmark-tab-table", id=0):
|
62 |
+
# Statistics display
|
63 |
+
stats_display = gr.Markdown(get_stats_display())
|
64 |
+
|
65 |
+
# Leaderboard table
|
66 |
+
leaderboard_table = create_simple_leaderboard()
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
with gr.Row():
|
71 |
+
with gr.Column():
|
72 |
+
gr.Markdown("## 📙 Citation")
|
73 |
+
gr.Markdown("If you use [MMLongBench-Doc](https://arxiv.org/abs/2407.01523) in your research, please cite our work:")
|
74 |
+
citation_textbox = gr.Textbox(
|
75 |
+
value=CITATION_BUTTON_TEXT,
|
76 |
+
elem_id="citation-textbox",
|
77 |
+
show_label=False,
|
78 |
+
interactive=False,
|
79 |
+
lines=8,
|
80 |
+
show_copy_button=True
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
if __name__ == "__main__":
|
85 |
+
demo.launch()
|
leaderboard_data.json
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"leaderboard": [
|
3 |
+
{
|
4 |
+
"model": "GLM-4.1V-Thinking",
|
5 |
+
"link": "https://arxiv.org/pdf/2507.01006",
|
6 |
+
"hf": "https://huggingface.co/THUDM/GLM-4.1V-9B-Thinking",
|
7 |
+
"params": "9B",
|
8 |
+
"open_source": true,
|
9 |
+
"acc": 42.4,
|
10 |
+
"release_date": "2025-07",
|
11 |
+
"moe": false
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"model": "GPT-4.1 2025-04-14 detail high",
|
15 |
+
"link": "https://openai.com/index/gpt-4-1/",
|
16 |
+
"hf": "-",
|
17 |
+
"params": "-",
|
18 |
+
"open_source": false,
|
19 |
+
"acc": 49.7,
|
20 |
+
"release_date": "2025-04",
|
21 |
+
"moe": "-"
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"model": "GPT-4o 2024-11-20 detail high",
|
25 |
+
"link": "https://arxiv.org/abs/2410.21276",
|
26 |
+
"hf": "-",
|
27 |
+
"params": "-",
|
28 |
+
"open_source": false,
|
29 |
+
"acc": 46.3,
|
30 |
+
"release_date": "2024-11",
|
31 |
+
"moe": "-"
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"model": "Kimi-VL-Thinking-2506",
|
35 |
+
"link": "https://arxiv.org/pdf/2504.07491",
|
36 |
+
"hf": "https://huggingface.co/moonshotai/Kimi-VL-A3B-Thinking-2506",
|
37 |
+
"params": "2.8B activated (16B total)",
|
38 |
+
"open_source": true,
|
39 |
+
"acc": 42.1,
|
40 |
+
"release_date": "2025-06",
|
41 |
+
"moe": true
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"model": "Kimi-VL-A3B-Instruct",
|
45 |
+
"link": "https://arxiv.org/pdf/2504.07491",
|
46 |
+
"hf": "https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct",
|
47 |
+
"params": "2.8B activated (16B total)",
|
48 |
+
"open_source": true,
|
49 |
+
"acc": 35.1,
|
50 |
+
"release_date": "2025-04",
|
51 |
+
"moe": true
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"model": "Qwen2.5-VL-72B",
|
55 |
+
"link": "https://arxiv.org/abs/2502.13923",
|
56 |
+
"hf": "https://huggingface.co/Qwen/Qwen2.5-VL-72B-Instruct",
|
57 |
+
"params": "72B",
|
58 |
+
"open_source": true,
|
59 |
+
"acc": 35.2,
|
60 |
+
"release_date": "2025-02",
|
61 |
+
"moe": false
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"model": "Qwen2.5-VL-7B",
|
65 |
+
"link": "https://arxiv.org/abs/2502.13923",
|
66 |
+
"hf": "https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct",
|
67 |
+
"params": "7B",
|
68 |
+
"open_source": true,
|
69 |
+
"acc": 25.1,
|
70 |
+
"release_date": "2025-02",
|
71 |
+
"moe": false
|
72 |
+
},
|
73 |
+
{
|
74 |
+
"model": "MiniMax-VL-01",
|
75 |
+
"link": "https://arxiv.org/pdf/2501.08313",
|
76 |
+
"hf": "https://huggingface.co/MiniMaxAI/MiniMax-VL-01",
|
77 |
+
"params": "45.9B activated (456B total)",
|
78 |
+
"open_source": true,
|
79 |
+
"acc": 32.5,
|
80 |
+
"release_date": "2025-01",
|
81 |
+
"moe": true
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"model": "Aria",
|
85 |
+
"link": "https://arxiv.org/pdf/2410.05993",
|
86 |
+
"hf": "https://huggingface.co/rhymes-ai/Aria",
|
87 |
+
"params": "3.9B activated (25.3B total)",
|
88 |
+
"open_source": true,
|
89 |
+
"acc": 28.3,
|
90 |
+
"release_date": "2024-10",
|
91 |
+
"moe": true
|
92 |
+
}
|
93 |
+
]
|
94 |
+
}
|
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,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
src/about.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# For MMLongBench-Doc (https://arxiv.org/abs/2407.01523), we use ACC as the main metric
|
16 |
+
task0 = Task("mmlongbench_doc", "acc", "ACC")
|
17 |
+
|
18 |
+
NUM_FEWSHOT = 0 # Change with your few shot
|
19 |
+
# ---------------------------------------------------
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
# Your leaderboard name
|
24 |
+
TITLE = """<h1 align="center" id="space-title">🥇 <a href="https://arxiv.org/abs/2407.01523" target="_blank">MMLongBench-Doc</a> Leaderboard</h1>"""
|
25 |
+
|
26 |
+
# Links and conference info
|
27 |
+
LINKS_AND_INFO = """
|
28 |
+
<div align="center">
|
29 |
+
<p><strong>NeurIPS 2024 Datasets and Benchmarks Track (Spotlight)</strong></p>
|
30 |
+
<p>
|
31 |
+
<a href="https://mayubo2333.github.io/MMLongBench-Doc/" target="_blank">🏠 Homepage</a> |
|
32 |
+
<a href="https://arxiv.org/abs/2407.01523" target="_blank">📄 arXiv Paper</a> |
|
33 |
+
<a href="https://huggingface.co/datasets/yubo2333/MMLongBench-Doc" target="_blank">🤗 Dataset</a>
|
34 |
+
</p>
|
35 |
+
</div>
|
36 |
+
"""
|
37 |
+
|
38 |
+
# What does your leaderboard evaluate?
|
39 |
+
INTRODUCTION_TEXT = """
|
40 |
+
📚 [MMLongBench-Doc](https://arxiv.org/abs/2407.01523) is a long-context, multimodal document understanding benchmark designed to evaluate the performance of large multimodal models on complex document understanding tasks.
|
41 |
+
|
42 |
+
📊 This leaderboard tracks the performance of various models on the [MMLongBench-Doc](https://arxiv.org/abs/2407.01523) benchmark, focusing on their ability to understand and process long documents with both text and visual elements.
|
43 |
+
|
44 |
+
🔧 You can use the official [GitHub repo](https://github.com/mayubo2333/MMLongBench-Doc) or [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) to evaluate your model on [MMLongBench-Doc](https://arxiv.org/abs/2407.01523). We provide the [official evaluation results](https://huggingface.co/OpenIXCLab/mmlongbench-doc-results) of GPT-4.1 and GPT-4o.
|
45 |
+
|
46 |
+
📝 To add your own model to the leaderboard, please send an Email to yubo001@e.ntu.edu.sg or zangyuhang@pjlab.org.cn then we will help with the evaluation and updating the leaderboard.
|
47 |
+
"""
|
48 |
+
|
49 |
+
# Which evaluations are you running? how can people reproduce what you have?
|
50 |
+
LLM_BENCHMARKS_TEXT = f"""
|
51 |
+
## How it works
|
52 |
+
|
53 |
+
[MMLongBench-Doc](https://arxiv.org/abs/2407.01523) evaluates multimodal models on their ability to understand long documents containing both text and visual elements. The benchmark includes various document understanding tasks that require models to process and reason over extended contexts.
|
54 |
+
|
55 |
+
## Evaluation Metrics
|
56 |
+
|
57 |
+
- **ACC (Accuracy)**: The primary metric measuring the overall accuracy of model predictions on document understanding tasks.
|
58 |
+
- **Parameters**: Model size in billions of parameters
|
59 |
+
- **Open Source**: Whether the model weights are publicly available
|
60 |
+
|
61 |
+
## Reproducibility
|
62 |
+
|
63 |
+
To reproduce our results, please refer to the official [MMLongBench-Doc](https://arxiv.org/abs/2407.01523) repository for evaluation scripts and detailed instructions.
|
64 |
+
"""
|
65 |
+
|
66 |
+
EVALUATION_QUEUE_TEXT = """
|
67 |
+
## Some good practices before submitting a model
|
68 |
+
|
69 |
+
### 1) Make sure you can load your model and tokenizer using AutoClasses:
|
70 |
+
```python
|
71 |
+
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
72 |
+
config = AutoConfig.from_pretrained("your model name", revision=revision)
|
73 |
+
model = AutoModel.from_pretrained("your model name", revision=revision)
|
74 |
+
tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
|
75 |
+
```
|
76 |
+
If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
|
77 |
+
|
78 |
+
Note: make sure your model is public!
|
79 |
+
Note: if your model needs `use_remote_code=True`, we do not support this option yet but we are working on adding it, stay posted!
|
80 |
+
|
81 |
+
### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
|
82 |
+
It's a new format for storing weights which is safer and faster to load and use. It will also allow us to add the number of parameters of your model to the `Extended Viewer`!
|
83 |
+
|
84 |
+
### 3) Make sure your model has an open license!
|
85 |
+
This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
|
86 |
+
|
87 |
+
### 4) Fill up your model card
|
88 |
+
When we add extra information about models to the leaderboard, it will be automatically taken from the model card
|
89 |
+
|
90 |
+
## In case of model failure
|
91 |
+
If your model is displayed in the `FAILED` category, its execution stopped.
|
92 |
+
Make sure you have followed the above steps first.
|
93 |
+
If everything is done, check you can launch the EleutherAIHarness on your model locally, using the above command without modifications (you can add `--limit` to limit the number of examples per task).
|
94 |
+
"""
|
95 |
+
|
96 |
+
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
97 |
+
CITATION_BUTTON_TEXT = r"""@inproceedings{ma2024mmlongbenchdoc,
|
98 |
+
title={{MMLONGBENCH}-{DOC}: Benchmarking Long-context Document Understanding with Visualizations},
|
99 |
+
author={Yubo Ma and Yuhang Zang and Liangyu Chen and Meiqi Chen and Yizhu Jiao and Xinze Li and Xinyuan Lu and Ziyu Liu and Yan Ma and Xiaoyi Dong and Pan Zhang and Liangming Pan and Yu-Gang Jiang and Jiaqi Wang and Yixin Cao and Aixin Sun},
|
100 |
+
booktitle={NeurIPS Datasets and Benchmarks Track},
|
101 |
+
year={2024},
|
102 |
+
url={https://openreview.net/forum?id=loJM1acwzf}
|
103 |
+
}"""
|
src/display/css_html_js.py
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
custom_css = """
|
2 |
+
|
3 |
+
.markdown-text {
|
4 |
+
font-size: 16px !important;
|
5 |
+
line-height: 1.6 !important;
|
6 |
+
}
|
7 |
+
|
8 |
+
/* Enhanced Leaderboard table styling */
|
9 |
+
.dataframe {
|
10 |
+
background: white !important;
|
11 |
+
border-radius: 12px !important;
|
12 |
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
|
13 |
+
overflow: hidden !important;
|
14 |
+
border: 1px solid #e8ecef !important;
|
15 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
|
16 |
+
}
|
17 |
+
|
18 |
+
.dataframe th {
|
19 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
|
20 |
+
color: #2c3e50 !important;
|
21 |
+
font-weight: 600 !important;
|
22 |
+
font-size: 11px !important;
|
23 |
+
padding: 16px 12px !important;
|
24 |
+
text-align: center !important;
|
25 |
+
border-bottom: 2px solid #dee2e6 !important;
|
26 |
+
letter-spacing: 0.025em !important;
|
27 |
+
text-transform: uppercase !important;
|
28 |
+
}
|
29 |
+
|
30 |
+
/* Override any conflicting styles */
|
31 |
+
.dataframe thead th {
|
32 |
+
font-size: 11px !important;
|
33 |
+
}
|
34 |
+
|
35 |
+
.dataframe th span {
|
36 |
+
font-size: 11px !important;
|
37 |
+
}
|
38 |
+
|
39 |
+
.dataframe td {
|
40 |
+
padding: 14px 12px !important;
|
41 |
+
border-bottom: 1px solid #f0f2f5 !important;
|
42 |
+
text-align: center !important;
|
43 |
+
vertical-align: middle !important;
|
44 |
+
font-size: 15px !important;
|
45 |
+
color: #2c3e50 !important;
|
46 |
+
line-height: 1.4 !important;
|
47 |
+
}
|
48 |
+
|
49 |
+
.dataframe tr:hover td {
|
50 |
+
background-color: #f8f9fa !important;
|
51 |
+
transition: background-color 0.2s ease !important;
|
52 |
+
}
|
53 |
+
|
54 |
+
.dataframe tr:nth-child(even) td {
|
55 |
+
background-color: #fdfdfd !important;
|
56 |
+
}
|
57 |
+
|
58 |
+
/* Enhanced hyperlinks in table */
|
59 |
+
.dataframe a {
|
60 |
+
color: #0066cc !important;
|
61 |
+
text-decoration: underline !important;
|
62 |
+
font-weight: 500 !important;
|
63 |
+
transition: all 0.2s ease !important;
|
64 |
+
border-radius: 4px !important;
|
65 |
+
padding: 2px 6px !important;
|
66 |
+
display: inline-block !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
.dataframe a:hover {
|
70 |
+
color: #004499 !important;
|
71 |
+
background-color: rgba(0, 102, 204, 0.1) !important;
|
72 |
+
text-decoration: underline !important;
|
73 |
+
transform: translateY(-1px) !important;
|
74 |
+
}
|
75 |
+
|
76 |
+
.dataframe a:visited {
|
77 |
+
color: #5a6c7d !important;
|
78 |
+
}
|
79 |
+
|
80 |
+
/* Model name styling (assuming first column contains model names) */
|
81 |
+
.dataframe td:first-child {
|
82 |
+
font-weight: 600 !important;
|
83 |
+
color: #1a202c !important;
|
84 |
+
text-align: left !important;
|
85 |
+
padding-left: 16px !important;
|
86 |
+
}
|
87 |
+
|
88 |
+
/* Score highlighting */
|
89 |
+
.dataframe td:last-child {
|
90 |
+
font-weight: 600 !important;
|
91 |
+
font-size: 16px !important;
|
92 |
+
}
|
93 |
+
|
94 |
+
#models-to-add-text {
|
95 |
+
font-size: 18px !important;
|
96 |
+
}
|
97 |
+
|
98 |
+
#citation-button span {
|
99 |
+
font-size: 16px !important;
|
100 |
+
}
|
101 |
+
|
102 |
+
#citation-button textarea {
|
103 |
+
font-size: 16px !important;
|
104 |
+
}
|
105 |
+
|
106 |
+
#citation-button > label > button {
|
107 |
+
margin: 6px;
|
108 |
+
transform: scale(1.3);
|
109 |
+
}
|
110 |
+
|
111 |
+
/* Citation section styling */
|
112 |
+
#citation-textbox textarea {
|
113 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
|
114 |
+
border: 2px solid #dee2e6 !important;
|
115 |
+
border-radius: 12px !important;
|
116 |
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
|
117 |
+
font-size: 12px !important;
|
118 |
+
padding: 20px !important;
|
119 |
+
line-height: 1.6 !important;
|
120 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
|
121 |
+
}
|
122 |
+
|
123 |
+
#citation-textbox label > button {
|
124 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
125 |
+
border: none !important;
|
126 |
+
border-radius: 8px !important;
|
127 |
+
color: white !important;
|
128 |
+
padding: 8px 16px !important;
|
129 |
+
margin: 8px !important;
|
130 |
+
transform: scale(1.1);
|
131 |
+
transition: transform 0.2s ease;
|
132 |
+
}
|
133 |
+
|
134 |
+
#citation-textbox label > button:hover {
|
135 |
+
transform: scale(1.15) !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#leaderboard-table {
|
139 |
+
margin-top: 25px !important;
|
140 |
+
}
|
141 |
+
|
142 |
+
#leaderboard-table-lite {
|
143 |
+
margin-top: 25px !important;
|
144 |
+
}
|
145 |
+
|
146 |
+
#search-bar-table-box > div:first-child {
|
147 |
+
background: none;
|
148 |
+
border: none;
|
149 |
+
}
|
150 |
+
|
151 |
+
#search-bar {
|
152 |
+
padding: 0px;
|
153 |
+
}
|
154 |
+
|
155 |
+
/* Enhanced table column widths and responsiveness */
|
156 |
+
#leaderboard-table td:nth-child(2),
|
157 |
+
#leaderboard-table th:nth-child(2) {
|
158 |
+
max-width: 400px;
|
159 |
+
overflow: hidden;
|
160 |
+
text-overflow: ellipsis;
|
161 |
+
white-space: nowrap;
|
162 |
+
}
|
163 |
+
|
164 |
+
/* Responsive table improvements */
|
165 |
+
.dataframe {
|
166 |
+
width: 100% !important;
|
167 |
+
margin: 16px 0 !important;
|
168 |
+
}
|
169 |
+
|
170 |
+
/* Better mobile responsiveness */
|
171 |
+
@media (max-width: 768px) {
|
172 |
+
.dataframe th,
|
173 |
+
.dataframe td {
|
174 |
+
padding: 8px 6px !important;
|
175 |
+
font-size: 13px !important;
|
176 |
+
}
|
177 |
+
|
178 |
+
.dataframe th {
|
179 |
+
font-size: 12px !important;
|
180 |
+
}
|
181 |
+
|
182 |
+
#leaderboard-table td:nth-child(2),
|
183 |
+
#leaderboard-table th:nth-child(2) {
|
184 |
+
max-width: 200px;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/* Rank column special styling */
|
189 |
+
.dataframe td:nth-child(1) {
|
190 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
191 |
+
color: white !important;
|
192 |
+
font-weight: 700 !important;
|
193 |
+
font-size: 16px !important;
|
194 |
+
border-radius: 8px !important;
|
195 |
+
margin: 4px !important;
|
196 |
+
min-width: 40px !important;
|
197 |
+
}
|
198 |
+
|
199 |
+
.dataframe tr:nth-child(1) td:nth-child(1) {
|
200 |
+
background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%) !important;
|
201 |
+
color: #8b4513 !important;
|
202 |
+
}
|
203 |
+
|
204 |
+
.dataframe tr:nth-child(2) td:nth-child(1) {
|
205 |
+
background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%) !important;
|
206 |
+
color: #4a4a4a !important;
|
207 |
+
}
|
208 |
+
|
209 |
+
.dataframe tr:nth-child(3) td:nth-child(1) {
|
210 |
+
background: linear-gradient(135deg, #cd7f32 0%, #daa520 100%) !important;
|
211 |
+
color: white !important;
|
212 |
+
}
|
213 |
+
|
214 |
+
.tab-buttons button {
|
215 |
+
font-size: 20px;
|
216 |
+
}
|
217 |
+
|
218 |
+
#scale-logo {
|
219 |
+
border-style: none !important;
|
220 |
+
box-shadow: none;
|
221 |
+
display: block;
|
222 |
+
margin-left: auto;
|
223 |
+
margin-right: auto;
|
224 |
+
max-width: 600px;
|
225 |
+
}
|
226 |
+
|
227 |
+
#scale-logo .download {
|
228 |
+
display: none;
|
229 |
+
}
|
230 |
+
#filter_type{
|
231 |
+
border: 0;
|
232 |
+
padding-left: 0;
|
233 |
+
padding-top: 0;
|
234 |
+
}
|
235 |
+
#filter_type label {
|
236 |
+
display: flex;
|
237 |
+
}
|
238 |
+
#filter_type label > span{
|
239 |
+
margin-top: var(--spacing-lg);
|
240 |
+
margin-right: 0.5em;
|
241 |
+
}
|
242 |
+
#filter_type label > .wrap{
|
243 |
+
width: 103px;
|
244 |
+
}
|
245 |
+
#filter_type label > .wrap .wrap-inner{
|
246 |
+
padding: 2px;
|
247 |
+
}
|
248 |
+
#filter_type label > .wrap .wrap-inner input{
|
249 |
+
width: 1px
|
250 |
+
}
|
251 |
+
#filter-columns-type{
|
252 |
+
border:0;
|
253 |
+
padding:0.5;
|
254 |
+
}
|
255 |
+
#filter-columns-size{
|
256 |
+
border:0;
|
257 |
+
padding:0.5;
|
258 |
+
}
|
259 |
+
#box-filter > .form{
|
260 |
+
border: 0
|
261 |
+
}
|
262 |
+
"""
|
263 |
+
|
264 |
+
get_window_url_params = """
|
265 |
+
function(url_params) {
|
266 |
+
const params = new URLSearchParams(window.location.search);
|
267 |
+
url_params = Object.fromEntries(params);
|
268 |
+
return url_params;
|
269 |
+
}
|
270 |
+
"""
|
src/display/formatting.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
26 |
+
def has_nan_values(df, columns):
|
27 |
+
return df[columns].isna().any(axis=1)
|
src/display/utils.py
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
8 |
+
def fields(raw_class):
|
9 |
+
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
10 |
+
|
11 |
+
|
12 |
+
# These classes are for user facing column names,
|
13 |
+
# to avoid having to change them all around the code
|
14 |
+
# when a modif is needed
|
15 |
+
@dataclass
|
16 |
+
class ColumnContent:
|
17 |
+
name: str
|
18 |
+
type: str
|
19 |
+
displayed_by_default: bool
|
20 |
+
hidden: bool = False
|
21 |
+
never_hidden: bool = False
|
22 |
+
|
23 |
+
## Leaderboard columns
|
24 |
+
auto_eval_column_dict = []
|
25 |
+
# Init
|
26 |
+
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
27 |
+
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
28 |
+
#Scores
|
29 |
+
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
30 |
+
for task in Tasks:
|
31 |
+
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
32 |
+
# Model information
|
33 |
+
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
34 |
+
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
35 |
+
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
36 |
+
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
37 |
+
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
38 |
+
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
39 |
+
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
40 |
+
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
41 |
+
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
42 |
+
|
43 |
+
# We use make dataclass to dynamically fill the scores from Tasks
|
44 |
+
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
45 |
+
|
46 |
+
## For the queue columns in the submission tab
|
47 |
+
@dataclass(frozen=True)
|
48 |
+
class EvalQueueColumn: # Queue column
|
49 |
+
model = ColumnContent("model", "markdown", True)
|
50 |
+
revision = ColumnContent("revision", "str", True)
|
51 |
+
private = ColumnContent("private", "bool", True)
|
52 |
+
precision = ColumnContent("precision", "str", True)
|
53 |
+
weight_type = ColumnContent("weight_type", "str", "Original")
|
54 |
+
status = ColumnContent("status", "str", True)
|
55 |
+
|
56 |
+
## All the model information that we might need
|
57 |
+
@dataclass
|
58 |
+
class ModelDetails:
|
59 |
+
name: str
|
60 |
+
display_name: str = ""
|
61 |
+
symbol: str = "" # emoji
|
62 |
+
|
63 |
+
|
64 |
+
class ModelType(Enum):
|
65 |
+
PT = ModelDetails(name="pretrained", symbol="🟢")
|
66 |
+
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
67 |
+
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
68 |
+
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
69 |
+
Unknown = ModelDetails(name="", symbol="?")
|
70 |
+
|
71 |
+
def to_str(self, separator=" "):
|
72 |
+
return f"{self.value.symbol}{separator}{self.value.name}"
|
73 |
+
|
74 |
+
@staticmethod
|
75 |
+
def from_str(type):
|
76 |
+
if "fine-tuned" in type or "🔶" in type:
|
77 |
+
return ModelType.FT
|
78 |
+
if "pretrained" in type or "🟢" in type:
|
79 |
+
return ModelType.PT
|
80 |
+
if "RL-tuned" in type or "🟦" in type:
|
81 |
+
return ModelType.RL
|
82 |
+
if "instruction-tuned" in type or "⭕" in type:
|
83 |
+
return ModelType.IFT
|
84 |
+
return ModelType.Unknown
|
85 |
+
|
86 |
+
class WeightType(Enum):
|
87 |
+
Adapter = ModelDetails("Adapter")
|
88 |
+
Original = ModelDetails("Original")
|
89 |
+
Delta = ModelDetails("Delta")
|
90 |
+
|
91 |
+
class Precision(Enum):
|
92 |
+
float16 = ModelDetails("float16")
|
93 |
+
bfloat16 = ModelDetails("bfloat16")
|
94 |
+
Unknown = ModelDetails("?")
|
95 |
+
|
96 |
+
def from_str(precision):
|
97 |
+
if precision in ["torch.float16", "float16"]:
|
98 |
+
return Precision.float16
|
99 |
+
if precision in ["torch.bfloat16", "bfloat16"]:
|
100 |
+
return Precision.bfloat16
|
101 |
+
return Precision.Unknown
|
102 |
+
|
103 |
+
# Column selection
|
104 |
+
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
105 |
+
|
106 |
+
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
107 |
+
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
108 |
+
|
109 |
+
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
110 |
+
|
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 = "demo-leaderboard-backend" # 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}/leaderboard"
|
13 |
+
QUEUE_REPO = f"{OWNER}/requests"
|
14 |
+
RESULTS_REPO = f"{OWNER}/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/json_leaderboard.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import pandas as pd
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
|
6 |
+
def load_leaderboard_from_json(json_path="leaderboard_data.json"):
|
7 |
+
"""Load leaderboard data from JSON file"""
|
8 |
+
try:
|
9 |
+
with open(json_path, 'r', encoding='utf-8') as f:
|
10 |
+
data = json.load(f)
|
11 |
+
return data['leaderboard']
|
12 |
+
except FileNotFoundError:
|
13 |
+
print(f"JSON file {json_path} not found")
|
14 |
+
return []
|
15 |
+
except json.JSONDecodeError:
|
16 |
+
print(f"Error decoding JSON file {json_path}")
|
17 |
+
return []
|
18 |
+
|
19 |
+
|
20 |
+
def create_leaderboard_df(json_path="leaderboard_data.json"):
|
21 |
+
"""Create a pandas DataFrame from JSON leaderboard data"""
|
22 |
+
leaderboard_data = load_leaderboard_from_json(json_path)
|
23 |
+
|
24 |
+
if not leaderboard_data:
|
25 |
+
return pd.DataFrame()
|
26 |
+
|
27 |
+
# Convert to DataFrame
|
28 |
+
df = pd.DataFrame(leaderboard_data)
|
29 |
+
|
30 |
+
# Sort by ACC score (descending)
|
31 |
+
df = df.sort_values('acc', ascending=False).reset_index(drop=True)
|
32 |
+
|
33 |
+
# Add ranking icons and make model names clickable links to papers
|
34 |
+
def add_ranking_icon_and_link(index, model_name, paper_link):
|
35 |
+
if index == 0:
|
36 |
+
return f'🥇 <a href="{paper_link}" target="_blank">{model_name}</a>'
|
37 |
+
elif index == 1:
|
38 |
+
return f'🥈 <a href="{paper_link}" target="_blank">{model_name}</a>'
|
39 |
+
elif index == 2:
|
40 |
+
return f'🥉 <a href="{paper_link}" target="_blank">{model_name}</a>'
|
41 |
+
else:
|
42 |
+
return f'<a href="{paper_link}" target="_blank">{model_name}</a>'
|
43 |
+
|
44 |
+
# Format the DataFrame for display
|
45 |
+
display_df = pd.DataFrame({
|
46 |
+
'Model': [add_ranking_icon_and_link(i, model, link) for i, (model, link) in enumerate(zip(df['model'], df['link']))],
|
47 |
+
'Release Date': df['release_date'],
|
48 |
+
'HF Model': df['hf'].apply(lambda x: f'<a href="{x}" target="_blank">🤗</a>' if x != "-" else "-"),
|
49 |
+
'MoE': df['moe'].apply(lambda x: '-' if x == '-' else ('✓' if x else '✗')),
|
50 |
+
'Parameters': df['params'],
|
51 |
+
'Open Source': df['open_source'].apply(lambda x: '✓' if x else '✗'),
|
52 |
+
'ACC Score': df['acc'].apply(lambda x: f"{x:.1f}")
|
53 |
+
})
|
54 |
+
|
55 |
+
return display_df
|
56 |
+
|
57 |
+
|
58 |
+
def get_leaderboard_stats(json_path="leaderboard_data.json"):
|
59 |
+
"""Get statistics about the leaderboard"""
|
60 |
+
leaderboard_data = load_leaderboard_from_json(json_path)
|
61 |
+
|
62 |
+
if not leaderboard_data:
|
63 |
+
return {}
|
64 |
+
|
65 |
+
df = pd.DataFrame(leaderboard_data)
|
66 |
+
|
67 |
+
stats = {
|
68 |
+
'total_models': len(df),
|
69 |
+
'open_source_models': df['open_source'].sum(),
|
70 |
+
'moe_models': df['moe'].apply(lambda x: 1 if x is True else 0).sum(),
|
71 |
+
'avg_acc': df['acc'].mean(),
|
72 |
+
'max_acc': df['acc'].max(),
|
73 |
+
'min_acc': df['acc'].min()
|
74 |
+
}
|
75 |
+
|
76 |
+
return stats
|
src/leaderboard/read_evals.py
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
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 |
+
|
35 |
+
@classmethod
|
36 |
+
def init_from_json_file(self, json_filepath):
|
37 |
+
"""Inits the result from the specific model result file"""
|
38 |
+
with open(json_filepath) as fp:
|
39 |
+
data = json.load(fp)
|
40 |
+
|
41 |
+
config = data.get("config")
|
42 |
+
|
43 |
+
# Precision
|
44 |
+
precision = Precision.from_str(config.get("model_dtype"))
|
45 |
+
|
46 |
+
# Get model and org
|
47 |
+
org_and_model = config.get("model_name", config.get("model_args", None))
|
48 |
+
org_and_model = org_and_model.split("/", 1)
|
49 |
+
|
50 |
+
if len(org_and_model) == 1:
|
51 |
+
org = None
|
52 |
+
model = org_and_model[0]
|
53 |
+
result_key = f"{model}_{precision.value.name}"
|
54 |
+
else:
|
55 |
+
org = org_and_model[0]
|
56 |
+
model = org_and_model[1]
|
57 |
+
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
+
full_model = "/".join(org_and_model)
|
59 |
+
|
60 |
+
still_on_hub, _, model_config = is_model_on_hub(
|
61 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
62 |
+
)
|
63 |
+
architecture = "?"
|
64 |
+
if model_config is not None:
|
65 |
+
architectures = getattr(model_config, "architectures", None)
|
66 |
+
if architectures:
|
67 |
+
architecture = ";".join(architectures)
|
68 |
+
|
69 |
+
# Extract results available in this file (some results are split in several files)
|
70 |
+
results = {}
|
71 |
+
for task in Tasks:
|
72 |
+
task = task.value
|
73 |
+
|
74 |
+
# We average all scores of a given metric (not all metrics are present in all files)
|
75 |
+
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
76 |
+
if accs.size == 0 or any([acc is None for acc in accs]):
|
77 |
+
continue
|
78 |
+
|
79 |
+
mean_acc = np.mean(accs) * 100.0
|
80 |
+
results[task.benchmark] = mean_acc
|
81 |
+
|
82 |
+
return self(
|
83 |
+
eval_name=result_key,
|
84 |
+
full_model=full_model,
|
85 |
+
org=org,
|
86 |
+
model=model,
|
87 |
+
results=results,
|
88 |
+
precision=precision,
|
89 |
+
revision= config.get("model_sha", ""),
|
90 |
+
still_on_hub=still_on_hub,
|
91 |
+
architecture=architecture
|
92 |
+
)
|
93 |
+
|
94 |
+
def update_with_request_file(self, requests_path):
|
95 |
+
"""Finds the relevant request file for the current model and updates info with it"""
|
96 |
+
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
97 |
+
|
98 |
+
try:
|
99 |
+
with open(request_file, "r") as f:
|
100 |
+
request = json.load(f)
|
101 |
+
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
102 |
+
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
103 |
+
self.license = request.get("license", "?")
|
104 |
+
self.likes = request.get("likes", 0)
|
105 |
+
self.num_params = request.get("params", 0)
|
106 |
+
self.date = request.get("submitted_time", "")
|
107 |
+
except Exception:
|
108 |
+
print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
|
109 |
+
|
110 |
+
def to_dict(self):
|
111 |
+
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
112 |
+
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
113 |
+
data_dict = {
|
114 |
+
"eval_name": self.eval_name, # not a column, just a save name,
|
115 |
+
AutoEvalColumn.precision.name: self.precision.value.name,
|
116 |
+
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
117 |
+
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
118 |
+
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
119 |
+
AutoEvalColumn.architecture.name: self.architecture,
|
120 |
+
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
121 |
+
AutoEvalColumn.revision.name: self.revision,
|
122 |
+
AutoEvalColumn.average.name: average,
|
123 |
+
AutoEvalColumn.license.name: self.license,
|
124 |
+
AutoEvalColumn.likes.name: self.likes,
|
125 |
+
AutoEvalColumn.params.name: self.num_params,
|
126 |
+
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
127 |
+
}
|
128 |
+
|
129 |
+
for task in Tasks:
|
130 |
+
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
131 |
+
|
132 |
+
return data_dict
|
133 |
+
|
134 |
+
|
135 |
+
def get_request_file_for_model(requests_path, model_name, precision):
|
136 |
+
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
137 |
+
request_files = os.path.join(
|
138 |
+
requests_path,
|
139 |
+
f"{model_name}_eval_request_*.json",
|
140 |
+
)
|
141 |
+
request_files = glob.glob(request_files)
|
142 |
+
|
143 |
+
# Select correct request file (precision)
|
144 |
+
request_file = ""
|
145 |
+
request_files = sorted(request_files, reverse=True)
|
146 |
+
for tmp_request_file in request_files:
|
147 |
+
with open(tmp_request_file, "r") as f:
|
148 |
+
req_content = json.load(f)
|
149 |
+
if (
|
150 |
+
req_content["status"] in ["FINISHED"]
|
151 |
+
and req_content["precision"] == precision.split(".")[-1]
|
152 |
+
):
|
153 |
+
request_file = tmp_request_file
|
154 |
+
return request_file
|
155 |
+
|
156 |
+
|
157 |
+
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
158 |
+
"""From the path of the results folder root, extract all needed info for results"""
|
159 |
+
model_result_filepaths = []
|
160 |
+
|
161 |
+
for root, _, files in os.walk(results_path):
|
162 |
+
# We should only have json files in model results
|
163 |
+
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
164 |
+
continue
|
165 |
+
|
166 |
+
# Sort the files by date
|
167 |
+
try:
|
168 |
+
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
169 |
+
except dateutil.parser._parser.ParserError:
|
170 |
+
files = [files[-1]]
|
171 |
+
|
172 |
+
for file in files:
|
173 |
+
model_result_filepaths.append(os.path.join(root, file))
|
174 |
+
|
175 |
+
eval_results = {}
|
176 |
+
for model_result_filepath in model_result_filepaths:
|
177 |
+
# Creation of result
|
178 |
+
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
179 |
+
eval_result.update_with_request_file(requests_path)
|
180 |
+
|
181 |
+
# Store results of same eval together
|
182 |
+
eval_name = eval_result.eval_name
|
183 |
+
if eval_name in eval_results.keys():
|
184 |
+
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
185 |
+
else:
|
186 |
+
eval_results[eval_name] = eval_result
|
187 |
+
|
188 |
+
results = []
|
189 |
+
for v in eval_results.values():
|
190 |
+
try:
|
191 |
+
v.to_dict() # we test if the dict version is complete
|
192 |
+
results.append(v)
|
193 |
+
except KeyError: # not all eval values present
|
194 |
+
continue
|
195 |
+
|
196 |
+
return results
|
src/populate.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
7 |
+
from src.display.utils import AutoEvalColumn, EvalQueueColumn, ModelType, Precision, WeightType
|
8 |
+
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
+
from src.about import Tasks
|
10 |
+
|
11 |
+
|
12 |
+
def load_csv_results():
|
13 |
+
"""Load results from main-results.csv file"""
|
14 |
+
csv_path = "main-results.csv"
|
15 |
+
if not os.path.exists(csv_path):
|
16 |
+
return []
|
17 |
+
|
18 |
+
df = pd.read_csv(csv_path)
|
19 |
+
results = []
|
20 |
+
|
21 |
+
for _, row in df.iterrows():
|
22 |
+
# Parse parameters - handle different formats
|
23 |
+
param_str = str(row['Param'])
|
24 |
+
if 'activated' in param_str:
|
25 |
+
# Extract the activated parameter count (e.g., "2.8B activated (16B total)")
|
26 |
+
param_value = float(param_str.split('B')[0])
|
27 |
+
elif 'B' in param_str:
|
28 |
+
# Simple format (e.g., "9B")
|
29 |
+
param_value = float(param_str.replace('B', ''))
|
30 |
+
else:
|
31 |
+
param_value = 0
|
32 |
+
|
33 |
+
# Convert CSV data to the format expected by the leaderboard
|
34 |
+
data_dict = {
|
35 |
+
AutoEvalColumn.model.name: make_clickable_model(row['Model']),
|
36 |
+
AutoEvalColumn.average.name: row['ACC'], # Using ACC as the average score
|
37 |
+
AutoEvalColumn.params.name: param_value,
|
38 |
+
AutoEvalColumn.license.name: "Open Source" if row['Open Source?'] == 'Yes' else "Proprietary",
|
39 |
+
AutoEvalColumn.model_type.name: ModelType.FT.value.name, # Default to fine-tuned
|
40 |
+
AutoEvalColumn.precision.name: Precision.float16.value.name, # Default precision
|
41 |
+
AutoEvalColumn.weight_type.name: WeightType.Original.value.name,
|
42 |
+
AutoEvalColumn.architecture.name: "Unknown",
|
43 |
+
AutoEvalColumn.still_on_hub.name: True,
|
44 |
+
AutoEvalColumn.revision.name: "",
|
45 |
+
AutoEvalColumn.likes.name: 0,
|
46 |
+
AutoEvalColumn.model_type_symbol.name: ModelType.FT.value.symbol,
|
47 |
+
}
|
48 |
+
|
49 |
+
# Add task-specific scores (required by the leaderboard)
|
50 |
+
for task in Tasks:
|
51 |
+
data_dict[task.name] = row['ACC'] # Use the same ACC score for all tasks
|
52 |
+
|
53 |
+
results.append(data_dict)
|
54 |
+
|
55 |
+
return results
|
56 |
+
|
57 |
+
|
58 |
+
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
59 |
+
"""Creates a dataframe from all the individual experiment results"""
|
60 |
+
raw_data = get_raw_eval_results(results_path, requests_path)
|
61 |
+
all_data_json = [v.to_dict() for v in raw_data]
|
62 |
+
|
63 |
+
# If no JSON data found, try loading from CSV
|
64 |
+
if not all_data_json:
|
65 |
+
all_data_json = load_csv_results()
|
66 |
+
|
67 |
+
if not all_data_json:
|
68 |
+
# Return empty dataframe if no data found
|
69 |
+
return pd.DataFrame(columns=cols)
|
70 |
+
|
71 |
+
df = pd.DataFrame.from_records(all_data_json)
|
72 |
+
|
73 |
+
# Only include columns that exist in the dataframe
|
74 |
+
existing_cols = [col for col in cols if col in df.columns]
|
75 |
+
|
76 |
+
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
77 |
+
df = df[existing_cols].round(decimals=2)
|
78 |
+
|
79 |
+
# filter out if any of the benchmarks have not been produced
|
80 |
+
df = df[has_no_nan_values(df, benchmark_cols)]
|
81 |
+
return df
|
82 |
+
|
83 |
+
|
84 |
+
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
85 |
+
"""Creates the different dataframes for the evaluation queues requestes"""
|
86 |
+
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
87 |
+
all_evals = []
|
88 |
+
|
89 |
+
for entry in entries:
|
90 |
+
if ".json" in entry:
|
91 |
+
file_path = os.path.join(save_path, entry)
|
92 |
+
with open(file_path) as fp:
|
93 |
+
data = json.load(fp)
|
94 |
+
|
95 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
96 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
97 |
+
|
98 |
+
all_evals.append(data)
|
99 |
+
elif ".md" not in entry:
|
100 |
+
# this is a folder
|
101 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
|
102 |
+
for sub_entry in sub_entries:
|
103 |
+
file_path = os.path.join(save_path, entry, sub_entry)
|
104 |
+
with open(file_path) as fp:
|
105 |
+
data = json.load(fp)
|
106 |
+
|
107 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
108 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
109 |
+
all_evals.append(data)
|
110 |
+
|
111 |
+
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
112 |
+
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
113 |
+
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
114 |
+
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
115 |
+
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
116 |
+
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
117 |
+
return df_finished[cols], df_running[cols], df_pending[cols]
|
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,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
from datetime import datetime, timezone
|
4 |
+
|
5 |
+
from src.display.formatting import styled_error, styled_message, styled_warning
|
6 |
+
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
|
7 |
+
from src.submission.check_validity import (
|
8 |
+
already_submitted_models,
|
9 |
+
check_model_card,
|
10 |
+
get_model_size,
|
11 |
+
is_model_on_hub,
|
12 |
+
)
|
13 |
+
|
14 |
+
REQUESTED_MODELS = None
|
15 |
+
USERS_TO_SUBMISSION_DATES = None
|
16 |
+
|
17 |
+
def add_new_eval(
|
18 |
+
model: str,
|
19 |
+
base_model: str,
|
20 |
+
revision: str,
|
21 |
+
precision: str,
|
22 |
+
weight_type: str,
|
23 |
+
model_type: str,
|
24 |
+
):
|
25 |
+
global REQUESTED_MODELS
|
26 |
+
global USERS_TO_SUBMISSION_DATES
|
27 |
+
if not REQUESTED_MODELS:
|
28 |
+
REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
|
29 |
+
|
30 |
+
user_name = ""
|
31 |
+
model_path = model
|
32 |
+
if "/" in model:
|
33 |
+
user_name = model.split("/")[0]
|
34 |
+
model_path = model.split("/")[1]
|
35 |
+
|
36 |
+
precision = precision.split(" ")[0]
|
37 |
+
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
38 |
+
|
39 |
+
if model_type is None or model_type == "":
|
40 |
+
return styled_error("Please select a model type.")
|
41 |
+
|
42 |
+
# Does the model actually exist?
|
43 |
+
if revision == "":
|
44 |
+
revision = "main"
|
45 |
+
|
46 |
+
# Is the model on the hub?
|
47 |
+
if weight_type in ["Delta", "Adapter"]:
|
48 |
+
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=True)
|
49 |
+
if not base_model_on_hub:
|
50 |
+
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
+
|
52 |
+
if not weight_type == "Adapter":
|
53 |
+
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=True)
|
54 |
+
if not model_on_hub:
|
55 |
+
return styled_error(f'Model "{model}" {error}')
|
56 |
+
|
57 |
+
# Is the model info correctly filled?
|
58 |
+
try:
|
59 |
+
model_info = API.model_info(repo_id=model, revision=revision)
|
60 |
+
except Exception:
|
61 |
+
return styled_error("Could not get your model information. Please fill it up properly.")
|
62 |
+
|
63 |
+
model_size = get_model_size(model_info=model_info, precision=precision)
|
64 |
+
|
65 |
+
# Were the model card and license filled?
|
66 |
+
try:
|
67 |
+
license = model_info.cardData["license"]
|
68 |
+
except Exception:
|
69 |
+
return styled_error("Please select a license for your model")
|
70 |
+
|
71 |
+
modelcard_OK, error_msg = check_model_card(model)
|
72 |
+
if not modelcard_OK:
|
73 |
+
return styled_error(error_msg)
|
74 |
+
|
75 |
+
# Seems good, creating the eval
|
76 |
+
print("Adding new eval")
|
77 |
+
|
78 |
+
eval_entry = {
|
79 |
+
"model": model,
|
80 |
+
"base_model": base_model,
|
81 |
+
"revision": revision,
|
82 |
+
"precision": precision,
|
83 |
+
"weight_type": weight_type,
|
84 |
+
"status": "PENDING",
|
85 |
+
"submitted_time": current_time,
|
86 |
+
"model_type": model_type,
|
87 |
+
"likes": model_info.likes,
|
88 |
+
"params": model_size,
|
89 |
+
"license": license,
|
90 |
+
"private": False,
|
91 |
+
}
|
92 |
+
|
93 |
+
# Check for duplicate submission
|
94 |
+
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
95 |
+
return styled_warning("This model has been already submitted.")
|
96 |
+
|
97 |
+
print("Creating eval file")
|
98 |
+
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
99 |
+
os.makedirs(OUT_DIR, exist_ok=True)
|
100 |
+
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
101 |
+
|
102 |
+
with open(out_path, "w") as f:
|
103 |
+
f.write(json.dumps(eval_entry))
|
104 |
+
|
105 |
+
print("Uploading eval file")
|
106 |
+
API.upload_file(
|
107 |
+
path_or_fileobj=out_path,
|
108 |
+
path_in_repo=out_path.split("eval-queue/")[1],
|
109 |
+
repo_id=QUEUE_REPO,
|
110 |
+
repo_type="dataset",
|
111 |
+
commit_message=f"Add {model} to eval queue",
|
112 |
+
)
|
113 |
+
|
114 |
+
# Remove the local file
|
115 |
+
os.remove(out_path)
|
116 |
+
|
117 |
+
return styled_message(
|
118 |
+
"Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
119 |
+
)
|