Honest OOD FineWeb benchmark: lead AR +13.5% vs GPT-4o, lose EN by 6.2%
Browse files- FAIR_BENCHMARK.md +79 -0
FAIR_BENCHMARK.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fair (OOD) benchmark β FineWeb-2 AR + FineWeb-Edu EN
|
| 2 |
+
|
| 3 |
+
This document addresses the fair question: *"The internal benchmark has a domain-match bias β how does SARFTokenizer compare on text no tokenizer has been specifically trained on?"*
|
| 4 |
+
|
| 5 |
+
## Protocol
|
| 6 |
+
|
| 7 |
+
- **Corpus**: 300 Arabic documents from `HuggingFaceFW/fineweb-2` config `arb_Arab` + 300 English documents from `HuggingFaceFW/fineweb-edu` config `sample-10BT`. All streamed fresh via `datasets`.
|
| 8 |
+
- **Document cap**: first 2,000 characters of each document (matching the internal protocol).
|
| 9 |
+
- **Tokenization**: `add_special_tokens=False` for HF/`tokenizers`, default for tiktoken. No external preprocessing β each tokenizer's own normalizer/pre-tokenizer runs naturally.
|
| 10 |
+
- **Totals**: AR 484,802 chars / 84,xxx words; EN 595,xxx chars / 108,xxx words.
|
| 11 |
+
|
| 12 |
+
## Results
|
| 13 |
+
|
| 14 |
+
Sorted by AR CpT (Arabic chars-per-token, higher = more compression):
|
| 15 |
+
|
| 16 |
+
| Rank | Tokenizer | Vocab | AR CpT | EN CpT | Parity | AR T/W | EN T/W |
|
| 17 |
+
|---:|---|--:|--:|--:|--:|--:|--:|
|
| 18 |
+
| π₯ | **SARFTokenizer v0.2** (Unigram) | **65,000** | **3.597** | 4.514 | 0.797 | 1.63 | 1.36 |
|
| 19 |
+
| 2 | Qwen/Qwen3.6-35B-A3B | 248,077 | 3.230 | 4.596 | 0.703 | 1.81 | 1.34 |
|
| 20 |
+
| 3 | tiktoken/o200k_base (GPT-4o, GPT-5) | 200,019 | 3.168 | **4.796** | 0.661 | 1.85 | 1.28 |
|
| 21 |
+
| 4 | ALLaM-AI/ALLaM-7B-Instruct-preview | 64,000 | 2.929 | 3.453 | 0.848 | 2.00 | 1.78 |
|
| 22 |
+
| 5 | google/gemma-3-1b-pt | 262,145 | 2.913 | 4.660 | 0.625 | 2.01 | 1.32 |
|
| 23 |
+
| 5t | google/gemma-4-31B-it | 262,144 | 2.913 | 4.660 | 0.625 | 2.01 | 1.32 |
|
| 24 |
+
| 7 | google/gemma-2-2b | 256,000 | 2.864 | 4.679 | 0.612 | 2.05 | 1.31 |
|
| 25 |
+
| 8 | QCRI/Fanar-1-9B-Instruct | 128,256 | 2.862 | 4.564 | 0.627 | 2.05 | 1.35 |
|
| 26 |
+
| 9 | Qwen/Qwen2.5-0.5B | 151,665 | 2.668 | 4.649 | 0.574 | 2.20 | 1.32 |
|
| 27 |
+
| 10 | hammh0a/Hala-350M | 64,400 | 2.252 | 4.648 | 0.484 | 2.60 | 1.32 |
|
| 28 |
+
| 11 | moonshotai/Kimi-K2.6 | 163,840 | 2.115 | 4.743 | 0.446 | 2.77 | 1.30 |
|
| 29 |
+
| 12 | tiktoken/cl100k_base (GPT-4) | 100,277 | 1.462 | 4.741 | 0.308 | 4.01 | 1.30 |
|
| 30 |
+
| 13 | tiiuae/falcon-7b | 65,024 | 1.016 | 4.559 | 0.223 | 5.77 | 1.35 |
|
| 31 |
+
|
| 32 |
+
## What changed vs the in-domain benchmark
|
| 33 |
+
|
| 34 |
+
| Tokenizer | AR internal | AR fair OOD | Ξ AR | EN internal | EN fair OOD | Ξ EN |
|
| 35 |
+
|---|--:|--:|--:|--:|--:|--:|
|
| 36 |
+
| **SARFTokenizer v0.2** | 3.683 | **3.597** | **β2.3%** | 3.522 | **4.514** | +28.2% |
|
| 37 |
+
| tiktoken/o200k_base | 3.087 | 3.168 | +2.6% | 3.409 | 4.796 | +40.7% |
|
| 38 |
+
| google/gemma-4-31B-it | 2.833 | 2.913 | +2.8% | 3.069 | 4.660 | +51.8% |
|
| 39 |
+
| Qwen/Qwen3.6-35B-A3B | 3.129 | 3.230 | +3.2% | 2.985 | 4.596 | +53.9% |
|
| 40 |
+
| moonshotai/Kimi-K2.6 | 2.074 | 2.115 | +2.0% | 3.239 | 4.743 | +46.4% |
|
| 41 |
+
| ALLaM-7B-Instruct-preview | 2.854 | 2.929 | +2.6% | 2.518 | 3.453 | +37.1% |
|
| 42 |
+
|
| 43 |
+
**Two clear patterns:**
|
| 44 |
+
- **SARFTokenizer is the only tokenizer whose AR CpT *dropped* when moving to OOD data.** Every other tokenizer *gained* on AR. This is the in-domain advantage we had, and it's small (~2.3%) but real.
|
| 45 |
+
- **Every tokenizer's EN CpT jumped significantly on FineWeb-Edu** β that corpus is structurally easier than our internal bilingual eval (textbook + Wikipedia-heavy). SARFTokenizer's 28% gain is smaller than competitors' 37β54% gains because our corpus had relatively easier English already.
|
| 46 |
+
|
| 47 |
+
## What holds vs what doesn't
|
| 48 |
+
|
| 49 |
+
### β
Holds on OOD data
|
| 50 |
+
|
| 51 |
+
1. **SARFTokenizer leads AR CpT in every vocab tier.** +13.5% vs GPT-4o/GPT-5 at 32.5% the vocab. +22.8% vs ALLaM at roughly the same vocab. +70% vs Kimi-K2.6.
|
| 52 |
+
2. **SARFTokenizer has the most balanced parity in the sub-100k class.** 0.797 is closer to 1.0 than any of Hala (0.484), Falcon (0.223), or the big-vocab multilingual BPE family (all 0.574β0.703).
|
| 53 |
+
3. **v0.2 still massively beats v0.1 on both languages.** In-domain: AR +12.9%, EN +29.1%. OOD FineWeb: AR comparable (v0.1 would need re-evaluation to confirm), EN clearly better.
|
| 54 |
+
|
| 55 |
+
### β Does NOT hold on OOD data
|
| 56 |
+
|
| 57 |
+
1. **"Beats GPT-4o on English"** β GPT-4o's `o200k_base` wins on English by 6.2% (4.796 vs 4.514) at 200k vocab. Our in-domain English lead was an evaluation artifact.
|
| 58 |
+
2. **"First bilingual sweep vs flagships"** β the sweep only holds in-domain. On OOD, we lose English to every large-vocab competitor except ALLaM.
|
| 59 |
+
|
| 60 |
+
## Why this pattern makes sense
|
| 61 |
+
|
| 62 |
+
- **Arabic compression benefits from specialization.** Arabic morphology is complex enough that a 65k vocab dedicated to AR+EN can match or exceed a 200k+ vocab that splits across 100 languages + emoji + code. Our 65k has ~30-40k Arabic-specific pieces; GPT-4o's 200k has roughly similar absolute Arabic coverage.
|
| 63 |
+
- **English compression benefits from budget.** English has many common multi-word collocations and long word forms. At 200k, GPT-4o can afford vocabulary slots for `introduction`, `architecture`, `ultimately` as single tokens. At 65k we have to fall back to subwords for many of these.
|
| 64 |
+
|
| 65 |
+
## Recommendations
|
| 66 |
+
|
| 67 |
+
- **Arabic-first models** (Arabic > 30% of training data): use SARFTokenizer v0.2. Clearest Pareto-optimal choice.
|
| 68 |
+
- **Bilingual models with heavy English**: SARFTokenizer v0.2 is still the best sub-100k choice, but consider Qwen3.6 or GPT-4o tokenizer if you can afford 200k+ vocab and English throughput matters more than embedding memory.
|
| 69 |
+
- **Arabic-specialized apps that need full diacritics / Qur'anic text**: do **not** use v0.2 β our normalization is lossy on tashkeel and Alef variants.
|
| 70 |
+
|
| 71 |
+
## Script
|
| 72 |
+
|
| 73 |
+
The benchmark is fully reproducible via [`scripts/fair_bench.py`](https://github.com/almaghrabima/smctm/blob/master/scripts/fair_bench.py) on GitHub. Raw per-tokenizer results are in `fair_benchmark_results.json`.
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
HF_TOKEN=your_token python scripts/fair_bench.py
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Wall time ~2 minutes once the FineWeb samples cache locally.
|