--- license: apache-2.0 language: - ar - en tags: - tokenizer - benchmark - eval - arabic - english - chars-per-token pretty_name: SARFTokenizer Benchmark Eval (600) size_categories: - n<1K task_categories: - text-classification dataset_info: features: - name: idx dtype: int64 - name: language dtype: string - name: text dtype: string - name: source dtype: string splits: - name: test num_bytes: 574100 num_examples: 600 configs: - config_name: default data_files: - split: test path: eval.parquet --- # SARFTokenizer Benchmark Eval (600 docs) The exact 300 Arabic + 300 English documents used to benchmark [`almaghrabima/SARFTokenizer`](https://huggingface.co/almaghrabima/SARFTokenizer) against GPT-5, GPT-4o, Gemma-4, Qwen3.6, Kimi-K2.6, ALLaM, and 8 other tokenizers. Publishing this dataset makes the benchmark in [SARFTokenizer/BENCHMARK.md](https://huggingface.co/almaghrabima/SARFTokenizer/blob/main/BENCHMARK.md) **fully reproducible** — anyone can compute the exact same chars-per-token numbers on the exact same samples. ## Statistics | | AR | EN | Total | |---|--:|--:|--:| | Documents | 300 | 300 | 600 | | Characters | 479,808 | 69,308 | 549,116 | | Words | 82,964 | 9,805 | 92,769 | | Max chars/sample | 2,000 | 2,000 | — | ## Schema | Field | Type | Description | |---|---|---| | `idx` | int64 | Index within the per-language subset (0–299) | | `language` | string | `"ar"` or `"en"` | | `text` | string | Document text, truncated to 2000 characters | | `source` | string | Always `"deeplatent-hq-bilingual"` | Sampled from the first 5 `ar_*.parquet` and first 5 `en_*.parquet` files of the `deeplatent-hq-bilingual` validation shards, with a 10% Arabic-character threshold for AR filtering (matching `scripts/bench_tokenizers.py`). ## Reproduce the headline benchmark ```bash pip install transformers tokenizers datasets ``` ```python from datasets import load_dataset from transformers import AutoTokenizer # Our eval corpus ds = load_dataset("almaghrabima/SARFTokenizer-benchmark-eval", split="test") ar_texts = [r["text"] for r in ds if r["language"] == "ar"] en_texts = [r["text"] for r in ds if r["language"] == "en"] # Load any tokenizer from huggingface_hub import login login(token="your_hf_token") # needed for private SARFTokenizer; skip if public tok = AutoTokenizer.from_pretrained("almaghrabima/SARFTokenizer") def stats(texts): chars = sum(len(t) for t in texts) words = sum(len(t.split()) for t in texts) tokens = sum(len(tok.encode(t, add_special_tokens=False)) for t in texts) return chars, words, tokens ar_c, ar_w, ar_t = stats(ar_texts) en_c, en_w, en_t = stats(en_texts) print(f"AR: {ar_c:,}c / {ar_t:,}t → CpT={ar_c/ar_t:.3f} T/W={ar_t/ar_w:.2f}") print(f"EN: {en_c:,}c / {en_t:,}t → CpT={en_c/en_t:.3f} T/W={en_t/en_w:.2f}") print(f"Parity = {(ar_c/ar_t)/(en_c/en_t):.3f}") ``` Expected output for SARFTokenizer v0.2: ``` AR: 479,808c / 130,253t → CpT=3.683 T/W=1.57 EN: 69,308c / 19,680t → CpT=3.522 T/W=2.01 Parity = 1.046 ``` ## Compare multiple tokenizers in one shot ```python from datasets import load_dataset from transformers import AutoTokenizer from huggingface_hub import login login(token="your_hf_token") # needed for private SARFTokenizer ds = load_dataset("almaghrabima/SARFTokenizer-benchmark-eval", split="test") ar_texts = [r["text"] for r in ds if r["language"] == "ar"] en_texts = [r["text"] for r in ds if r["language"] == "en"] ar_chars = sum(len(t) for t in ar_texts) en_chars = sum(len(t) for t in en_texts) peers = { "SARFTokenizer-v0.2": ("almaghrabima/SARFTokenizer", False), "gemma-4-31B-it": ("google/gemma-4-31B-it", False), "Qwen3.6-35B-A3B": ("Qwen/Qwen3.6-35B-A3B", False), "Kimi-K2.6": ("moonshotai/Kimi-K2.6", True), "ALLaM-7B": ("ALLaM-AI/ALLaM-7B-Instruct-preview", False), "Qwen2.5-0.5B": ("Qwen/Qwen2.5-0.5B", False), "Falcon-7B": ("tiiuae/falcon-7b", False), } print(f"{'Tokenizer':<22} {'Vocab':>10} {'AR CpT':>8} {'EN CpT':>8} {'Parity':>8}") print("=" * 60) for name, (repo, trc) in peers.items(): try: t = AutoTokenizer.from_pretrained(repo, trust_remote_code=trc) ar_t = sum(len(t.encode(x, add_special_tokens=False)) for x in ar_texts) en_t = sum(len(t.encode(x, add_special_tokens=False)) for x in en_texts) ar_cpt = ar_chars / ar_t en_cpt = en_chars / en_t print(f"{name:<22} {len(t):>10,} {ar_cpt:>8.3f} {en_cpt:>8.3f} {ar_cpt/en_cpt:>8.3f}") except Exception as e: print(f"{name:<22} SKIP: {e.__class__.__name__}") ``` Expected numbers are the [headline benchmark](https://huggingface.co/almaghrabima/SARFTokenizer/blob/main/BENCHMARK.md) — any divergence means a tokenizer changed upstream. ## Files - `eval.parquet` — 600 documents, schema above, ~540 KB - `summary.json` — aggregate stats - `README.md` — this file ## License Apache 2.0. Underlying text is from the `deeplatent-hq-bilingual` curated corpus; individual documents retain their original web-sourced licenses.