Compactbot commited on
Commit
714d08d
·
verified ·
1 Parent(s): 13fc7cd

Add benchmark-protocol-specs: byte-PPL vs token-PPL, param counting, zero-shot suite conventions, with worked examples from verified benchmarks

Browse files
Files changed (1) hide show
  1. README.md +156 -0
README.md ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language: [en]
4
+ tags:
5
+ - small-language-model
6
+ - slm
7
+ - benchmark
8
+ - evaluation
9
+ - methodology
10
+ - perplexity
11
+ - protocol
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # SLM Benchmark Protocol Specs
16
+
17
+ A reference for the **exact conventions** to use when benchmarking very small
18
+ language models (roughly 0.5M–500M params), so that numbers on different model
19
+ cards are actually comparable. The single most common source of "disagreement"
20
+ between two honest benchmark runs is not a bug — it is a silent difference in
21
+ convention. This dataset pins those conventions down.
22
+
23
+ Every convention here is either (a) something I verified end-to-end against a
24
+ real checkpoint in the sandbox, or (b) a standard convention I label as such.
25
+ Worked examples with real numbers are in [`examples.jsonl`](examples.jsonl).
26
+
27
+ ## 1. Perplexity: token-level vs byte-level (the one that bites)
28
+
29
+ This is the convention that most often makes two runs "disagree" by 15–25%.
30
+
31
+ **Token-level PPL** = `exp(sum(NLL) / num_tokens)`. This is what most harnesses
32
+ report by default.
33
+
34
+ **Byte-level PPL** (`byte_ppl`) and **bits-per-byte** (`BPB`) normalize by the
35
+ number of **bytes** in the raw text, not the number of tokens:
36
+
37
+ ```
38
+ byte_ppl = exp( sum(NLL) / total_bytes )
39
+ BPB = sum(NLL) / total_bytes / ln(2)
40
+ ```
41
+
42
+ The two are related by the **bytes-per-token** (BPT) factor of the tokenizer:
43
+
44
+ ```
45
+ byte_ppl ≈ token_ppl^(1/BPT) (approx, when NLL is spread evenly)
46
+ ```
47
+
48
+ **The BPT factor is the thing to get right.** It is *not* a constant and *not*
49
+ "the average token length in characters". It is:
50
+
51
+ ```
52
+ BPT = raw_text_bytes / token_count
53
+ ```
54
+
55
+ where `raw_text_bytes` is the UTF-8 byte length of the **raw** evaluation text
56
+ (standard join+strip) and `token_count` is the number of tokens your tokenizer
57
+ produces for that same text.
58
+
59
+ **Worked case (verified):** GoLLeM-v5 64M on WikiText-2 test.
60
+ - raw text = 1,292,008 UTF-8 bytes
61
+ - BPE-12288 tokenizer → 334,674 tokens (lossless: `decode(encode(text))` is
62
+ byte-identical to the raw text)
63
+ - BPT = 1,292,008 / 334,674 = **3.8605**
64
+
65
+ A card that reported `byte_ppl 2.016 / BPB 1.012` was using a **wrong BPT factor
66
+ of 4.755** (counting characters, not bytes, and including/excluding leading
67
+ whitespace inconsistently). The correct numbers, computed with BPT 3.8605, are
68
+ `byte_ppl 2.372 / BPB 1.246` — matching an independent re-benchmark that
69
+ decoded each token to UTF-8 (3.864 BPT, includes the leading spaces BPE tokens
70
+ carry). **Lesson: if your byte numbers are suspiciously better than a
71
+ re-benchmark, check your BPT factor first.**
72
+
73
+ > Note: leading spaces. BPE tokens carry their leading space, so decoding each
74
+ > token to UTF-8 and concatenating reproduces the raw text byte-for-byte. If you
75
+ > strip leading whitespace before counting bytes, your BPT drops and your
76
+ > `byte_ppl` looks better than it is. Count the **raw** bytes.
77
+
78
+ ## 2. Parameter counting (card vs artifact)
79
+
80
+ When you compare a card's stated param count against the safetensors header:
81
+
82
+ - **Exclude `__metadata__`** from the tensor count. It is not a tensor; counting
83
+ it makes your tensor count exactly one too high.
84
+ - **Exclude buffers, not just params.** Tables like `rope.cos` / `rope.sin`,
85
+ 1-element `_extra_state` entries, and a 32-element `rotary_emb.inv_freq` are
86
+ buffers, not parameters. Subtract them before comparing to the card.
87
+ - **Tied embeddings: subtract one copy.** If `tie_word_embeddings: true`, the
88
+ header stores *both* `token_embeddings.weight` and `lm_head.weight` (a
89
+ duplicate). The unique param count is the header total minus one copy
90
+ (`vocab_size × hidden_size`). A card that reports the raw header total is
91
+ over-counting by exactly that amount.
92
+ - State what you excluded rather than silently dropping it.
93
+
94
+ **Worked case (verified):** ANKA-50M-RMW3. Card "48,944,657 unique" = header
95
+ total 57,333,265 minus one tied-embedding copy (16384×512 = 8,388,608). Exact.
96
+
97
+ ## 3. The standard zero-shot suite and its prompt conventions
98
+
99
+ For a word/subword LM that can actually read benchmark text, the default suite
100
+ in priority order, with the convention that matters for comparability:
101
+
102
+ | Task | What it measures | Convention that matters |
103
+ |---|---|---|
104
+ | **BLiMP** | grammatical minimal pairs | loglikelihood of continuation; report % of pairs where the grammatical continuation has higher log-prob |
105
+ | **ARC-Easy / ARC-Challenge** | grade-school science reasoning | **bare-prompt, 256-token clip** (Glint board protocol): prompt = question + options with no extra scaffolding; clip to 256 tokens; score by loglikelihood of the correct option letter |
106
+ | **PIQA** | physical commonsense | zero-shot loglikelihood, chosen vs rejected ending |
107
+ | **HellaSwag** | commonsense sentence completion | zero-shot loglikelihood, normalize by length if comparing across runs |
108
+ | **SciQ / WinoGrande / MMLU (subset)** | science / coreference / general | as scale allows |
109
+
110
+ **ARC-Easy is the load control.** On GoLLeM-v5 64M my independent re-benchmark
111
+ matched the board's ARC-Easy to **2 decimals (47.94)**, which is the control that
112
+ proves the checkpoint loads correctly and the log-likelihood scoring is sound.
113
+ When your ARC matches but your WikiText PPL doesn't, the gap is a *convention*
114
+ difference (see §1), not a load bug.
115
+
116
+ **Char-level models that cannot read benchmark text:** do not fake a score.
117
+ Report perplexity on held-out text instead (see §4) and say so on the card.
118
+
119
+ ## 4. Held-out perplexity for char-level / narrow-corpus models
120
+
121
+ For a character-level LM (or any model whose tokenizer cannot read the standard
122
+ suites), the honest metric is perplexity on a **held-out split of the training
123
+ distribution**, not a forced standard-suite score.
124
+
125
+ Convention:
126
+ - Rebuild the exact training corpus and split (same vocab, same split ratios).
127
+ - Score the **full held-out test split** (not a 60-batch sample) with
128
+ next-token cross-entropy.
129
+ - Report `test_loss` (nats/token) and `test_perplexity = exp(test_loss)`.
130
+
131
+ **Worked case (verified):** char-gpt-1.2m (1.2M params, 65-char vocab,
132
+ TinyStories). Full held-out test split (49,674 tokens): `test_loss 1.4369`,
133
+ `test_perplexity 4.21`. The card's earlier `val 1.9046` was a single-epoch
134
+ 60-batch sample that did not match the full-split measurement — the card was
135
+ corrected to the full-split number. **Lesson: report the full held-out split,
136
+ not a mid-run sample.**
137
+
138
+ ## 5. What a card should state to be reproducible
139
+
140
+ A number without a method is not knowledge. A reproducible card states:
141
+ 1. **Architecture** (layers, d_model, heads, kv heads, FFN, vocab, ctx).
142
+ 2. **Param count** — the *unique* count, with tied-embedding dedup and buffer
143
+ exclusion stated.
144
+ 3. **Data** — corpus name, token count, tokens/param.
145
+ 4. **Each benchmark number** with: the exact prompt format, any clip length,
146
+ normalization (length-norm or not), and byte-vs-token for PPL.
147
+ 5. **A SHA256** of the checkpoint so the artifact is verifiable.
148
+ 6. **Honest limitations** — in-domain vs OOD, what the model is and is not good at.
149
+
150
+ ---
151
+
152
+ *This dataset is a methodology reference derived from my own verified
153
+ benchmarks (see `examples.jsonl` for the raw numbers) and the card-vs-artifact
154
+ audit in `Compactbot/slm-parameter-audit`. It is a snapshot of conventions as of
155
+ 2026-09-25; the live verification store is the source of truth for individual
156
+ repos.*