Drop the unused gold_gamed config; say what the benchmark is for, with PyBot's progress chart
Browse filesNo eval or leaderboard run used gold_gamed: the eval pins `gold` at dbda1eaf, before gold_gamed existed. It stays recoverable at 0dd39c80. The card body comes from create_dataset.py's card(), updated to match.
- README.md +33 -91
- gold_gamed/test-00000-of-00001.parquet → assets/progress.png +2 -2
- scripts/create_dataset.py +34 -4
- scripts/create_gold_gamed.py +0 -312
README.md
CHANGED
|
@@ -28,50 +28,12 @@ dataset_info:
|
|
| 28 |
num_examples: 1000
|
| 29 |
download_size: 176482
|
| 30 |
dataset_size: 427543
|
| 31 |
-
- config_name: gold_gamed
|
| 32 |
-
features:
|
| 33 |
-
- name: id
|
| 34 |
-
dtype: string
|
| 35 |
-
- name: instruction
|
| 36 |
-
dtype: string
|
| 37 |
-
- name: variant
|
| 38 |
-
dtype: string
|
| 39 |
-
- name: system_prompt
|
| 40 |
-
dtype: string
|
| 41 |
-
- name: output
|
| 42 |
-
dtype: string
|
| 43 |
-
- name: generator
|
| 44 |
-
dtype: string
|
| 45 |
-
- name: finish_reason
|
| 46 |
-
dtype: string
|
| 47 |
-
- name: output_length
|
| 48 |
-
dtype: int64
|
| 49 |
-
- name: reference_length
|
| 50 |
-
dtype: int64
|
| 51 |
-
- name: switched
|
| 52 |
-
dtype: bool
|
| 53 |
-
- name: preference
|
| 54 |
-
dtype: float64
|
| 55 |
-
- name: judge
|
| 56 |
-
dtype: string
|
| 57 |
-
- name: judge_top_logprobs
|
| 58 |
-
dtype: string
|
| 59 |
-
splits:
|
| 60 |
-
- name: test
|
| 61 |
-
num_bytes: 5534164
|
| 62 |
-
num_examples: 4000
|
| 63 |
-
download_size: 2357171
|
| 64 |
-
dataset_size: 5534164
|
| 65 |
configs:
|
| 66 |
- config_name: gold
|
| 67 |
data_files:
|
| 68 |
- split: test
|
| 69 |
path: gold/test-*
|
| 70 |
default: true
|
| 71 |
-
- config_name: gold_gamed
|
| 72 |
-
data_files:
|
| 73 |
-
- split: test
|
| 74 |
-
path: gold_gamed/test-*
|
| 75 |
language:
|
| 76 |
- en
|
| 77 |
license: apache-2.0
|
|
@@ -84,11 +46,9 @@ tags:
|
|
| 84 |
| subset | description | num_samples |
|
| 85 |
| --- | --- | ---: |
|
| 86 |
| `gold` (default) | Single-turn everyday chat prompts from smoltalk's `everyday-conversations`, sampled in proportion to their parent topic, with the source conversations' replies by `meta-llama/Meta-Llama-3.1-70B-Instruct` as references | 1000 |
|
| 87 |
-
| `gold_gamed` | Gamed baselines for the length-controlled win rate: `meta-llama/Llama-3.1-70B-Instruct` told to answer in a few words, in one sentence, concisely or in detail, judged against `gold` | 4000 |
|
| 88 |
|
| 89 |
1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
|
| 90 |
-
win rates.
|
| 91 |
-
(`cmpatino/chatbot-swarm`) at different commits, and small LMs, against one fixed reference.
|
| 92 |
|
| 93 |
```python
|
| 94 |
from datasets import load_dataset
|
|
@@ -99,6 +59,36 @@ ds = load_dataset("HuggingFaceSwarms/SmolTalkBench", "gold", split="test")
|
|
| 99 |
Variants with other reference models go in their own configs, keeping the same `id`s and
|
| 100 |
instructions so that results compare across them.
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
## Construction
|
| 103 |
|
| 104 |
- Source: the `everyday-conversations` subset of [`HuggingFaceTB/smoltalk`](https://huggingface.co/datasets/HuggingFaceTB/smoltalk)
|
|
@@ -124,46 +114,6 @@ instructions so that results compare across them.
|
|
| 124 |
| `group` | `everyday` (three-level topics) or `school` (two-level grade-school knowledge topics) |
|
| 125 |
| `source_split`, `source_index` | the row in the source subset |
|
| 126 |
|
| 127 |
-
Note that SmolLM and SmolLM2 Instruct models were trained on the source conversations.
|
| 128 |
-
|
| 129 |
-
## The `gold_gamed` config
|
| 130 |
-
|
| 131 |
-
The gamed baselines of AlpacaEval's `length_controlled_v1` GLM (its `df_gamed.csv`), for the
|
| 132 |
-
`gold` references: their model, [`meta-llama/Llama-3.1-70B-Instruct`](https://huggingface.co/meta-llama/Llama-3.1-70B-Instruct),
|
| 133 |
-
answers each instruction once per variant under a system prompt that asks for a length, and
|
| 134 |
-
each reply is judged against the gold reference. Fitted alongside a model's judgements, without
|
| 135 |
-
an intercept and at a total weight of 0.2 per instruction, they set how much length alone moves
|
| 136 |
-
the judge. The length-controlled win rate then can't put all of a model's losses down to length.
|
| 137 |
-
|
| 138 |
-
| variant | system prompt | median words | win rate vs `gold` (%) |
|
| 139 |
-
|---|---|---:|---:|
|
| 140 |
-
| `terse` | You are a helpful assistant. Answer in as few words as possible. | 7 | 9.8 |
|
| 141 |
-
| `brief` | You are a helpful assistant. Answer in one short sentence. | 20 | 46.3 |
|
| 142 |
-
| `concise` | You are a helpful assistant. Be as concise as possible while still providing all the necessary information to answer the question. | 104 | 96.4 |
|
| 143 |
-
| `verbose` | You are a helpful assistant. Always answer with as much detail as possible. | 456 | 98.3 |
|
| 144 |
-
|
| 145 |
-
The `gold` references have a median of 24 words. The concise and
|
| 146 |
-
verbose prompts are AlpacaEval's; `terse` and `brief` cover replies as short as the
|
| 147 |
-
references and shorter. Each reply
|
| 148 |
-
is the model's answer to the instruction as a single user turn, sampled with its
|
| 149 |
-
`generation_config` (vLLM 0.32.0, seed 0, at most 4096 tokens).
|
| 150 |
-
|
| 151 |
-
- **The judge** is `hf-inference-providers/deepseek-ai/DeepSeek-V4.1-Flash:fireworks-ai`, with the eval's settings: AlpacaEval 2.0's weighted annotator
|
| 152 |
-
prompt, the reply and the reference swapped as AlpacaEval does, one token at temperature 1,
|
| 153 |
-
and the preference read from its top-5 logprobs. The preferences only calibrate evals by the
|
| 154 |
-
same judge.
|
| 155 |
-
|
| 156 |
-
| column | description |
|
| 157 |
-
|---|---|
|
| 158 |
-
| `id`, `instruction` | the `gold` row |
|
| 159 |
-
| `variant`, `system_prompt` | which gamed baseline, and its system prompt |
|
| 160 |
-
| `output` | the reply |
|
| 161 |
-
| `generator`, `finish_reason` | the model, and why its reply ended (`length` when truncated) |
|
| 162 |
-
| `output_length`, `reference_length` | the reply's and the `gold` reference's length in characters |
|
| 163 |
-
| `switched` | whether the reply was shown to the judge first |
|
| 164 |
-
| `preference` | 1 when the reference wins, 2 when the reply does, NaN when the judge named neither |
|
| 165 |
-
| `judge`, `judge_top_logprobs` | the judge, and the top-5 logprobs of its one token (JSON) |
|
| 166 |
-
|
| 167 |
## Reproducing
|
| 168 |
|
| 169 |
[`scripts/create_dataset.py`](scripts/create_dataset.py) builds the `gold` config and pushes it with this card and itself:
|
|
@@ -174,13 +124,5 @@ uv run scripts/create_dataset.py --n 1000 --seed 0 \
|
|
| 174 |
--source_revision 5feaf2fd3ffca7c237fc38d1861bc30365d48ffa --repo HuggingFaceSwarms/SmolTalkBench --push
|
| 175 |
```
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
```sh
|
| 181 |
-
hf download HuggingFaceSwarms/SmolTalkBench scripts/create_gold_gamed.py --repo-type dataset --local-dir .
|
| 182 |
-
hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \
|
| 183 |
-
--timeout 4h scripts/create_gold_gamed.py \
|
| 184 |
-
--gold_revision dbda1eaf1e9839f51e7ef073783dacd226d7ebfb --generator_revision 1605565b47bb9346c5515c34102e054115b4f98b \
|
| 185 |
-
--repo HuggingFaceSwarms/SmolTalkBench --push
|
| 186 |
-
```
|
|
|
|
| 28 |
num_examples: 1000
|
| 29 |
download_size: 176482
|
| 30 |
dataset_size: 427543
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
configs:
|
| 32 |
- config_name: gold
|
| 33 |
data_files:
|
| 34 |
- split: test
|
| 35 |
path: gold/test-*
|
| 36 |
default: true
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
language:
|
| 38 |
- en
|
| 39 |
license: apache-2.0
|
|
|
|
| 46 |
| subset | description | num_samples |
|
| 47 |
| --- | --- | ---: |
|
| 48 |
| `gold` (default) | Single-turn everyday chat prompts from smoltalk's `everyday-conversations`, sampled in proportion to their parent topic, with the source conversations' replies by `meta-llama/Meta-Llama-3.1-70B-Instruct` as references | 1000 |
|
|
|
|
| 49 |
|
| 50 |
1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
|
| 51 |
+
win rates.
|
|
|
|
| 52 |
|
| 53 |
```python
|
| 54 |
from datasets import load_dataset
|
|
|
|
| 59 |
Variants with other reference models go in their own configs, keeping the same `id`s and
|
| 60 |
instructions so that results compare across them.
|
| 61 |
|
| 62 |
+
## What it's for
|
| 63 |
+
|
| 64 |
+
SmolTalkBench is the benchmark behind the
|
| 65 |
+
[SwarmChat leaderboard](https://huggingface.co/spaces/HuggingFaceSwarms/swarmchat-leaderboard).
|
| 66 |
+
Swarms of agents write chatbots entirely in Python, with no weights or training, just rules,
|
| 67 |
+
patterns and lookup tables, in the [SwarmChat](https://huggingface.co/collections/HuggingFaceSwarms/swarmchat)
|
| 68 |
+
repos. Every commit of their bot is scored on SmolTalkBench, next to small instruction-tuned
|
| 69 |
+
LMs, against the same fixed references. The best of these bots is
|
| 70 |
+
[PyBot](https://github.com/huggingface/pybot): its win rate climbed from 0% to 26% over more
|
| 71 |
+
than 6,000 commits, on par with SmolLM-360M-Instruct.
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
|
| 75 |
+
SmolLM and SmolLM2 Instruct models were trained on the source conversations, so the SmolLM
|
| 76 |
+
baselines' scores are inflated.
|
| 77 |
+
|
| 78 |
+
## How it's scored
|
| 79 |
+
|
| 80 |
+
The eval is the Inspect task `smoltalk_bench_gold` in flock's `experiments/run4/eval`, which
|
| 81 |
+
pins this dataset's `gold` config to a fixed revision.
|
| 82 |
+
|
| 83 |
+
- The model answers each `instruction` once, as a single user turn.
|
| 84 |
+
- An LLM judge (`deepseek-ai/DeepSeek-V4.1-Flash`, with AlpacaEval 2.0's weighted annotator
|
| 85 |
+
prompt) compares the reply with the reference `output`. Which one it sees first is fixed per
|
| 86 |
+
prompt, as in AlpacaEval. A sample's score is the judge's probability that the reply is
|
| 87 |
+
better, read from its top-5 logprobs.
|
| 88 |
+
- The leaderboard ranks by the length-penalised win rate: the mean score, where a reply more
|
| 89 |
+
than 500 characters longer than its reference counts as a tie at most (WildBench's length
|
| 90 |
+
penalty).
|
| 91 |
+
|
| 92 |
## Construction
|
| 93 |
|
| 94 |
- Source: the `everyday-conversations` subset of [`HuggingFaceTB/smoltalk`](https://huggingface.co/datasets/HuggingFaceTB/smoltalk)
|
|
|
|
| 114 |
| `group` | `everyday` (three-level topics) or `school` (two-level grade-school knowledge topics) |
|
| 115 |
| `source_split`, `source_index` | the row in the source subset |
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
## Reproducing
|
| 118 |
|
| 119 |
[`scripts/create_dataset.py`](scripts/create_dataset.py) builds the `gold` config and pushes it with this card and itself:
|
|
|
|
| 124 |
--source_revision 5feaf2fd3ffca7c237fc38d1861bc30365d48ffa --repo HuggingFaceSwarms/SmolTalkBench --push
|
| 125 |
```
|
| 126 |
|
| 127 |
+
The chart in `assets/progress.png` is not built by this script: it plots the PyBot Space's
|
| 128 |
+
progress data, which comes from the leaderboard's results.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gold_gamed/test-00000-of-00001.parquet → assets/progress.png
RENAMED
|
File without changes
|
scripts/create_dataset.py
CHANGED
|
@@ -84,8 +84,7 @@ def card(args, total):
|
|
| 84 |
| `{CONFIG}` (default) | Single-turn everyday chat prompts from smoltalk's `{SUBSET}`, sampled in proportion to their parent topic, with the source conversations' replies by `{GENERATOR}` as references | {args.n} |
|
| 85 |
|
| 86 |
{args.n} single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
|
| 87 |
-
win rates.
|
| 88 |
-
(`cmpatino/chatbot-swarm`) at different commits, and small LMs, against one fixed reference.
|
| 89 |
|
| 90 |
```python
|
| 91 |
from datasets import load_dataset
|
|
@@ -96,6 +95,36 @@ ds = load_dataset("{args.repo}", "{CONFIG}", split="test")
|
|
| 96 |
Variants with other reference models go in their own configs, keeping the same `id`s and
|
| 97 |
instructions so that results compare across them.
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
## Construction
|
| 100 |
|
| 101 |
- Source: the `{SUBSET}` subset of [`{SOURCE}`](https://huggingface.co/datasets/{SOURCE})
|
|
@@ -121,8 +150,6 @@ instructions so that results compare across them.
|
|
| 121 |
| `group` | `everyday` (three-level topics) or `school` (two-level grade-school knowledge topics) |
|
| 122 |
| `source_split`, `source_index` | the row in the source subset |
|
| 123 |
|
| 124 |
-
Note that SmolLM and SmolLM2 Instruct models were trained on the source conversations.
|
| 125 |
-
|
| 126 |
## Reproducing
|
| 127 |
|
| 128 |
[`{SCRIPT}`]({SCRIPT}) builds the `{CONFIG}` config and pushes it with this card and itself:
|
|
@@ -132,6 +159,9 @@ hf download {args.repo} {SCRIPT} --repo-type dataset --local-dir .
|
|
| 132 |
uv run {SCRIPT} --n {args.n} --seed {args.seed} \\
|
| 133 |
--source_revision {args.source_revision} --repo {args.repo} --push{public}
|
| 134 |
```
|
|
|
|
|
|
|
|
|
|
| 135 |
"""
|
| 136 |
|
| 137 |
|
|
|
|
| 84 |
| `{CONFIG}` (default) | Single-turn everyday chat prompts from smoltalk's `{SUBSET}`, sampled in proportion to their parent topic, with the source conversations' replies by `{GENERATOR}` as references | {args.n} |
|
| 85 |
|
| 86 |
{args.n} single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
|
| 87 |
+
win rates.
|
|
|
|
| 88 |
|
| 89 |
```python
|
| 90 |
from datasets import load_dataset
|
|
|
|
| 95 |
Variants with other reference models go in their own configs, keeping the same `id`s and
|
| 96 |
instructions so that results compare across them.
|
| 97 |
|
| 98 |
+
## What it's for
|
| 99 |
+
|
| 100 |
+
SmolTalkBench is the benchmark behind the
|
| 101 |
+
[SwarmChat leaderboard](https://huggingface.co/spaces/HuggingFaceSwarms/swarmchat-leaderboard).
|
| 102 |
+
Swarms of agents write chatbots entirely in Python, with no weights or training, just rules,
|
| 103 |
+
patterns and lookup tables, in the [SwarmChat](https://huggingface.co/collections/HuggingFaceSwarms/swarmchat)
|
| 104 |
+
repos. Every commit of their bot is scored on SmolTalkBench, next to small instruction-tuned
|
| 105 |
+
LMs, against the same fixed references. The best of these bots is
|
| 106 |
+
[PyBot](https://github.com/huggingface/pybot): its win rate climbed from 0% to 26% over more
|
| 107 |
+
than 6,000 commits, on par with SmolLM-360M-Instruct.
|
| 108 |
+
|
| 109 |
+

|
| 110 |
+
|
| 111 |
+
SmolLM and SmolLM2 Instruct models were trained on the source conversations, so the SmolLM
|
| 112 |
+
baselines' scores are inflated.
|
| 113 |
+
|
| 114 |
+
## How it's scored
|
| 115 |
+
|
| 116 |
+
The eval is the Inspect task `smoltalk_bench_gold` in flock's `experiments/run4/eval`, which
|
| 117 |
+
pins this dataset's `{CONFIG}` config to a fixed revision.
|
| 118 |
+
|
| 119 |
+
- The model answers each `instruction` once, as a single user turn.
|
| 120 |
+
- An LLM judge (`deepseek-ai/DeepSeek-V4.1-Flash`, with AlpacaEval 2.0's weighted annotator
|
| 121 |
+
prompt) compares the reply with the reference `output`. Which one it sees first is fixed per
|
| 122 |
+
prompt, as in AlpacaEval. A sample's score is the judge's probability that the reply is
|
| 123 |
+
better, read from its top-5 logprobs.
|
| 124 |
+
- The leaderboard ranks by the length-penalised win rate: the mean score, where a reply more
|
| 125 |
+
than 500 characters longer than its reference counts as a tie at most (WildBench's length
|
| 126 |
+
penalty).
|
| 127 |
+
|
| 128 |
## Construction
|
| 129 |
|
| 130 |
- Source: the `{SUBSET}` subset of [`{SOURCE}`](https://huggingface.co/datasets/{SOURCE})
|
|
|
|
| 150 |
| `group` | `everyday` (three-level topics) or `school` (two-level grade-school knowledge topics) |
|
| 151 |
| `source_split`, `source_index` | the row in the source subset |
|
| 152 |
|
|
|
|
|
|
|
| 153 |
## Reproducing
|
| 154 |
|
| 155 |
[`{SCRIPT}`]({SCRIPT}) builds the `{CONFIG}` config and pushes it with this card and itself:
|
|
|
|
| 159 |
uv run {SCRIPT} --n {args.n} --seed {args.seed} \\
|
| 160 |
--source_revision {args.source_revision} --repo {args.repo} --push{public}
|
| 161 |
```
|
| 162 |
+
|
| 163 |
+
The chart in `assets/progress.png` is not built by this script: it plots the PyBot Space's
|
| 164 |
+
progress data, which comes from the leaderboard's results.
|
| 165 |
"""
|
| 166 |
|
| 167 |
|
scripts/create_gold_gamed.py
DELETED
|
@@ -1,312 +0,0 @@
|
|
| 1 |
-
# /// script
|
| 2 |
-
# requires-python = ">=3.12"
|
| 3 |
-
# dependencies = ["vllm==0.32.0", "inspect-ai==0.3.286", "openai", "datasets>=3.0",
|
| 4 |
-
# "huggingface_hub>=0.30"]
|
| 5 |
-
# ///
|
| 6 |
-
"""Build SmolTalkBench's `gold_gamed` config: the gold references' model told to answer in a
|
| 7 |
-
few words, in one sentence, concisely or in detail, each reply judged against the gold
|
| 8 |
-
reference. These are the gamed baselines that calibrate the length-controlled win rate, as
|
| 9 |
-
AlpacaEval's `df_gamed.csv` does for its `length_controlled_v1` GLM.
|
| 10 |
-
|
| 11 |
-
uv run scripts/create_gold_gamed.py --limit 20 # smoke test, needs a GPU
|
| 12 |
-
hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \
|
| 13 |
-
scripts/create_gold_gamed.py --push
|
| 14 |
-
|
| 15 |
-
The model answers each gold instruction once per variant, as a single user turn under the
|
| 16 |
-
variant's system prompt: AlpacaEval's concise and verbose prompts, which come out longer than
|
| 17 |
-
the references, and two prompts for replies as short as them and shorter. It samples with its
|
| 18 |
-
generation_config, through vLLM.
|
| 19 |
-
The judge and its settings are the eval's (flock's experiments/run4/eval/smoltalk_bench.py):
|
| 20 |
-
AlpacaEval 2.0's weighted annotator prompt, the reference and the reply swapped as AlpacaEval
|
| 21 |
-
does, and the preference read from the top-5 logprobs of the judge's one token. Run it after
|
| 22 |
-
create_dataset.py, which rewrites the card. vLLM's image has the CUDA toolkit that its
|
| 23 |
-
two-GPU all-reduce compiles kernels with.
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
import argparse
|
| 27 |
-
import asyncio
|
| 28 |
-
import json
|
| 29 |
-
import math
|
| 30 |
-
import random
|
| 31 |
-
import statistics
|
| 32 |
-
from pathlib import Path
|
| 33 |
-
|
| 34 |
-
from datasets import Dataset, load_dataset
|
| 35 |
-
from huggingface_hub import CommitOperationAdd, DatasetCard, HfApi
|
| 36 |
-
|
| 37 |
-
REPO = "HuggingFaceSwarms/SmolTalkBench"
|
| 38 |
-
GOLD = "gold"
|
| 39 |
-
GOLD_REVISION = "dbda1eaf1e9839f51e7ef073783dacd226d7ebfb"
|
| 40 |
-
CONFIG = "gold_gamed"
|
| 41 |
-
SCRIPT = "scripts/create_gold_gamed.py"
|
| 42 |
-
GENERATOR = "meta-llama/Llama-3.1-70B-Instruct"
|
| 43 |
-
GENERATOR_REVISION = "1605565b47bb9346c5515c34102e054115b4f98b"
|
| 44 |
-
JUDGE = "hf-inference-providers/deepseek-ai/DeepSeek-V4.1-Flash:fireworks-ai"
|
| 45 |
-
# AlpacaEval's concise and verbose prompts (models_configs/gpt4_1106_preview_*), and two for
|
| 46 |
-
# the short end
|
| 47 |
-
VARIANTS = {
|
| 48 |
-
"terse": "You are a helpful assistant. Answer in as few words as possible.",
|
| 49 |
-
"brief": "You are a helpful assistant. Answer in one short sentence.",
|
| 50 |
-
"concise": "You are a helpful assistant. Be as concise as possible while still providing all "
|
| 51 |
-
"the necessary information to answer the question.",
|
| 52 |
-
"verbose": "You are a helpful assistant. Always answer with as much detail as possible.",
|
| 53 |
-
}
|
| 54 |
-
MAX_TOKENS = 4096 # AlpacaEval's, for its gamed baselines
|
| 55 |
-
SEED = 0
|
| 56 |
-
|
| 57 |
-
# AlpacaEval's weighted_alpaca_eval_gpt4_turbo annotator, ported from tatsu-lab/alpaca_eval
|
| 58 |
-
# (Apache-2.0) as in flock's experiments/run4/eval/judge.py
|
| 59 |
-
JUDGE_SYSTEM = (
|
| 60 |
-
"You are a highly efficient assistant, who evaluates and selects the best large language "
|
| 61 |
-
"model (LLMs) based on the quality of their responses to a given instruction. This process "
|
| 62 |
-
"will be used to create a leaderboard reflecting the most accurate and human-preferred answers."
|
| 63 |
-
)
|
| 64 |
-
JUDGE_USER = '''I require a leaderboard for various large language models. I'll provide you with prompts given to these models and their corresponding outputs. Your task is to assess these responses, and select the model that produces the best output from a human perspective.
|
| 65 |
-
|
| 66 |
-
## Instruction
|
| 67 |
-
|
| 68 |
-
{
|
| 69 |
-
"instruction": """{instruction}""",
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
## Model Outputs
|
| 73 |
-
|
| 74 |
-
Here are the unordered outputs from the models. Each output is associated with a specific model, identified by a unique model identifier.
|
| 75 |
-
|
| 76 |
-
{
|
| 77 |
-
{
|
| 78 |
-
"model_identifier": "m",
|
| 79 |
-
"output": """{output_1}"""
|
| 80 |
-
},
|
| 81 |
-
{
|
| 82 |
-
"model_identifier": "M",
|
| 83 |
-
"output": """{output_2}"""
|
| 84 |
-
}
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
## Task
|
| 88 |
-
|
| 89 |
-
Evaluate the models based on the quality and relevance of their outputs, and select the model that generated the best output. Answer by providing the model identifier of the best model. We will use your output as the name of the best model, so make sure your output only contains one of the following model identifiers and nothing else (no quotes, no spaces, no new lines, ...): m or M.
|
| 90 |
-
|
| 91 |
-
## Best Model Identifier'''
|
| 92 |
-
JUDGE_SEED = 0
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
def is_switched(instruction: str) -> bool:
|
| 96 |
-
"""Whether the reply goes first, as AlpacaEval's RandomSwitchTwoColumnsProcessor."""
|
| 97 |
-
return random.Random(f"is_switched_outputs{instruction}{JUDGE_SEED}").choices([False, True])[0]
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
def judge_user(instruction: str, output_1: str, output_2: str) -> str:
|
| 101 |
-
"""The judge's user message, placeholders filled in template order."""
|
| 102 |
-
user = JUDGE_USER
|
| 103 |
-
for key, value in (("instruction", instruction), ("output_1", output_1),
|
| 104 |
-
("output_2", output_2)):
|
| 105 |
-
user = user.replace("{" + key + "}", value, 1)
|
| 106 |
-
return user
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
def preference(top_logprobs: dict[str, float]) -> float:
|
| 110 |
-
"""1 when output_1 ("m") is certainly better, 2 when output_2 ("M") is, NaN when neither
|
| 111 |
-
token is listed."""
|
| 112 |
-
if "m" not in top_logprobs and "M" not in top_logprobs:
|
| 113 |
-
return math.nan
|
| 114 |
-
p_m = math.exp(top_logprobs.get("m", -math.inf))
|
| 115 |
-
p_big_m = math.exp(top_logprobs.get("M", -math.inf))
|
| 116 |
-
return 2 - p_m / (p_m + p_big_m)
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
def generate(rows: list[dict], args) -> list[dict]:
|
| 120 |
-
"""One reply per gold row and variant, from the generator under the variant's prompt."""
|
| 121 |
-
import torch
|
| 122 |
-
from vllm import LLM
|
| 123 |
-
|
| 124 |
-
llm = LLM(model=args.generator, revision=args.generator_revision, seed=SEED,
|
| 125 |
-
tensor_parallel_size=torch.cuda.device_count(), max_model_len=8192)
|
| 126 |
-
params = llm.get_default_sampling_params() # the model's generation_config
|
| 127 |
-
params.max_tokens, params.seed = MAX_TOKENS, SEED
|
| 128 |
-
items = [{"id": row["id"], "instruction": row["instruction"], "variant": variant,
|
| 129 |
-
"system_prompt": prompt, "reference": row["output"]}
|
| 130 |
-
for variant, prompt in VARIANTS.items() for row in rows]
|
| 131 |
-
outputs = llm.chat([[{"role": "system", "content": item["system_prompt"]},
|
| 132 |
-
{"role": "user", "content": item["instruction"]}] for item in items],
|
| 133 |
-
params)
|
| 134 |
-
for item, output in zip(items, outputs, strict=True):
|
| 135 |
-
reply = output.outputs[0]
|
| 136 |
-
item["output"], item["finish_reason"] = reply.text, reply.finish_reason
|
| 137 |
-
print(f"sampling: temperature {params.temperature}, top_p {params.top_p}, "
|
| 138 |
-
f"top_k {params.top_k}, max_tokens {params.max_tokens}")
|
| 139 |
-
return items
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
async def judge(items: list[dict], judge_model: str, max_connections: int) -> None:
|
| 143 |
-
"""Adds the judge's preference for each reply over its reference, as the eval's scorer."""
|
| 144 |
-
from inspect_ai.model import ChatMessageSystem, ChatMessageUser, GenerateConfig, get_model
|
| 145 |
-
|
| 146 |
-
# The eval's JUDGE_CONFIG, with its retries
|
| 147 |
-
config = GenerateConfig(max_tokens=1, temperature=1.0, logprobs=True, top_logprobs=5,
|
| 148 |
-
extra_body={"chat_template_kwargs": {"thinking": False}},
|
| 149 |
-
max_connections=max_connections, max_retries=10, timeout=600)
|
| 150 |
-
grader = get_model(judge_model, config=config)
|
| 151 |
-
|
| 152 |
-
async def one(item):
|
| 153 |
-
switched = is_switched(item["instruction"])
|
| 154 |
-
output_1, output_2 = ((item["output"], item["reference"]) if switched
|
| 155 |
-
else (item["reference"], item["output"]))
|
| 156 |
-
result = await grader.generate([
|
| 157 |
-
ChatMessageSystem(content=JUDGE_SYSTEM),
|
| 158 |
-
ChatMessageUser(content=judge_user(item["instruction"], output_1, output_2))])
|
| 159 |
-
logprobs = result.choices[0].logprobs if result.choices else None
|
| 160 |
-
top = {t.token: t.logprob for t in logprobs.content[0].top_logprobs} \
|
| 161 |
-
if logprobs and logprobs.content else {}
|
| 162 |
-
pref = preference(top)
|
| 163 |
-
item.update(switched=switched, preference=3 - pref if switched else pref,
|
| 164 |
-
judge=str(grader), judge_top_logprobs=json.dumps(top))
|
| 165 |
-
|
| 166 |
-
await asyncio.gather(*(one(item) for item in items))
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
def stats(rows: list[dict]) -> dict[str, dict]:
|
| 170 |
-
"""Per variant: median words, win rate against the gold reference, unjudged and
|
| 171 |
-
truncated replies."""
|
| 172 |
-
out = {}
|
| 173 |
-
for variant in VARIANTS:
|
| 174 |
-
sub = [r for r in rows if r["variant"] == variant]
|
| 175 |
-
wins = [r["preference"] - 1 for r in sub if not math.isnan(r["preference"])]
|
| 176 |
-
out[variant] = {"n": len(sub),
|
| 177 |
-
"median_words": statistics.median(len(r["output"].split()) for r in sub),
|
| 178 |
-
"win_rate": 100 * statistics.fmean(wins) if wins else math.nan,
|
| 179 |
-
"unjudged": len(sub) - len(wins),
|
| 180 |
-
"truncated": sum(r["finish_reason"] == "length" for r in sub)}
|
| 181 |
-
out["gold"] = {"median_words": statistics.median(
|
| 182 |
-
len(r["reference"].split()) for r in rows if r["variant"] == next(iter(VARIANTS)))}
|
| 183 |
-
return out
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
def section(args, summary: dict) -> str:
|
| 187 |
-
rows = "\n".join(
|
| 188 |
-
f"| `{v}` | {VARIANTS[v]} | {s['median_words']:g} | {s['win_rate']:.1f} |"
|
| 189 |
-
for v, s in summary.items() if v in VARIANTS)
|
| 190 |
-
return f"""## The `{CONFIG}` config
|
| 191 |
-
|
| 192 |
-
The gamed baselines of AlpacaEval's `length_controlled_v1` GLM (its `df_gamed.csv`), for the
|
| 193 |
-
`gold` references: their model, [`{args.generator}`](https://huggingface.co/{args.generator}),
|
| 194 |
-
answers each instruction once per variant under a system prompt that asks for a length, and
|
| 195 |
-
each reply is judged against the gold reference. Fitted alongside a model's judgements, without
|
| 196 |
-
an intercept and at a total weight of 0.2 per instruction, they set how much length alone moves
|
| 197 |
-
the judge. The length-controlled win rate then can't put all of a model's losses down to length.
|
| 198 |
-
|
| 199 |
-
| variant | system prompt | median words | win rate vs `gold` (%) |
|
| 200 |
-
|---|---|---:|---:|
|
| 201 |
-
{rows}
|
| 202 |
-
|
| 203 |
-
The `gold` references have a median of {summary['gold']['median_words']:g} words. The concise and
|
| 204 |
-
verbose prompts are AlpacaEval's; `terse` and `brief` cover replies as short as the
|
| 205 |
-
references and shorter. Each reply
|
| 206 |
-
is the model's answer to the instruction as a single user turn, sampled with its
|
| 207 |
-
`generation_config` (vLLM 0.32.0, seed {SEED}, at most {MAX_TOKENS} tokens).
|
| 208 |
-
|
| 209 |
-
- **The judge** is `{args.judge}`, with the eval's settings: AlpacaEval 2.0's weighted annotator
|
| 210 |
-
prompt, the reply and the reference swapped as AlpacaEval does, one token at temperature 1,
|
| 211 |
-
and the preference read from its top-5 logprobs. The preferences only calibrate evals by the
|
| 212 |
-
same judge.
|
| 213 |
-
|
| 214 |
-
| column | description |
|
| 215 |
-
|---|---|
|
| 216 |
-
| `id`, `instruction` | the `gold` row |
|
| 217 |
-
| `variant`, `system_prompt` | which gamed baseline, and its system prompt |
|
| 218 |
-
| `output` | the reply |
|
| 219 |
-
| `generator`, `finish_reason` | the model, and why its reply ended (`length` when truncated) |
|
| 220 |
-
| `output_length`, `reference_length` | the reply's and the `gold` reference's length in characters |
|
| 221 |
-
| `switched` | whether the reply was shown to the judge first |
|
| 222 |
-
| `preference` | 1 when the reference wins, 2 when the reply does, NaN when the judge named neither |
|
| 223 |
-
| `judge`, `judge_top_logprobs` | the judge, and the top-5 logprobs of its one token (JSON) |
|
| 224 |
-
|
| 225 |
-
"""
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
def reproducing(args) -> str:
|
| 229 |
-
return f"""
|
| 230 |
-
[`{SCRIPT}`]({SCRIPT}) builds the `{CONFIG}` config on a Hugging Face Job, and adds it to this
|
| 231 |
-
card and pushes itself. Run it after `create_dataset.py`, which rewrites the card:
|
| 232 |
-
|
| 233 |
-
```sh
|
| 234 |
-
hf download {args.repo} {SCRIPT} --repo-type dataset --local-dir .
|
| 235 |
-
hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \\
|
| 236 |
-
--timeout 4h {SCRIPT} \\
|
| 237 |
-
--gold_revision {args.gold_revision} --generator_revision {args.generator_revision} \\
|
| 238 |
-
--repo {args.repo} --push
|
| 239 |
-
```
|
| 240 |
-
"""
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
def with_config(text: str, args, summary: dict, n: int) -> str:
|
| 244 |
-
"""The card with this config's row in the summary table, its section before Reproducing and
|
| 245 |
-
its command at the end, replacing any earlier ones."""
|
| 246 |
-
row = (f"| `{CONFIG}` | Gamed baselines for the length-controlled win rate: "
|
| 247 |
-
f"`{args.generator}` told to answer in a few words, in one sentence, concisely or in "
|
| 248 |
-
f"detail, judged against "
|
| 249 |
-
f"`gold` | {n} |")
|
| 250 |
-
lines = [line for line in text.split("\n") if not line.startswith(f"| `{CONFIG}` |")]
|
| 251 |
-
last_row = lines.index("| subset | description | num_samples |") + 1
|
| 252 |
-
while lines[last_row + 1].startswith("| `"):
|
| 253 |
-
last_row += 1
|
| 254 |
-
text = "\n".join(lines[:last_row + 1] + [row] + lines[last_row + 1:])
|
| 255 |
-
head, sep, tail = text.partition("## Reproducing")
|
| 256 |
-
assert sep, "the card has no Reproducing section"
|
| 257 |
-
start = head.find(f"## The `{CONFIG}` config")
|
| 258 |
-
head = head[:start] if start >= 0 else head
|
| 259 |
-
tail = tail.split(f"\n[`{SCRIPT}`]")[0].rstrip("\n") + "\n"
|
| 260 |
-
return head + section(args, summary) + sep + tail + reproducing(args)
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
def main():
|
| 264 |
-
parser = argparse.ArgumentParser(description=__doc__,
|
| 265 |
-
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 266 |
-
parser.add_argument("--gold_revision", default=GOLD_REVISION,
|
| 267 |
-
help=f"commit of {REPO} to take the gold config from")
|
| 268 |
-
parser.add_argument("--generator", default=GENERATOR)
|
| 269 |
-
parser.add_argument("--generator_revision", default=GENERATOR_REVISION)
|
| 270 |
-
parser.add_argument("--judge", default=JUDGE, help="Inspect model string of the judge")
|
| 271 |
-
parser.add_argument("--max_connections", type=int, default=50,
|
| 272 |
-
help="concurrent requests to the judge")
|
| 273 |
-
parser.add_argument("--limit", type=int, help="only the first N gold rows (smoke test)")
|
| 274 |
-
parser.add_argument("--repo", default=REPO)
|
| 275 |
-
parser.add_argument("--push", action="store_true")
|
| 276 |
-
args = parser.parse_args()
|
| 277 |
-
if args.push and args.limit:
|
| 278 |
-
parser.error("--push builds the whole config, without --limit")
|
| 279 |
-
gold = load_dataset(args.repo, GOLD, split="test", revision=args.gold_revision)
|
| 280 |
-
rows = gold.to_list()[:args.limit]
|
| 281 |
-
items = generate(rows, args)
|
| 282 |
-
asyncio.run(judge(items, args.judge, args.max_connections))
|
| 283 |
-
for item in items:
|
| 284 |
-
item.update(generator=args.generator, output_length=len(item["output"]),
|
| 285 |
-
reference_length=len(item["reference"]))
|
| 286 |
-
summary = stats(items)
|
| 287 |
-
print(json.dumps(summary, indent=2))
|
| 288 |
-
if not args.push:
|
| 289 |
-
return
|
| 290 |
-
columns = ["id", "instruction", "variant", "system_prompt", "output", "generator",
|
| 291 |
-
"finish_reason", "output_length", "reference_length", "switched", "preference",
|
| 292 |
-
"judge", "judge_top_logprobs"]
|
| 293 |
-
Dataset.from_list([{c: item[c] for c in columns} for item in items]).push_to_hub(
|
| 294 |
-
args.repo, config_name=CONFIG, split="test")
|
| 295 |
-
pushed = DatasetCard.load(args.repo, repo_type="dataset")
|
| 296 |
-
# push_to_hub can drop the default flag from gold; keep gold the default config
|
| 297 |
-
for entry in pushed.data["configs"]:
|
| 298 |
-
entry.pop("default", None)
|
| 299 |
-
if entry["config_name"] == GOLD:
|
| 300 |
-
entry["default"] = True
|
| 301 |
-
pushed.text = with_config(pushed.text, args, summary, len(items))
|
| 302 |
-
api = HfApi()
|
| 303 |
-
api.create_commit(args.repo, repo_type="dataset", operations=[
|
| 304 |
-
CommitOperationAdd("README.md", str(pushed).encode()),
|
| 305 |
-
CommitOperationAdd(SCRIPT, Path(__file__).read_bytes()),
|
| 306 |
-
], commit_message=f"Publish the {CONFIG} config's card section and the script that built it")
|
| 307 |
-
print(f"pushed https://huggingface.co/datasets/{args.repo} @ "
|
| 308 |
-
f"{api.dataset_info(args.repo).sha}")
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
if __name__ == "__main__":
|
| 312 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|