Alignment-Lab-AI commited on
Commit
d741f98
β€’
1 Parent(s): 6df700e

Upload folder using huggingface_hub

Browse files
.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,5 @@ 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
36
+ gif.gif filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ venv/
2
+ .venv/
3
+ __pycache__/
4
+ .env
5
+ .ipynb_checkpoints
6
+ *ipynb
7
+ .vscode/
8
+ .DS_Store
9
+ .ruff_cache/
10
+ .python-version
11
+ .profile_app.python
12
+ *pstats
13
+ poetry.lock
14
+
15
+ eval-queue/
16
+ eval-results/
17
+ dynamic-info/
18
+
19
+ src/assets/model_counts.html
.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,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: style format quality all
2
+
3
+ # Applies code style fixes to the specified file or directory
4
+ style:
5
+ @echo "Applying style fixes to $(file)"
6
+ ruff format $(file)
7
+ ruff check --fix $(file) --line-length 119
8
+
9
+ # Checks code quality for the specified file or directory
10
+ quality:
11
+ @echo "Checking code quality for $(file)"
12
+ ruff check $(file) --line-length 119
13
+
14
+ # Applies PEP8 formatting and checks the entire codebase
15
+ all:
16
+ @echo "Formatting and checking the entire codebase"
17
+ ruff format .
18
+ ruff check --fix . --line-length 119
README.md CHANGED
@@ -1,12 +1,23 @@
1
  ---
2
- title: Orcaleaderboard
3
- emoji: πŸŒ–
4
- colorFrom: gray
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 5.4.0
8
  app_file: app.py
9
- pinned: false
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Open LLM Leaderboard
3
+ emoji: πŸ†
4
+ colorFrom: green
5
+ colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 4.20.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: apache-2.0
11
+ fullWidth: true
12
+ startup_duration_timeout: 1h
13
+ space_ci:
14
+ private: true
15
+ secrets:
16
+ - HF_TOKEN
17
+ - WEBHOOK_SECRET
18
+ tags:
19
+ - leaderboard
20
+ short_description: Track, rank and evaluate open LLMs and chatbots
21
  ---
22
 
23
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import logging
3
+ import time
4
+ import datetime
5
+ import gradio as gr
6
+ import datasets
7
+ from huggingface_hub import snapshot_download
8
+ from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
9
+
10
+ from src.display.about import (
11
+ CITATION_BUTTON_LABEL,
12
+ CITATION_BUTTON_TEXT,
13
+ FAQ_TEXT,
14
+ INTRODUCTION_TEXT,
15
+ LLM_BENCHMARKS_TEXT,
16
+ TITLE,
17
+ )
18
+ from src.display.css_html_js import custom_css
19
+ from src.display.utils import (
20
+ BENCHMARK_COLS,
21
+ COLS,
22
+ EVAL_COLS,
23
+ AutoEvalColumn,
24
+ fields,
25
+ )
26
+ from src.envs import (
27
+ EVAL_REQUESTS_PATH,
28
+ AGGREGATED_REPO,
29
+ QUEUE_REPO,
30
+ REPO_ID,
31
+ HF_HOME,
32
+ )
33
+ from src.populate import get_evaluation_queue_df, get_leaderboard_df
34
+ from src.tools.plots import create_metric_plot_obj, create_plot_df, create_scores_df
35
+
36
+ # Configure logging
37
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
38
+
39
+
40
+ # Convert the environment variable "LEADERBOARD_FULL_INIT" to a boolean value, defaulting to True if the variable is not set.
41
+ # This controls whether a full initialization should be performed.
42
+ DO_FULL_INIT = os.getenv("LEADERBOARD_FULL_INIT", "True") == "True"
43
+ LAST_UPDATE_LEADERBOARD = datetime.datetime.now()
44
+
45
+ def time_diff_wrapper(func):
46
+ def wrapper(*args, **kwargs):
47
+ start_time = time.time()
48
+ result = func(*args, **kwargs)
49
+ end_time = time.time()
50
+ diff = end_time - start_time
51
+ logging.info(f"Time taken for {func.__name__}: {diff} seconds")
52
+ return result
53
+
54
+ return wrapper
55
+
56
+
57
+ @time_diff_wrapper
58
+ def download_dataset(repo_id, local_dir, repo_type="dataset", max_attempts=3, backoff_factor=1.5):
59
+ """Download dataset with exponential backoff retries."""
60
+ attempt = 0
61
+ while attempt < max_attempts:
62
+ try:
63
+ logging.info(f"Downloading {repo_id} to {local_dir}")
64
+ snapshot_download(
65
+ repo_id=repo_id,
66
+ local_dir=local_dir,
67
+ repo_type=repo_type,
68
+ tqdm_class=None,
69
+ etag_timeout=30,
70
+ max_workers=8,
71
+ )
72
+ logging.info("Download successful")
73
+ return
74
+ except Exception as e:
75
+ wait_time = backoff_factor**attempt
76
+ logging.error(f"Error downloading {repo_id}: {e}, retrying in {wait_time}s")
77
+ time.sleep(wait_time)
78
+ attempt += 1
79
+ raise Exception(f"Failed to download {repo_id} after {max_attempts} attempts")
80
+
81
+ def get_latest_data_leaderboard(leaderboard_initial_df = None):
82
+ current_time = datetime.datetime.now()
83
+ global LAST_UPDATE_LEADERBOARD
84
+ if current_time - LAST_UPDATE_LEADERBOARD < datetime.timedelta(minutes=10) and leaderboard_initial_df is not None:
85
+ return leaderboard_initial_df
86
+ LAST_UPDATE_LEADERBOARD = current_time
87
+ leaderboard_dataset = datasets.load_dataset(
88
+ AGGREGATED_REPO,
89
+ "default",
90
+ split="train",
91
+ cache_dir=HF_HOME,
92
+ download_mode=datasets.DownloadMode.REUSE_DATASET_IF_EXISTS, # Uses the cached dataset
93
+ verification_mode="no_checks"
94
+ )
95
+
96
+ leaderboard_df = get_leaderboard_df(
97
+ leaderboard_dataset=leaderboard_dataset,
98
+ cols=COLS,
99
+ benchmark_cols=BENCHMARK_COLS,
100
+ )
101
+
102
+ return leaderboard_df
103
+
104
+ def get_latest_data_queue():
105
+ eval_queue_dfs = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
106
+ return eval_queue_dfs
107
+
108
+ def init_space():
109
+ """Initializes the application space, loading only necessary data."""
110
+ if DO_FULL_INIT:
111
+ # These downloads only occur on full initialization
112
+ download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
113
+
114
+ # Always redownload the leaderboard DataFrame
115
+ leaderboard_df = get_latest_data_leaderboard()
116
+
117
+ # Evaluation queue DataFrame retrieval is independent of initialization detail level
118
+ eval_queue_dfs = get_latest_data_queue()
119
+
120
+ return leaderboard_df, eval_queue_dfs
121
+
122
+
123
+ # Calls the init_space function with the `full_init` parameter determined by the `do_full_init` variable.
124
+ # This initializes various DataFrames used throughout the application, with the level of initialization detail controlled by the `do_full_init` flag.
125
+ leaderboard_df, eval_queue_dfs = init_space()
126
+ finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = eval_queue_dfs
127
+
128
+
129
+ # Data processing for plots now only on demand in the respective Gradio tab
130
+ def load_and_create_plots():
131
+ plot_df = create_plot_df(create_scores_df(leaderboard_df))
132
+ return plot_df
133
+
134
+ def init_leaderboard(dataframe):
135
+ return Leaderboard(
136
+ value = dataframe,
137
+ datatype=[c.type for c in fields(AutoEvalColumn)],
138
+ select_columns=SelectColumns(
139
+ default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
140
+ cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.dummy],
141
+ label="Select Columns to Display:",
142
+ ),
143
+ search_columns=[AutoEvalColumn.model.name, AutoEvalColumn.fullname.name, AutoEvalColumn.license.name],
144
+ hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
145
+ filter_columns=[
146
+ ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
147
+ ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
148
+ ColumnFilter(
149
+ AutoEvalColumn.params.name,
150
+ type="slider",
151
+ min=0.01,
152
+ max=150,
153
+ label="Select the number of parameters (B)",
154
+ ),
155
+ ColumnFilter(
156
+ AutoEvalColumn.still_on_hub.name, type="boolean", label="Private or deleted", default=True
157
+ ),
158
+ ColumnFilter(
159
+ AutoEvalColumn.merged.name, type="boolean", label="Contains a merge/moerge", default=True
160
+ ),
161
+ ColumnFilter(AutoEvalColumn.moe.name, type="boolean", label="MoE", default=False),
162
+ ColumnFilter(AutoEvalColumn.not_flagged.name, type="boolean", label="Flagged", default=True),
163
+ ],
164
+ bool_checkboxgroup_label="Hide models",
165
+ interactive=False,
166
+ )
167
+
168
+ demo = gr.Blocks(css=custom_css)
169
+ with demo:
170
+ gr.HTML(TITLE)
171
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
172
+
173
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
174
+ with gr.TabItem("πŸ… LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
175
+ leaderboard = init_leaderboard(leaderboard_df)
176
+
177
+ with gr.TabItem("πŸ“ˆ Metrics through time", elem_id="llm-benchmark-tab-table", id=2):
178
+ with gr.Row():
179
+ with gr.Column():
180
+ plot_df = load_and_create_plots()
181
+ chart = create_metric_plot_obj(
182
+ plot_df,
183
+ [AutoEvalColumn.average.name],
184
+ title="Average of Top Scores and Human Baseline Over Time (from last update)",
185
+ )
186
+ gr.Plot(value=chart, min_width=500)
187
+ with gr.Column():
188
+ plot_df = load_and_create_plots()
189
+ chart = create_metric_plot_obj(
190
+ plot_df,
191
+ BENCHMARK_COLS,
192
+ title="Top Scores and Human Baseline Over Time (from last update)",
193
+ )
194
+ gr.Plot(value=chart, min_width=500)
195
+
196
+ with gr.TabItem("πŸ“ About", elem_id="llm-benchmark-tab-table", id=3):
197
+ gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
198
+
199
+ with gr.TabItem("❗FAQ", elem_id="llm-benchmark-tab-table", id=4):
200
+ gr.Markdown(FAQ_TEXT, elem_classes="markdown-text")
201
+
202
+ with gr.Row():
203
+ with gr.Accordion("πŸ“™ Citation", open=False):
204
+ citation_button = gr.Textbox(
205
+ value=CITATION_BUTTON_TEXT,
206
+ label=CITATION_BUTTON_LABEL,
207
+ lines=20,
208
+ elem_id="citation-button",
209
+ show_copy_button=True,
210
+ )
211
+
212
+ demo.load(fn=get_latest_data_leaderboard, inputs=[leaderboard], outputs=[leaderboard])
213
+
214
+
215
+ demo.queue(default_concurrency_limit=40).launch()
app_timer.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import logging
3
+ import time
4
+ import datetime
5
+ import gradio as gr
6
+ import datasets
7
+ from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload, RepoCard
8
+ from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
9
+
10
+ from src.display.about import (
11
+ CITATION_BUTTON_LABEL,
12
+ CITATION_BUTTON_TEXT,
13
+ INTRODUCTION_TEXT,
14
+ TITLE,
15
+ )
16
+ from src.display.css_html_js import custom_css
17
+
18
+ demo = gr.Blocks(css=custom_css)
19
+ with demo:
20
+ gr.HTML(TITLE)
21
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
22
+
23
+ countdown = gr.HTML(
24
+ """<div align="center">
25
+ <div position: relative>
26
+ <img
27
+ src="https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/resolve/main/gif.gif"
28
+ allowtransparency="true"
29
+ style="display:block;width:100%;height:auto;"
30
+ />
31
+ <iframe
32
+ src="https://logwork.com/widget/countdown/?text=Surprise%20loading...&amp;timezone=Europe%2FParis&amp;width=&amp;style=circles&amp;uid=815898&amp;loc=https://logwork.com/countdown-fxmc&amp;language=en&amp;textcolor=&amp;background=%23ffd21e&amp;date=2024-06-26%2015%3A00%3A00&amp;digitscolor=%23ff9d00&amp;unitscolor=&amp"
33
+ style="position: absolute; top:0; left: 0; border: medium; width:100%; height:100%; margin: 0px; visibility: visible;"
34
+ scrolling="no"
35
+ allowtransparency="true"
36
+ frameborder="0"
37
+ allowfullscreen
38
+ />
39
+ </div>
40
+ </div>"""
41
+ )
42
+ #gif = gr.Image(value="./gif.gif", interactive=False)
43
+ gr.Markdown("*Countdown by Logwork.com, gif art by Chun Te Lee*")
44
+
45
+ with gr.Row():
46
+ with gr.Accordion("πŸ“™ Citation", open=False):
47
+ citation_button = gr.Textbox(
48
+ value=CITATION_BUTTON_TEXT,
49
+ label=CITATION_BUTTON_LABEL,
50
+ lines=20,
51
+ elem_id="citation-button",
52
+ show_copy_button=True,
53
+ )
54
+
55
+ demo.queue(default_concurrency_limit=40).launch()
gif.gif ADDED

Git LFS Details

  • SHA256: ca34fd48c50eda15857dffedd1659921e7ae33e1d53f5e7afa34696040f4ef80
  • Pointer size: 132 Bytes
  • Size of remote file: 3.85 MB
pyproject.toml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.ruff]
2
+ line-length = 120
3
+ target-version = "py312"
4
+ include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
5
+ ignore=["I","EM","FBT","TRY003","S101","D101","D102","D103","D104","D105","G004","D107","FA102"]
6
+ fixable=["ALL"]
7
+ select=["ALL"]
8
+
9
+ [tool.ruff.lint]
10
+ select = ["E", "F"]
11
+ fixable = ["ALL"]
12
+ ignore = ["E501"] # line too long (black is taking care of this)
13
+
14
+ [tool.isort]
15
+ profile = "black"
16
+ line_length = 119
17
+
18
+ [tool.black]
19
+ line-length = 119
20
+
21
+ [tool.poetry]
22
+ package-mode = false
23
+ name = "open-llm-leaderboard"
24
+ version = "0.1.0"
25
+ description = ""
26
+ authors = []
27
+ readme = "README.md"
28
+
29
+ [tool.poetry.dependencies]
30
+ python = "3.12.1"
31
+ apscheduler = "3.10.1"
32
+ black = "23.11.0"
33
+ click = "8.1.3"
34
+ datasets = "2.14.5"
35
+ huggingface-hub = ">=0.18.0"
36
+ matplotlib = "3.8.4"
37
+ numpy = "1.26.0"
38
+ pandas = "2.2.2"
39
+ plotly = "5.14.1"
40
+ python-dateutil = "2.8.2"
41
+ requests = "2.28.2"
42
+ sentencepiece = "^0.2.0"
43
+ tqdm = "4.65.0"
44
+ transformers = "4.41.1"
45
+ tokenizers = ">=0.15.0"
46
+ gradio-space-ci = {git = "https://huggingface.co/spaces/Wauplin/gradio-space-ci", rev = "0.2.3"}
47
+ gradio = " 4.20.0"
48
+ isort = "^5.13.2"
49
+ ruff = "^0.3.5"
50
+ gradio-leaderboard = "0.0.8"
51
+
52
+ [build-system]
53
+ requires = ["poetry-core"]
54
+ build-backend = "poetry.core.masonry.api"
requirements.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ APScheduler==3.10.1
2
+ black==23.11.0
3
+ click==8.1.3
4
+ datasets==2.14.5
5
+ huggingface-hub>=0.18.0
6
+ matplotlib==3.8.4
7
+ numpy==1.26.0
8
+ pandas==2.2.2
9
+ plotly==5.14.1
10
+ python-dateutil==2.8.2
11
+ requests==2.28.2
12
+ sentencepiece
13
+ tqdm==4.65.0
14
+ transformers==4.41.1
15
+ tokenizers>=0.15.0
16
+ gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.3 # CI !!!
17
+ gradio==4.20.0
18
+ gradio_leaderboard==0.0.9
src/display/about.py ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from src.display.utils import ModelType
2
+
3
+ TITLE = """<h1 style="text-align:left;float:left; id="space-title">πŸ€— Open LLM Leaderboard Archive</h1>"""
4
+
5
+ INTRODUCTION_TEXT = """
6
+ This is the archived version of the Open LLM Leaderboard, which ran from April 2023 to June 2024.
7
+ """
8
+
9
+ icons = f"""
10
+ - {ModelType.PT.to_str(" : ")} model: new, base models, trained on a given text corpora using masked modelling
11
+ - {ModelType.CPT.to_str(" : ")} model: new, base models, continuously trained on further corpus (which may include IFT/chat data) using masked modelling
12
+ - {ModelType.FT.to_str(" : ")} model: pretrained models finetuned on more data
13
+ - {ModelType.chat.to_str(" : ")} model: chat like fine-tunes, either using IFT (datasets of task instruction), RLHF or DPO (changing the model loss a bit with an added policy), etc
14
+ - {ModelType.merges.to_str(" : ")} model: merges or MoErges, models which have been merged or fused without additional fine-tuning.
15
+ """
16
+ LLM_BENCHMARKS_TEXT = """
17
+ ## ABOUT
18
+ With the plethora of large language models (LLMs) and chatbots being released week upon week, often with grandiose claims of their performance, it can be hard to filter out the genuine progress that is being made by the open-source community and which model is the current state of the art.
19
+
20
+ πŸ€— Submit a model for automated evaluation on the πŸ€— GPU cluster on the "Submit" page!
21
+ The leaderboard's backend runs the great [Eleuther AI Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) - read more details below!
22
+
23
+ ### Tasks
24
+ πŸ“ˆ We evaluate models on 6 key benchmarks using the <a href="https://github.com/EleutherAI/lm-evaluation-harness" target="_blank"> Eleuther AI Language Model Evaluation Harness </a>, a unified framework to test generative language models on a large number of different evaluation tasks.
25
+
26
+ - <a href="https://arxiv.org/abs/1803.05457" target="_blank"> AI2 Reasoning Challenge </a> (25-shot) - a set of grade-school science questions.
27
+ - <a href="https://arxiv.org/abs/1905.07830" target="_blank"> HellaSwag </a> (10-shot) - a test of commonsense inference, which is easy for humans (~95%) but challenging for SOTA models.
28
+ - <a href="https://arxiv.org/abs/2009.03300" target="_blank"> MMLU </a> (5-shot) - a test to measure a text model's multitask accuracy. The test covers 57 tasks including elementary mathematics, US history, computer science, law, and more.
29
+ - <a href="https://arxiv.org/abs/2109.07958" target="_blank"> TruthfulQA </a> (0-shot) - a test to measure a model's propensity to reproduce falsehoods commonly found online. Note: TruthfulQA is technically a 6-shot task in the Harness because each example is prepended with 6 Q/A pairs, even in the 0-shot setting.
30
+ - <a href="https://arxiv.org/abs/1907.10641" target="_blank"> Winogrande </a> (5-shot) - an adversarial and difficult Winograd benchmark at scale, for commonsense reasoning.
31
+ - <a href="https://arxiv.org/abs/2110.14168" target="_blank"> GSM8k </a> (5-shot) - diverse grade school math word problems to measure a model's ability to solve multi-step mathematical reasoning problems.
32
+
33
+ For all these evaluations, a higher score is a better score.
34
+ We chose these benchmarks as they test a variety of reasoning and general knowledge across a wide variety of fields in 0-shot and few-shot settings.
35
+
36
+ ### Results
37
+ You can find:
38
+ - detailed numerical results in the `results` Hugging Face dataset: https://huggingface.co/datasets/open-llm-leaderboard/results
39
+ - details on the input/outputs for the models in the `details` of each model, which you can access by clicking the πŸ“„ emoji after the model name
40
+ - community queries and running status in the `requests` Hugging Face dataset: https://huggingface.co/datasets/open-llm-leaderboard/requests
41
+
42
+ If a model's name contains "Flagged", this indicates it has been flagged by the community, and should probably be ignored! Clicking the link will redirect you to the discussion about the model.
43
+
44
+ ---------------------------
45
+
46
+ ## REPRODUCIBILITY
47
+ To reproduce our results, here are the commands you can run, using [this version](https://github.com/EleutherAI/lm-evaluation-harness/tree/b281b0921b636bc36ad05c0b0b0763bd6dd43463) of the Eleuther AI Harness:
48
+ `python main.py --model=hf-causal-experimental --model_args="pretrained=<your_model>,use_accelerate=True,revision=<your_model_revision>"`
49
+ ` --tasks=<task_list> --num_fewshot=<n_few_shot> --batch_size=1 --output_path=<output_path>`
50
+
51
+ ```
52
+ python main.py --model=hf-causal-experimental \
53
+ --model_args="pretrained=<your_model>,use_accelerate=True,revision=<your_model_revision>" \
54
+ --tasks=<task_list> \
55
+ --num_fewshot=<n_few_shot> \
56
+ --batch_size=1 \
57
+ --output_path=<output_path>
58
+ ```
59
+
60
+ **Note:** We evaluate all models on a single node of 8 H100s, so the global batch size is 8 for each evaluation. If you don't use parallelism, adapt your batch size to fit.
61
+ *You can expect results to vary slightly for different batch sizes because of padding.*
62
+
63
+ The tasks and few shots parameters are:
64
+ - ARC: 25-shot, *arc-challenge* (`acc_norm`)
65
+ - HellaSwag: 10-shot, *hellaswag* (`acc_norm`)
66
+ - TruthfulQA: 0-shot, *truthfulqa-mc* (`mc2`)
67
+ - MMLU: 5-shot, *hendrycksTest-abstract_algebra,hendrycksTest-anatomy,hendrycksTest-astronomy,hendrycksTest-business_ethics,hendrycksTest-clinical_knowledge,hendrycksTest-college_biology,hendrycksTest-college_chemistry,hendrycksTest-college_computer_science,hendrycksTest-college_mathematics,hendrycksTest-college_medicine,hendrycksTest-college_physics,hendrycksTest-computer_security,hendrycksTest-conceptual_physics,hendrycksTest-econometrics,hendrycksTest-electrical_engineering,hendrycksTest-elementary_mathematics,hendrycksTest-formal_logic,hendrycksTest-global_facts,hendrycksTest-high_school_biology,hendrycksTest-high_school_chemistry,hendrycksTest-high_school_computer_science,hendrycksTest-high_school_european_history,hendrycksTest-high_school_geography,hendrycksTest-high_school_government_and_politics,hendrycksTest-high_school_macroeconomics,hendrycksTest-high_school_mathematics,hendrycksTest-high_school_microeconomics,hendrycksTest-high_school_physics,hendrycksTest-high_school_psychology,hendrycksTest-high_school_statistics,hendrycksTest-high_school_us_history,hendrycksTest-high_school_world_history,hendrycksTest-human_aging,hendrycksTest-human_sexuality,hendrycksTest-international_law,hendrycksTest-jurisprudence,hendrycksTest-logical_fallacies,hendrycksTest-machine_learning,hendrycksTest-management,hendrycksTest-marketing,hendrycksTest-medical_genetics,hendrycksTest-miscellaneous,hendrycksTest-moral_disputes,hendrycksTest-moral_scenarios,hendrycksTest-nutrition,hendrycksTest-philosophy,hendrycksTest-prehistory,hendrycksTest-professional_accounting,hendrycksTest-professional_law,hendrycksTest-professional_medicine,hendrycksTest-professional_psychology,hendrycksTest-public_relations,hendrycksTest-security_studies,hendrycksTest-sociology,hendrycksTest-us_foreign_policy,hendrycksTest-virology,hendrycksTest-world_religions* (average of all the results `acc`)
68
+ - Winogrande: 5-shot, *winogrande* (`acc`)
69
+ - GSM8k: 5-shot, *gsm8k* (`acc`)
70
+
71
+ Side note on the baseline scores:
72
+ - for log-likelihood evaluation, we select the random baseline
73
+ - for GSM8K, we select the score obtained in the paper after finetuning a 6B model on the full GSM8K training set for 50 epochs
74
+
75
+ ---------------------------
76
+
77
+ ## RESOURCES
78
+
79
+ ### Quantization
80
+ To get more information about quantization, see:
81
+ - 8 bits: [blog post](https://huggingface.co/blog/hf-bitsandbytes-integration), [paper](https://arxiv.org/abs/2208.07339)
82
+ - 4 bits: [blog post](https://huggingface.co/blog/4bit-transformers-bitsandbytes), [paper](https://arxiv.org/abs/2305.14314)
83
+
84
+ ### Useful links
85
+ - [Community resources](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/174)
86
+ - [Collection of best models](https://huggingface.co/collections/open-llm-leaderboard/llm-leaderboard-best-models-652d6c7965a4619fb5c27a03)
87
+
88
+ ### Other cool leaderboards:
89
+ - [LLM safety](https://huggingface.co/spaces/AI-Secure/llm-trustworthy-leaderboard)
90
+ - [LLM performance](https://huggingface.co/spaces/optimum/llm-perf-leaderboard)
91
+
92
+
93
+ """
94
+
95
+ FAQ_TEXT = """
96
+
97
+ ## SUBMISSIONS
98
+ My model requires `trust_remote_code=True`, can I submit it?
99
+ - *We only support models that have been integrated into a stable version of the `transformers` library for automatic submission, as we don't want to run possibly unsafe code on our cluster.*
100
+
101
+ What about models of type X?
102
+ - *We only support models that have been integrated into a stable version of the `transformers` library for automatic submission.*
103
+
104
+ How can I follow when my model is launched?
105
+ - *You can look for its request file [here](https://huggingface.co/datasets/open-llm-leaderboard/requests) and follow the status evolution, or directly in the queues above the submit form.*
106
+
107
+ My model disappeared from all the queues, what happened?
108
+ - *A model disappearing from all the queues usually means that there has been a failure. You can check if that is the case by looking for your model [here](https://huggingface.co/datasets/open-llm-leaderboard/requests).*
109
+
110
+ What causes an evaluation failure?
111
+ - *Most of the failures we get come from problems in the submissions (corrupted files, config problems, wrong parameters selected for eval ...), so we'll be grateful if you first make sure you have followed the steps in `About`. However, from time to time, we have failures on our side (hardware/node failures, problems with an update of our backend, connectivity problems ending up in the results not being saved, ...).*
112
+
113
+ How can I report an evaluation failure?
114
+ - *As we store the logs for all models, feel free to create an issue, **where you link to the requests file of your model** (look for it [here](https://huggingface.co/datasets/open-llm-leaderboard/requests/tree/main)), so we can investigate! If the model failed due to a problem on our side, we'll relaunch it right away!*
115
+ *Note: Please do not re-upload your model under a different name, it will not help*
116
+
117
+ ---------------------------
118
+
119
+ ## RESULTS
120
+ What kind of information can I find?
121
+ - *Let's imagine you are interested in the Yi-34B results. You have access to 3 different information categories:*
122
+ - *The [request file](https://huggingface.co/datasets/open-llm-leaderboard/requests/blob/main/01-ai/Yi-34B_eval_request_False_bfloat16_Original.json): it gives you information about the status of the evaluation*
123
+ - *The [aggregated results folder](https://huggingface.co/datasets/open-llm-leaderboard/results/tree/main/01-ai/Yi-34B): it gives you aggregated scores, per experimental run*
124
+ - *The [details dataset](https://huggingface.co/datasets/open-llm-leaderboard/details_01-ai__Yi-34B/tree/main): it gives you the full details (scores and examples for each task and a given model)*
125
+
126
+
127
+ Why do models appear several times in the leaderboard?
128
+ - *We run evaluations with user-selected precision and model commit. Sometimes, users submit specific models at different commits and at different precisions (for example, in float16 and 4bit to see how quantization affects performance). You should be able to verify this by displaying the `precision` and `model sha` columns in the display. If, however, you see models appearing several times with the same precision and hash commit, this is not normal.*
129
+
130
+ What is this concept of "flagging"?
131
+ - *This mechanism allows users to report models that have unfair performance on the leaderboard. This contains several categories: exceedingly good results on the leaderboard because the model was (maybe accidentally) trained on the evaluation data, models that are copies of other models not attributed properly, etc.*
132
+
133
+ My model has been flagged improperly, what can I do?
134
+ - *Every flagged model has a discussion associated with it - feel free to plead your case there, and we'll see what to do together with the community.*
135
+
136
+ ---------------------------
137
+
138
+ ## HOW TO SEARCH FOR A MODEL
139
+ Search for models in the leaderboard by:
140
+ 1. Name, e.g., *model_name*
141
+ 2. Multiple names, separated by `;`, e.g., *model_name1;model_name2*
142
+ 3. License, prefix with `Hub License:...`, e.g., *Hub License: MIT*
143
+ 4. Combination of name and license, order is irrelevant, e.g., *model_name; Hub License: cc-by-sa-4.0*
144
+
145
+ ---------------------------
146
+
147
+ ## EDITING SUBMISSIONS
148
+ I upgraded my model and want to re-submit, how can I do that?
149
+ - *Please open an issue with the precise name of your model, and we'll remove your model from the leaderboard so you can resubmit. You can also resubmit directly with the new commit hash!*
150
+
151
+ I need to rename my model, how can I do that?
152
+ - *You can use @Weyaxi 's [super cool tool](https://huggingface.co/spaces/Weyaxi/open-llm-leaderboard-renamer) to request model name changes, then open a discussion where you link to the created pull request, and we'll check them and merge them as needed.*
153
+
154
+ ---------------------------
155
+
156
+ ## OTHER
157
+ Why do you differentiate between pretrained, continuously pretrained, fine-tuned, merges, etc?
158
+ - *These different models do not play in the same categories, and therefore need to be separated for fair comparison. Base pretrained models are the most interesting for the community, as they are usually good models to fine-tune later on - any jump in performance from a pretrained model represents a true improvement on the SOTA.
159
+ Fine-tuned and IFT/RLHF/chat models usually have better performance, but the latter might be more sensitive to system prompts, which we do not cover at the moment in the Open LLM Leaderboard.
160
+ Merges and moerges have artificially inflated performance on test sets, which is not always explainable, and does not always apply to real-world situations.*
161
+
162
+ What should I use the leaderboard for?
163
+ - *We recommend using the leaderboard for 3 use cases: 1) getting an idea of the state of open pretrained models, by looking only at the ranks and score of this category; 2) experimenting with different fine-tuning methods, datasets, quantization techniques, etc, and comparing their score in a reproducible setup, and 3) checking the performance of a model of interest to you, wrt to other models of its category.*
164
+
165
+ Why don't you display closed-source model scores?
166
+ - *This is a leaderboard for Open models, both for philosophical reasons (openness is cool) and for practical reasons: we want to ensure that the results we display are accurate and reproducible, but 1) commercial closed models can change their API thus rendering any scoring at a given time incorrect 2) we re-run everything on our cluster to ensure all models are run on the same setup and you can't do that for these models.*
167
+
168
+ I have an issue with accessing the leaderboard through the Gradio API
169
+ - *Since this is not the recommended way to access the leaderboard, we won't provide support for this, but you can look at tools provided by the community for inspiration!*
170
+
171
+ I have another problem, help!
172
+ - *Please open an issue in the discussion tab, and we'll do our best to help you in a timely manner :) *
173
+ """
174
+
175
+
176
+ EVALUATION_QUEUE_TEXT = f"""
177
+ # Evaluation Queue for the πŸ€— Open LLM Leaderboard
178
+
179
+ Models added here will be automatically evaluated on the πŸ€— cluster.
180
+
181
+ ## Don't forget to read the FAQ and the About tabs for more information!
182
+
183
+ ## First steps before submitting a model
184
+
185
+ ### 1) Make sure you can load your model and tokenizer using AutoClasses:
186
+ ```python
187
+ from transformers import AutoConfig, AutoModel, AutoTokenizer
188
+ config = AutoConfig.from_pretrained("your model name", revision=revision)
189
+ model = AutoModel.from_pretrained("your model name", revision=revision)
190
+ tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
191
+ ```
192
+ If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
193
+
194
+ Note: make sure your model is public!
195
+ 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!
196
+
197
+ ### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
198
+ 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`!
199
+
200
+ ### 3) Make sure your model has an open license!
201
+ This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model πŸ€—
202
+
203
+ ### 4) Fill up your model card
204
+ When we add extra information about models to the leaderboard, it will be automatically taken from the model card
205
+
206
+ ### 5) Select the correct precision
207
+ Not all models are converted properly from `float16` to `bfloat16`, and selecting the wrong precision can sometimes cause evaluation error (as loading a `bf16` model in `fp16` can sometimes generate NaNs, depending on the weight range).
208
+
209
+ <b>Note:</b> Please be advised that when submitting, git <b>branches</b> and <b>tags</b> will be strictly tied to the <b>specific commit</b> present at the time of submission. This ensures revision consistency.
210
+ ## Model types
211
+ {icons}
212
+ """
213
+
214
+ CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
215
+ CITATION_BUTTON_TEXT = r"""
216
+ @misc{open-llm-leaderboard,
217
+ author = {Edward Beeching and ClΓ©mentine Fourrier and Nathan Habib and Sheon Han and Nathan Lambert and Nazneen Rajani and Omar Sanseviero and Lewis Tunstall and Thomas Wolf},
218
+ title = {Open LLM Leaderboard},
219
+ year = {2023},
220
+ publisher = {Hugging Face},
221
+ howpublished = "\url{https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard}"
222
+ }
223
+
224
+ ????
225
+ """
src/display/css_html_js.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ custom_css = """
2
+ /* Limit the width of the first AutoEvalColumn so that names don't expand too much */
3
+ table td:first-child,
4
+ table th:first-child {
5
+ max-width: 400px;
6
+ overflow: auto;
7
+ white-space: nowrap;
8
+ }
9
+
10
+ /* Full width space */
11
+ .gradio-container {
12
+ max-width: 95%!important;
13
+ }
14
+
15
+ /* Text style and margins */
16
+ .markdown-text {
17
+ font-size: 16px !important;
18
+ }
19
+
20
+ #models-to-add-text {
21
+ font-size: 18px !important;
22
+ }
23
+
24
+ #citation-button span {
25
+ font-size: 16px !important;
26
+ }
27
+
28
+ #citation-button textarea {
29
+ font-size: 16px !important;
30
+ }
31
+
32
+ #citation-button > label > button {
33
+ margin: 6px;
34
+ transform: scale(1.3);
35
+ }
36
+
37
+ #search-bar-table-box > div:first-child {
38
+ background: none;
39
+ border: none;
40
+ }
41
+
42
+ #search-bar {
43
+ padding: 0px;
44
+ }
45
+
46
+ .tab-buttons button {
47
+ font-size: 20px;
48
+ }
49
+
50
+ /* Filters style */
51
+ #filter_type{
52
+ border: 0;
53
+ padding-left: 0;
54
+ padding-top: 0;
55
+ }
56
+ #filter_type label {
57
+ display: flex;
58
+ }
59
+ #filter_type label > span{
60
+ margin-top: var(--spacing-lg);
61
+ margin-right: 0.5em;
62
+ }
63
+ #filter_type label > .wrap{
64
+ width: 103px;
65
+ }
66
+ #filter_type label > .wrap .wrap-inner{
67
+ padding: 2px;
68
+ }
69
+ #filter_type label > .wrap .wrap-inner input{
70
+ width: 1px
71
+ }
72
+ #filter-columns-type{
73
+ border:0;
74
+ padding:0.5;
75
+ }
76
+ #filter-columns-size{
77
+ border:0;
78
+ padding:0.5;
79
+ }
80
+ #box-filter > .form{
81
+ border: 0
82
+ }
83
+ """
84
+
85
+ get_window_url_params = """
86
+ function(url_params) {
87
+ const params = new URLSearchParams(window.location.search);
88
+ url_params = Object.fromEntries(params);
89
+ return url_params;
90
+ }
91
+ """
src/display/formatting.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import HfApi
2
+
3
+ API = HfApi()
4
+
5
+
6
+ def model_hyperlink(link, model_name):
7
+ return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
8
+
9
+
10
+ def make_clickable_model(model_name):
11
+ link = f"https://huggingface.co/{model_name}"
12
+
13
+ details_model_name = model_name.replace("/", "__")
14
+ details_link = f"https://huggingface.co/datasets/open-llm-leaderboard-old/details_{details_model_name}"
15
+
16
+ return model_hyperlink(link, model_name) + " " + model_hyperlink(details_link, "πŸ“‘")
17
+
18
+
19
+ def styled_error(error):
20
+ return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
21
+
22
+
23
+ def styled_warning(warn):
24
+ return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
25
+
26
+
27
+ def styled_message(message):
28
+ return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
29
+
30
+
31
+ def has_no_nan_values(df, columns):
32
+ return df[columns].notna().all(axis=1)
33
+
34
+
35
+ def has_nan_values(df, columns):
36
+ return df[columns].isna().any(axis=1)
src/display/utils.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass, make_dataclass
2
+ from enum import Enum
3
+ import json
4
+ import logging
5
+ from datetime import datetime
6
+ import pandas as pd
7
+
8
+
9
+ # Configure logging
10
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
11
+
12
+
13
+ def parse_datetime(datetime_str):
14
+ formats = [
15
+ "%Y-%m-%dT%H-%M-%S.%f", # Format with dashes
16
+ "%Y-%m-%dT%H:%M:%S.%f", # Standard format with colons
17
+ "%Y-%m-%dT%H %M %S.%f", # Spaces as separator
18
+ ]
19
+
20
+ for fmt in formats:
21
+ try:
22
+ return datetime.strptime(datetime_str, fmt)
23
+ except ValueError:
24
+ continue
25
+ # in rare cases set unix start time for files with incorrect time (legacy files)
26
+ logging.error(f"No valid date format found for: {datetime_str}")
27
+ return datetime(1970, 1, 1)
28
+
29
+
30
+ def load_json_data(file_path):
31
+ """Safely load JSON data from a file."""
32
+ try:
33
+ with open(file_path, "r") as file:
34
+ return json.load(file)
35
+ except json.JSONDecodeError:
36
+ print(f"Error reading JSON from {file_path}")
37
+ return None # Or raise an exception
38
+
39
+
40
+ def fields(raw_class):
41
+ return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
42
+
43
+
44
+ @dataclass
45
+ class Task:
46
+ benchmark: str
47
+ metric: str
48
+ col_name: str
49
+
50
+
51
+ class Tasks(Enum):
52
+ arc = Task("arc:challenge", "acc_norm", "ARC")
53
+ hellaswag = Task("hellaswag", "acc_norm", "HellaSwag")
54
+ mmlu = Task("hendrycksTest", "acc", "MMLU")
55
+ truthfulqa = Task("truthfulqa:mc", "mc2", "TruthfulQA")
56
+ winogrande = Task("winogrande", "acc", "Winogrande")
57
+ gsm8k = Task("gsm8k", "acc", "GSM8K")
58
+
59
+
60
+ # These classes are for user facing column names,
61
+ # to avoid having to change them all around the code
62
+ # when a modif is needed
63
+ @dataclass(frozen=True)
64
+ class ColumnContent:
65
+ name: str
66
+ type: str
67
+ displayed_by_default: bool
68
+ hidden: bool = False
69
+ never_hidden: bool = False
70
+ dummy: bool = False
71
+
72
+
73
+ auto_eval_column_dict = []
74
+ # Init
75
+ auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
76
+ auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
77
+ # Scores
78
+ auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
79
+ for task in Tasks:
80
+ auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
81
+ # Model information
82
+ auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
83
+ auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
84
+ auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
85
+ auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
86
+ auto_eval_column_dict.append(["merged", ColumnContent, ColumnContent("Merged", "bool", False)])
87
+ auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
88
+ auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
89
+ auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❀️", "number", False)])
90
+ auto_eval_column_dict.append(
91
+ ["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False, hidden=True)]
92
+ )
93
+ auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
94
+ auto_eval_column_dict.append(["not_flagged", ColumnContent, ColumnContent("Flagged", "bool", False, hidden=True)])
95
+ auto_eval_column_dict.append(["moe", ColumnContent, ColumnContent("MoE", "bool", False, hidden=True)])
96
+ auto_eval_column_dict.append(["date", ColumnContent, ColumnContent("date", "bool", False, hidden=True)])
97
+ # Dummy column for the search bar (hidden by the custom CSS)
98
+ auto_eval_column_dict.append(["fullname", ColumnContent, ColumnContent("fullname", "str", False, dummy=True)])
99
+
100
+ # We use make dataclass to dynamically fill the scores from Tasks
101
+ AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
102
+
103
+
104
+ @dataclass(frozen=True)
105
+ class EvalQueueColumn: # Queue column
106
+ model = ColumnContent("model", "markdown", True)
107
+ revision = ColumnContent("revision", "str", True)
108
+ private = ColumnContent("private", "bool", True)
109
+ precision = ColumnContent("precision", "str", True)
110
+ weight_type = ColumnContent("weight_type", "str", "Original")
111
+ status = ColumnContent("status", "str", True)
112
+
113
+
114
+ baseline_row = {
115
+ AutoEvalColumn.model.name: "<p>Baseline</p>",
116
+ AutoEvalColumn.revision.name: "N/A",
117
+ AutoEvalColumn.precision.name: None,
118
+ AutoEvalColumn.merged.name: False,
119
+ AutoEvalColumn.average.name: 31.0,
120
+ AutoEvalColumn.arc.name: 25.0,
121
+ AutoEvalColumn.hellaswag.name: 25.0,
122
+ AutoEvalColumn.mmlu.name: 25.0,
123
+ AutoEvalColumn.truthfulqa.name: 25.0,
124
+ AutoEvalColumn.winogrande.name: 50.0,
125
+ AutoEvalColumn.gsm8k.name: 0.21,
126
+ AutoEvalColumn.fullname.name: "baseline",
127
+ AutoEvalColumn.model_type.name: "",
128
+ AutoEvalColumn.not_flagged.name: False,
129
+ }
130
+
131
+ # Average ⬆️ human baseline is 0.897 (source: averaging human baselines below)
132
+ # ARC human baseline is 0.80 (source: https://lab42.global/arc/)
133
+ # HellaSwag human baseline is 0.95 (source: https://deepgram.com/learn/hellaswag-llm-benchmark-guide)
134
+ # MMLU human baseline is 0.898 (source: https://openreview.net/forum?id=d7KBjmI3GmQ)
135
+ # TruthfulQA human baseline is 0.94(source: https://arxiv.org/pdf/2109.07958.pdf)
136
+ # Winogrande: https://leaderboard.allenai.org/winogrande/submissions/public
137
+ # GSM8K: paper
138
+ # Define the human baselines
139
+ human_baseline_row = {
140
+ AutoEvalColumn.model.name: "<p>Human performance</p>",
141
+ AutoEvalColumn.revision.name: "N/A",
142
+ AutoEvalColumn.precision.name: None,
143
+ AutoEvalColumn.average.name: 92.75,
144
+ AutoEvalColumn.merged.name: False,
145
+ AutoEvalColumn.arc.name: 80.0,
146
+ AutoEvalColumn.hellaswag.name: 95.0,
147
+ AutoEvalColumn.mmlu.name: 89.8,
148
+ AutoEvalColumn.truthfulqa.name: 94.0,
149
+ AutoEvalColumn.winogrande.name: 94.0,
150
+ AutoEvalColumn.gsm8k.name: 100,
151
+ AutoEvalColumn.fullname.name: "human_baseline",
152
+ AutoEvalColumn.model_type.name: "",
153
+ AutoEvalColumn.not_flagged.name: False,
154
+ }
155
+
156
+
157
+ @dataclass
158
+ class ModelDetails:
159
+ name: str
160
+ symbol: str = "" # emoji, only for the model type
161
+
162
+
163
+ class ModelType(Enum):
164
+ PT = ModelDetails(name="🟒 pretrained", symbol="🟒")
165
+ CPT = ModelDetails(name="🟩 continuously pretrained", symbol="🟩")
166
+ FT = ModelDetails(name="πŸ”Ά fine-tuned on domain-specific datasets", symbol="πŸ”Ά")
167
+ chat = ModelDetails(name="πŸ’¬ chat models (RLHF, DPO, IFT, ...)", symbol="πŸ’¬")
168
+ merges = ModelDetails(name="🀝 base merges and moerges", symbol="🀝")
169
+ Unknown = ModelDetails(name="", symbol="?")
170
+
171
+ def to_str(self, separator=" "):
172
+ return f"{self.value.symbol}{separator}{self.value.name}"
173
+
174
+ @staticmethod
175
+ def from_str(type):
176
+ if "fine-tuned" in type or "πŸ”Ά" in type:
177
+ return ModelType.FT
178
+ if "continously pretrained" in type or "🟩" in type:
179
+ return ModelType.CPT
180
+ if "pretrained" in type or "🟒" in type:
181
+ return ModelType.PT
182
+ if any([k in type for k in ["instruction-tuned", "RL-tuned", "chat", "🟦", "β­•", "πŸ’¬"]]):
183
+ return ModelType.chat
184
+ if "merge" in type or "🀝" in type:
185
+ return ModelType.merges
186
+ return ModelType.Unknown
187
+
188
+
189
+ class WeightType(Enum):
190
+ Adapter = ModelDetails("Adapter")
191
+ Original = ModelDetails("Original")
192
+ Delta = ModelDetails("Delta")
193
+
194
+
195
+ class Precision(Enum):
196
+ float16 = ModelDetails("float16")
197
+ bfloat16 = ModelDetails("bfloat16")
198
+ qt_8bit = ModelDetails("8bit")
199
+ qt_4bit = ModelDetails("4bit")
200
+ qt_GPTQ = ModelDetails("GPTQ")
201
+ Unknown = ModelDetails("?")
202
+
203
+ def from_str(precision):
204
+ if precision in ["torch.float16", "float16"]:
205
+ return Precision.float16
206
+ if precision in ["torch.bfloat16", "bfloat16"]:
207
+ return Precision.bfloat16
208
+ if precision in ["8bit"]:
209
+ return Precision.qt_8bit
210
+ if precision in ["4bit"]:
211
+ return Precision.qt_4bit
212
+ if precision in ["GPTQ", "None"]:
213
+ return Precision.qt_GPTQ
214
+ return Precision.Unknown
215
+
216
+
217
+ # Column selection
218
+ COLS = [c.name for c in fields(AutoEvalColumn)]
219
+ TYPES = [c.type for c in fields(AutoEvalColumn)]
220
+
221
+ EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
222
+ EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
223
+
224
+ BENCHMARK_COLS = [t.value.col_name for t in Tasks]
225
+
226
+ NUMERIC_INTERVALS = {
227
+ "?": pd.Interval(-1, 0, closed="right"),
228
+ "~1.5": pd.Interval(0, 2, closed="right"),
229
+ "~3": pd.Interval(2, 4, closed="right"),
230
+ "~7": pd.Interval(4, 9, closed="right"),
231
+ "~13": pd.Interval(9, 20, closed="right"),
232
+ "~35": pd.Interval(20, 45, closed="right"),
233
+ "~60": pd.Interval(45, 70, closed="right"),
234
+ "70+": pd.Interval(70, 10000, closed="right"),
235
+ }
src/envs.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import HfApi
3
+
4
+ # clone / pull the lmeh eval data
5
+ HF_TOKEN = os.environ.get("HF_TOKEN", None)
6
+
7
+ REPO_ID = "open-llm-leaderboard-old/open_llm_leaderboard"
8
+ QUEUE_REPO = "open-llm-leaderboard-old/requests"
9
+ AGGREGATED_REPO = "open-llm-leaderboard-old/contents"
10
+
11
+ HF_HOME = os.getenv("HF_HOME", ".")
12
+
13
+ # Check HF_HOME write access
14
+ print(f"Initial HF_HOME set to: {HF_HOME}")
15
+
16
+ if not os.access(HF_HOME, os.W_OK):
17
+ print(f"No write access to HF_HOME: {HF_HOME}. Resetting to current directory.")
18
+ HF_HOME = "."
19
+ os.environ["HF_HOME"] = HF_HOME
20
+ else:
21
+ print("Write access confirmed for HF_HOME")
22
+
23
+ EVAL_REQUESTS_PATH = os.path.join(HF_HOME, "eval-queue")
24
+
25
+ # Rate limit variables
26
+ RATE_LIMIT_PERIOD = 7
27
+ RATE_LIMIT_QUOTA = 5
28
+ HAS_HIGHER_RATE_LIMIT = ["TheBloke"]
29
+
30
+ API = HfApi(token=HF_TOKEN)
src/leaderboard/filter_models.py ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from src.display.formatting import model_hyperlink
2
+ from src.display.utils import AutoEvalColumn
3
+
4
+
5
+ # Models which have been flagged by users as being problematic for a reason or another
6
+ # (Model name to forum discussion link)
7
+ FLAGGED_MODELS = {
8
+ "merged": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
9
+ "Voicelab/trurl-2-13b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/202",
10
+ "deepnight-research/llama-2-70B-inst": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/207",
11
+ "Aspik101/trurl-2-13b-pl-instruct_unload": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/213",
12
+ "Fredithefish/ReasonixPajama-3B-HF": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/236",
13
+ "TigerResearch/tigerbot-7b-sft-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/237",
14
+ "gaodrew/gaodrew-gorgonzola-13b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/215",
15
+ "AIDC-ai-business/Marcoroni-70B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/287",
16
+ "AIDC-ai-business/Marcoroni-13B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/287",
17
+ "AIDC-ai-business/Marcoroni-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/287",
18
+ "fblgit/una-xaberius-34b-v1beta": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/444",
19
+ "jan-hq/trinity-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
20
+ "rwitz2/go-bruins-v2.1.1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
21
+ "rwitz2/go-bruins-v2.1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
22
+ "GreenNode/GreenNodeLM-v3olet-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
23
+ "GreenNode/GreenNodeLM-7B-v4leo": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
24
+ "GreenNode/LeoScorpius-GreenNode-7B-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
25
+ "viethq188/LeoScorpius-7B-Chat-DPO": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
26
+ "GreenNode/GreenNodeLM-7B-v2leo": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
27
+ "janai-hq/trinity-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
28
+ "ignos/LeoScorpius-GreenNode-Alpaca-7B-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
29
+ "fblgit/una-cybertron-7b-v3-OMA": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
30
+ "mncai/mistral-7b-dpo-merge-v1.1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
31
+ "mncai/mistral-7b-dpo-v6": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
32
+ "Toten5/LeoScorpius-GreenNode-7B-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
33
+ "GreenNode/GreenNodeLM-7B-v1olet": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
34
+ "quantumaikr/quantum-dpo-v0.1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
35
+ "quantumaikr/quantum-v0.01": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
36
+ "quantumaikr/quantum-trinity-v0.1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
37
+ "mncai/mistral-7b-dpo-v5": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
38
+ "cookinai/BruinHermes": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
39
+ "jan-ai/Pandora-10.7B-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
40
+ "v1olet/v1olet_marcoroni-go-bruins-merge-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
41
+ "v1olet/v1olet_merged_dpo_7B_v3": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
42
+ "rwitz2/pee": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
43
+ "zyh3826 / GML-Mistral-merged-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/503",
44
+ "dillfrescott/trinity-medium": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/474",
45
+ "udkai/Garrulus": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/526",
46
+ "dfurman/GarrulusMarcoro-7B-v0.1": "https://huggingface.co/dfurman/GarrulusMarcoro-7B-v0.1/discussions/1",
47
+ "eren23/slerp-test-turdus-beagle": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
48
+ "abideen/NexoNimbus-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
49
+ "alnrg2arg/test2_3": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
50
+ "nfaheem/Marcoroni-7b-DPO-Merge": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
51
+ "CultriX/MergeTrix-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
52
+ "liminerity/Blur-7b-v1.21": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/548",
53
+ # Merges not indicated
54
+ "gagan3012/MetaModelv2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
55
+ "gagan3012/MetaModelv3": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
56
+ "kyujinpy/Sakura-SOLRCA-Math-Instruct-DPO-v2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
57
+ "kyujinpy/Sakura-SOLAR-Instruct-DPO-v2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
58
+ "kyujinpy/Sakura-SOLRCA-Math-Instruct-DPO-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
59
+ "kyujinpy/Sakura-SOLRCA-Instruct-DPO": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
60
+ "fblgit/LUNA-SOLARkrautLM-Instruct": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
61
+ "perlthoughts/Marcoroni-8x7B-v3-MoE": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
62
+ "rwitz/go-bruins-v2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
63
+ "rwitz/go-bruins": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
64
+ "Walmart-the-bag/Solar-10.7B-Cato": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
65
+ "aqweteddy/mistral_tv-neural-marconroni": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
66
+ "NExtNewChattingAI/shark_tank_ai_7_b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
67
+ "Q-bert/MetaMath-Cybertron": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
68
+ "OpenPipe/mistral-ft-optimized-1227": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
69
+ "perlthoughts/Falkor-7b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
70
+ "v1olet/v1olet_merged_dpo_7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
71
+ "Ba2han/BruinsV2-OpHermesNeu-11B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
72
+ "DopeorNope/You_can_cry_Snowman-13B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
73
+ "PistachioAlt/Synatra-MCS-7B-v0.3-RP-Slerp": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
74
+ "Weyaxi/MetaMath-una-cybertron-v2-bf16-Ties": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
75
+ "Weyaxi/OpenHermes-2.5-neural-chat-7b-v3-2-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
76
+ "perlthoughts/Falkor-8x7B-MoE": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
77
+ "elinas/chronos007-70b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
78
+ "Weyaxi/MetaMath-NeuralHermes-2.5-Mistral-7B-Linear": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
79
+ "Weyaxi/MetaMath-neural-chat-7b-v3-2-Ties": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
80
+ "diffnamehard/Mistral-CatMacaroni-slerp-uncensored-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
81
+ "Weyaxi/neural-chat-7b-v3-1-OpenHermes-2.5-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
82
+ "Weyaxi/MetaMath-NeuralHermes-2.5-Mistral-7B-Ties": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
83
+ "Walmart-the-bag/Misted-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
84
+ "garage-bAInd/Camel-Platypus2-70B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
85
+ "Weyaxi/OpenOrca-Zephyr-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
86
+ "uukuguy/speechless-mistral-7b-dare-0.85": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/510",
87
+ "DopeorNope/SOLARC-M-10.7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/511",
88
+ "cloudyu/Mixtral_11Bx2_MoE_19B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/511",
89
+ "DopeorNope/SOLARC-MOE-10.7Bx6 ": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/511",
90
+ "DopeorNope/SOLARC-MOE-10.7Bx4": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/511",
91
+ "gagan3012/MetaModelv2 ": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/511",
92
+ "udkai/Turdus": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
93
+ "kodonho/Solar-OrcaDPO-Solar-Instruct-SLERP": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
94
+ "kodonho/SolarM-SakuraSolar-SLERP": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
95
+ "Yhyu13/LMCocktail-10.7B-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
96
+ "mlabonne/NeuralMarcoro14-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
97
+ "Neuronovo/neuronovo-7B-v0.2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
98
+ "ryandt/MusingCaterpillar": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
99
+ "Neuronovo/neuronovo-7B-v0.3": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
100
+ "SanjiWatsuki/Lelantos-DPO-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
101
+ "bardsai/jaskier-7b-dpo": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
102
+ "cookinai/OpenCM-14": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
103
+ "bardsai/jaskier-7b-dpo-v2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
104
+ "jan-hq/supermario-v2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
105
+ # MoErges
106
+ "cloudyu/Yi-34Bx2-MoE-60B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
107
+ "cloudyu/Mixtral_34Bx2_MoE_60B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
108
+ "gagan3012/MetaModel_moe": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
109
+ "macadeliccc/SOLAR-math-2x10.7b-v0.2": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
110
+ "cloudyu/Mixtral_7Bx2_MoE": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
111
+ "macadeliccc/SOLAR-math-2x10.7b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
112
+ "macadeliccc/Orca-SOLAR-4x10.7b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
113
+ "macadeliccc/piccolo-8x7b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
114
+ "cloudyu/Mixtral_7Bx4_MOE_24B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
115
+ "macadeliccc/laser-dolphin-mixtral-2x7b-dpo": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
116
+ "macadeliccc/polyglot-math-4x7b": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/540",
117
+ # Other - contamination mostly
118
+ "DopeorNope/COKAL-v1-70B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/566",
119
+ "CultriX/MistralTrix-v1": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/556",
120
+ "Contamination/contaminated_proof_7b_v1.0": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/664",
121
+ "Contamination/contaminated_proof_7b_v1.0_safetensor": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/664",
122
+ "Ppoyaa/StarMonarch-7B": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/749",
123
+ "Gille/StrangeMerges_45-7B-dare_ties": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/749",
124
+ "berkeley-nest/Starling-LM-7B-alpha": "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/749",
125
+ }
126
+
127
+ # Models which have been requested by orgs to not be submitted on the leaderboard
128
+ DO_NOT_SUBMIT_MODELS = [
129
+ "Voicelab/trurl-2-13b", # trained on MMLU
130
+ "TigerResearch/tigerbot-70b-chat", # per authors request
131
+ "TigerResearch/tigerbot-70b-chat-v2", # per authors request
132
+ "TigerResearch/tigerbot-70b-chat-v4-4k", # per authors request
133
+ ]
134
+
135
+
136
+ def flag_models(leaderboard_data: list[dict]):
137
+ """Flags models based on external criteria or flagged status."""
138
+ for model_data in leaderboard_data:
139
+ # If a model is not flagged, use its "fullname" as a key
140
+ if model_data[AutoEvalColumn.not_flagged.name]:
141
+ flag_key = model_data[AutoEvalColumn.fullname.name]
142
+ else:
143
+ # Merges and moes are flagged
144
+ flag_key = "merged"
145
+
146
+ # Reverse the logic: Check for non-flagged models instead
147
+ if flag_key in FLAGGED_MODELS:
148
+ issue_num = FLAGGED_MODELS[flag_key].split("/")[-1]
149
+ issue_link = model_hyperlink(
150
+ FLAGGED_MODELS[flag_key],
151
+ f"See discussion #{issue_num}",
152
+ )
153
+ model_data[AutoEvalColumn.model.name] = (
154
+ f"{model_data[AutoEvalColumn.model.name]} has been flagged! {issue_link}"
155
+ )
156
+ model_data[AutoEvalColumn.not_flagged.name] = False
157
+ else:
158
+ model_data[AutoEvalColumn.not_flagged.name] = True
159
+
160
+
161
+ def remove_forbidden_models(leaderboard_data: list[dict]):
162
+ """Removes models from the leaderboard based on the DO_NOT_SUBMIT list."""
163
+ indices_to_remove = []
164
+ for ix, model in enumerate(leaderboard_data):
165
+ if model[AutoEvalColumn.fullname.name] in DO_NOT_SUBMIT_MODELS:
166
+ indices_to_remove.append(ix)
167
+
168
+ # Remove the models from the list
169
+ for ix in reversed(indices_to_remove):
170
+ leaderboard_data.pop(ix)
171
+ return leaderboard_data
172
+
173
+ """
174
+ def remove_forbidden_models(leaderboard_data):
175
+ #Removes models from the leaderboard based on the DO_NOT_SUBMIT list.
176
+ indices_to_remove = []
177
+ for ix, row in leaderboard_data.iterrows():
178
+ if row[AutoEvalColumn.fullname.name] in DO_NOT_SUBMIT_MODELS:
179
+ indices_to_remove.append(ix)
180
+
181
+ # Remove the models from the list
182
+ return leaderboard_data.drop(indices_to_remove)
183
+ """
184
+
185
+
186
+ def filter_models_flags(leaderboard_data: list[dict]):
187
+ leaderboard_data = remove_forbidden_models(leaderboard_data)
188
+ flag_models(leaderboard_data)
src/populate.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pathlib
2
+ import pandas as pd
3
+ from datasets import Dataset
4
+ from src.display.formatting import has_no_nan_values, make_clickable_model
5
+ from src.display.utils import AutoEvalColumn, EvalQueueColumn, baseline_row
6
+ from src.leaderboard.filter_models import filter_models_flags
7
+ from src.display.utils import load_json_data
8
+
9
+
10
+ def _process_model_data(entry, model_name_key="model", revision_key="revision"):
11
+ """Enrich model data with clickable links and revisions."""
12
+ entry[EvalQueueColumn.model.name] = make_clickable_model(entry.get(model_name_key, ""))
13
+ entry[EvalQueueColumn.revision.name] = entry.get(revision_key, "main")
14
+ return entry
15
+
16
+
17
+ def get_evaluation_queue_df(save_path, cols):
18
+ """Generate dataframes for pending, running, and finished evaluation entries."""
19
+ save_path = pathlib.Path(save_path)
20
+ all_evals = []
21
+
22
+ for path in save_path.rglob("*.json"):
23
+ data = load_json_data(path)
24
+ if data:
25
+ all_evals.append(_process_model_data(data))
26
+
27
+ # Organizing data by status
28
+ status_map = {
29
+ "PENDING": ["PENDING", "RERUN"],
30
+ "RUNNING": ["RUNNING"],
31
+ "FINISHED": ["FINISHED", "PENDING_NEW_EVAL"],
32
+ }
33
+ status_dfs = {status: [] for status in status_map}
34
+ for eval_data in all_evals:
35
+ for status, extra_statuses in status_map.items():
36
+ if eval_data["status"] in extra_statuses:
37
+ status_dfs[status].append(eval_data)
38
+
39
+ return tuple(pd.DataFrame(status_dfs[status], columns=cols) for status in ["FINISHED", "RUNNING", "PENDING"])
40
+
41
+
42
+ def get_leaderboard_df(leaderboard_dataset: Dataset, cols: list, benchmark_cols: list):
43
+ """Retrieve and process leaderboard data."""
44
+ all_data_json = leaderboard_dataset.to_dict()
45
+ num_items = leaderboard_dataset.num_rows
46
+ all_data_json_list = [{k: all_data_json[k][ix] for k in all_data_json.keys()} for ix in range(num_items)]
47
+ filter_models_flags(all_data_json_list)
48
+
49
+ df = pd.DataFrame.from_records(all_data_json_list)
50
+ df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
51
+ df = df[cols].round(decimals=2)
52
+ df = df[has_no_nan_values(df, benchmark_cols)]
53
+ return df
src/submission/check_validity.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, get_safetensors_metadata
10
+ from transformers import AutoConfig, AutoTokenizer
11
+
12
+ from src.envs import HAS_HIGHER_RATE_LIMIT
13
+
14
+
15
+ # ht to @Wauplin, thank you for the snippet!
16
+ # See https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard/discussions/317
17
+ def check_model_card(repo_id: str) -> tuple[bool, str]:
18
+ # Returns operation status, and error message
19
+ try:
20
+ card = ModelCard.load(repo_id)
21
+ except huggingface_hub.utils.EntryNotFoundError:
22
+ return False, "Please add a model card to your model to explain how you trained/fine-tuned it.", None
23
+
24
+ # Enforce license metadata
25
+ if card.data.license is None:
26
+ if not ("license_name" in card.data and "license_link" in card.data):
27
+ return (
28
+ False,
29
+ (
30
+ "License not found. Please add a license to your model card using the `license` metadata or a"
31
+ " `license_name`/`license_link` pair."
32
+ ),
33
+ None,
34
+ )
35
+
36
+ # Enforce card content
37
+ if len(card.text) < 200:
38
+ return False, "Please add a description to your model card, it is too short.", None
39
+
40
+ return True, "", card
41
+
42
+
43
+ def is_model_on_hub(
44
+ model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False
45
+ ) -> tuple[bool, str, AutoConfig]:
46
+ try:
47
+ config = AutoConfig.from_pretrained(
48
+ model_name, revision=revision, trust_remote_code=trust_remote_code, token=token
49
+ ) # , force_download=True)
50
+ if test_tokenizer:
51
+ try:
52
+ tk = AutoTokenizer.from_pretrained(
53
+ model_name, revision=revision, trust_remote_code=trust_remote_code, token=token
54
+ )
55
+ except ValueError as e:
56
+ return (False, f"uses a tokenizer which is not in a transformers release: {e}", None)
57
+ except Exception:
58
+ return (
59
+ False,
60
+ "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?",
61
+ None,
62
+ )
63
+ return True, None, config
64
+
65
+ except ValueError:
66
+ return (
67
+ False,
68
+ "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.",
69
+ None,
70
+ )
71
+
72
+ except Exception as e:
73
+ if "You are trying to access a gated repo." in str(e):
74
+ return True, "uses a gated model.", None
75
+ return False, f"was not found or misconfigured on the hub! Error raised was {e.args[0]}", None
76
+
77
+
78
+ def get_model_size(model_info: ModelInfo, precision: str):
79
+ size_pattern = re.compile(r"(\d+\.)?\d+(b|m)")
80
+ safetensors = None
81
+ try:
82
+ safetensors = get_safetensors_metadata(model_info.id)
83
+ except Exception as e:
84
+ print(e)
85
+
86
+ if safetensors is not None:
87
+ model_size = round(sum(safetensors.parameter_count.values()) / 1e9, 3)
88
+ else:
89
+ try:
90
+ size_match = re.search(size_pattern, model_info.id.lower())
91
+ model_size = size_match.group(0)
92
+ model_size = round(float(model_size[:-1]) if model_size[-1] == "b" else float(model_size[:-1]) / 1e3, 3)
93
+ except AttributeError:
94
+ return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
95
+
96
+ size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.id.lower()) else 1
97
+ model_size = size_factor * model_size
98
+ return model_size
99
+
100
+
101
+ def get_model_arch(model_info: ModelInfo):
102
+ return model_info.config.get("architectures", "Unknown")
103
+
104
+
105
+ def user_submission_permission(org_or_user, users_to_submission_dates, rate_limit_period, rate_limit_quota):
106
+ if org_or_user not in users_to_submission_dates:
107
+ return True, ""
108
+ submission_dates = sorted(users_to_submission_dates[org_or_user])
109
+
110
+ time_limit = (datetime.now(timezone.utc) - timedelta(days=rate_limit_period)).strftime("%Y-%m-%dT%H:%M:%SZ")
111
+ submissions_after_timelimit = [d for d in submission_dates if d > time_limit]
112
+
113
+ num_models_submitted_in_period = len(submissions_after_timelimit)
114
+ if org_or_user in HAS_HIGHER_RATE_LIMIT:
115
+ rate_limit_quota = 2 * rate_limit_quota
116
+
117
+ if num_models_submitted_in_period > rate_limit_quota:
118
+ error_msg = f"Organisation or user `{org_or_user}`"
119
+ error_msg += f"already has {num_models_submitted_in_period} model requests submitted to the leaderboard "
120
+ error_msg += f"in the last {rate_limit_period} days.\n"
121
+ error_msg += (
122
+ "Please wait a couple of days before resubmitting, so that everybody can enjoy using the leaderboard πŸ€—"
123
+ )
124
+ return False, error_msg
125
+ return True, ""
126
+
127
+
128
+ def already_submitted_models(requested_models_dir: str) -> set[str]:
129
+ depth = 1
130
+ file_names = []
131
+ users_to_submission_dates = defaultdict(list)
132
+
133
+ for root, _, files in os.walk(requested_models_dir):
134
+ current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
135
+ if current_depth == depth:
136
+ for file in files:
137
+ if not file.endswith(".json"):
138
+ continue
139
+ with open(os.path.join(root, file), "r") as f:
140
+ info = json.load(f)
141
+ file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
142
+
143
+ # Select organisation
144
+ if info["model"].count("/") == 0 or "submitted_time" not in info:
145
+ continue
146
+ organisation, _ = info["model"].split("/")
147
+ users_to_submission_dates[organisation].append(info["submitted_time"])
148
+
149
+ return set(file_names), users_to_submission_dates
150
+
151
+
152
+ def get_model_tags(model_card, model: str):
153
+ is_merge_from_metadata = False
154
+ is_moe_from_metadata = False
155
+
156
+ tags = []
157
+ if model_card is None:
158
+ return tags
159
+ if model_card.data.tags:
160
+ is_merge_from_metadata = any(
161
+ [tag in model_card.data.tags for tag in ["merge", "moerge", "mergekit", "lazymergekit"]]
162
+ )
163
+ is_moe_from_metadata = any([tag in model_card.data.tags for tag in ["moe", "moerge"]])
164
+
165
+ is_merge_from_model_card = any(
166
+ keyword in model_card.text.lower() for keyword in ["merged model", "merge model", "moerge"]
167
+ )
168
+ if is_merge_from_model_card or is_merge_from_metadata:
169
+ tags.append("merge")
170
+ is_moe_from_model_card = any(keyword in model_card.text.lower() for keyword in ["moe", "mixtral"])
171
+ # Hardcoding because of gating problem
172
+ if "Qwen/Qwen1.5-32B" in model:
173
+ is_moe_from_model_card = False
174
+ is_moe_from_name = "moe" in model.lower().replace("/", "-").replace("_", "-").split("-")
175
+ if is_moe_from_model_card or is_moe_from_name or is_moe_from_metadata:
176
+ tags.append("moe")
177
+
178
+ return tags
src/tools/plots.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import plotly.express as px
4
+ from plotly.graph_objs import Figure
5
+
6
+ from src.display.utils import BENCHMARK_COLS, AutoEvalColumn, Task, Tasks
7
+ from src.display.utils import human_baseline_row as HUMAN_BASELINE
8
+ from src.leaderboard.filter_models import FLAGGED_MODELS
9
+
10
+
11
+ def create_scores_df(results_df: list[dict]) -> pd.DataFrame:
12
+ """
13
+ Generates a DataFrame containing the maximum scores until each date.
14
+
15
+ :param results_df: A DataFrame containing result information including metric scores and dates.
16
+ :return: A new DataFrame containing the maximum scores until each date for every metric.
17
+ """
18
+ # Step 1: Ensure 'date' is in datetime format and sort the DataFrame by it
19
+ results_df["date"] = pd.to_datetime(results_df["date"], format="mixed", utc=True)
20
+ results_df.sort_values(by="date", inplace=True)
21
+
22
+ # Step 2: Initialize the scores dictionary
23
+ scores = {k: [] for k in BENCHMARK_COLS + [AutoEvalColumn.average.name]}
24
+
25
+ # Step 3: Iterate over the rows of the DataFrame and update the scores dictionary
26
+ for task in [t.value for t in Tasks] + [Task("Average", "avg", AutoEvalColumn.average.name)]:
27
+ current_max = 0
28
+ last_date = ""
29
+ column = task.col_name
30
+ for _, row in results_df.iterrows():
31
+ current_model = row[AutoEvalColumn.fullname.name]
32
+ # We ignore models that are flagged/no longer on the hub/not finished
33
+ to_ignore = (
34
+ not row[AutoEvalColumn.still_on_hub.name]
35
+ or not row[AutoEvalColumn.not_flagged.name]
36
+ or current_model in FLAGGED_MODELS
37
+ )
38
+ if to_ignore:
39
+ continue
40
+
41
+ current_date = row[AutoEvalColumn.date.name]
42
+ current_score = row[task.col_name]
43
+
44
+ if current_score > current_max:
45
+ if current_date == last_date and len(scores[column]) > 0:
46
+ scores[column][-1] = {"model": current_model, "date": current_date, "score": current_score}
47
+ else:
48
+ scores[column].append({"model": current_model, "date": current_date, "score": current_score})
49
+ current_max = current_score
50
+ last_date = current_date
51
+
52
+ # Step 4: Return all dictionaries as DataFrames
53
+ return {k: pd.DataFrame(v) for k, v in scores.items()}
54
+
55
+
56
+ def create_plot_df(scores_df: dict[str : pd.DataFrame]) -> pd.DataFrame:
57
+ """
58
+ Transforms the scores DataFrame into a new format suitable for plotting.
59
+
60
+ :param scores_df: A DataFrame containing metric scores and dates.
61
+ :return: A new DataFrame reshaped for plotting purposes.
62
+ """
63
+ # Initialize the list to store DataFrames
64
+ dfs = []
65
+ # Iterate over the cols and create a new DataFrame for each column
66
+ for col in BENCHMARK_COLS + [AutoEvalColumn.average.name]:
67
+ d = scores_df[col].reset_index(drop=True)
68
+ d["task"] = col
69
+ dfs.append(d)
70
+
71
+ # Concatenate all the created DataFrames
72
+ concat_df = pd.concat(dfs, ignore_index=True)
73
+
74
+ # Sort values by 'date'
75
+ concat_df.sort_values(by="date", inplace=True)
76
+ concat_df.reset_index(drop=True, inplace=True)
77
+ return concat_df
78
+
79
+
80
+ def create_metric_plot_obj(df: pd.DataFrame, metrics: list[str], title: str) -> Figure:
81
+ """
82
+ Create a Plotly figure object with lines representing different metrics
83
+ and horizontal dotted lines representing human baselines.
84
+
85
+ :param df: The DataFrame containing the metric values, names, and dates.
86
+ :param metrics: A list of strings representing the names of the metrics
87
+ to be included in the plot.
88
+ :param title: A string representing the title of the plot.
89
+ :return: A Plotly figure object with lines representing metrics and
90
+ horizontal dotted lines representing human baselines.
91
+ """
92
+
93
+ # Filter the DataFrame based on the specified metrics
94
+ df = df[df["task"].isin(metrics)]
95
+
96
+ # Filter the human baselines based on the specified metrics
97
+ filtered_human_baselines = {k: v for k, v in HUMAN_BASELINE.items() if k in metrics}
98
+
99
+ # Create a line figure using plotly express with specified markers and custom data
100
+ fig = px.line(
101
+ df,
102
+ x="date",
103
+ y="score",
104
+ color="task",
105
+ markers=True,
106
+ custom_data=["task", "score", "model"],
107
+ title=title,
108
+ )
109
+
110
+ # Update hovertemplate for better hover interaction experience
111
+ fig.update_traces(
112
+ hovertemplate="<br>".join(
113
+ [
114
+ "Model Name: %{customdata[2]}",
115
+ "Metric Name: %{customdata[0]}",
116
+ "Date: %{x}",
117
+ "Metric Value: %{y}",
118
+ ]
119
+ )
120
+ )
121
+
122
+ # Update the range of the y-axis
123
+ fig.update_layout(yaxis_range=[0, 100])
124
+
125
+ # Create a dictionary to hold the color mapping for each metric
126
+ metric_color_mapping = {}
127
+
128
+ # Map each metric name to its color in the figure
129
+ for trace in fig.data:
130
+ metric_color_mapping[trace.name] = trace.line.color
131
+
132
+ # Iterate over filtered human baselines and add horizontal lines to the figure
133
+ for metric, value in filtered_human_baselines.items():
134
+ color = metric_color_mapping.get(metric, "blue") # Retrieve color from mapping; default to blue if not found
135
+ location = "top left" if metric == "HellaSwag" else "bottom left" # Set annotation position
136
+ # Add horizontal line with matched color and positioned annotation
137
+ fig.add_hline(
138
+ y=value,
139
+ line_dash="dot",
140
+ annotation_text=f"{metric} human baseline",
141
+ annotation_position=location,
142
+ annotation_font_size=10,
143
+ annotation_font_color=color,
144
+ line_color=color,
145
+ )
146
+
147
+ return fig
148
+
149
+
150
+ # Example Usage:
151
+ # human_baselines dictionary is defined.
152
+ # chart = create_metric_plot_obj(scores_df, ["ARC", "HellaSwag", "MMLU", "TruthfulQA"], human_baselines, "Graph Title")