Download README.md from TimothDevA/cruxtok: direct link, hf CLI and curl.
- Browser
- Download file 3.1 kB
-
https://huggingface.co/TimothDevA/cruxtok/resolve/main/README.md
- Command line
-
hf download hf://TimothDevA/cruxtok/README.md
-
curl -L -o README.md https://huggingface.co/TimothDevA/cruxtok/resolve/main/README.md
license: mit
language:
- en
tags:
- tokenizer
- vector-quantization
- residual-vq
datasets:
- EdinburghNLP/xsum
CruxTok tokenizers (XSum)
Residual VQ text tokenizers from the paper What Does the First Level of a Residual Text Tokenizer Know? Learned-Query Pooling Puts the Gist in Level 1 (arXiv link to follow). Code: github.com/Zilch123/CruxTok.
CruxTok (T1) replaces the fixed-window pooling of Next-Concept Modeling (NCM) with learned-query pooling. Against an NCM baseline with the same parameter count, its first level (4 codes) recovers much more of a sentence.
Files
| Folder | Model | Params | Seed, precision | Text accuracy, k=1 / k=3 / full |
|---|---|---|---|---|
t1_seed42 |
CruxTok (T1) | 73.2M | 42, bf16 | 23.5 / 60.1 / 98.8 |
t1_seed2 |
CruxTok (T1) | 73.2M | 2, bf16 | 24.4 / 60.7 / 98.8 |
t0cap_seed42 |
NCM, same budget (T0-cap) | 60.6M | 42, fp16 | 23.5 / 47.1 / 95.8 |
t0cap_seed2 |
NCM, same budget (T0-cap) | 60.6M | 2, bf16 | 23.0 / 46.5 / 95.7 |
t0cap_matched |
NCM with 5 encoder and 3 decoder blocks | 73.1M | 42, bf16 | 19.3 / 45.6 / 97.8 |
Each folder holds tokenizer.pt (weights and config), config.yaml and eval.jsonl (held-out reconstruction every 5,000 updates). Parameter counts include codebooks. "k" means levels 1..k together: k=1 is 4 codes, k=3 is 20, and full is all 9 levels over a 48-token window (GPT-2 tokenizer).
All models were trained on XSum training summaries for 30,000 updates at batch 256, about 16x below NCM's tokenizer budget.
Usage
git clone --recurse-submodules https://github.com/Zilch123/CruxTok && cd CruxTok && pip install -e .
from cruxtok.model.cruxtok import CruxTok
tok = CruxTok.from_pretrained("TimothDevA/cruxtok", filename="t1_seed42/tokenizer.pt")
codes = tok.encode("West Ham striker Andy Carroll is facing up to six weeks out of action.")
print(tok.decode(codes, upto_level=1)) # from the first 4 codes only
print(tok.decode(codes)) # all levels
The NCM baselines load through the repository's NCM wrapper:
from huggingface_hub import snapshot_download
from cruxtok.eval.semantic import load_run
path = snapshot_download("TimothDevA/cruxtok", allow_patterns="t0cap_matched/*")
tokenizer, cfg = load_run(f"{path}/t0cap_matched", "cpu")
Results at level 1
| Embedding cosine to original | LLM judge, CruxTok win rate | |
|---|---|---|
| T0-cap | 0.359 | 0.700 [0.678, 0.722] |
| T0-cap, matched | 0.342 | 0.740 (seed 42), 0.772 (seed 2) |
| CruxTok (seeds 42 / 2) | 0.449 / 0.455 |
On 1,000 XSum test summaries. The judge (GLM-5.3, validated on STS-B at Spearman 0.90) compares level-1 reconstructions in both orders. CruxTok does not make similar sentences get similar codes: on STS-B at k=3, code similarity reaches Spearman 0.28 for the matched baseline against 0.02-0.03 for CruxTok.
Attribution and license
MIT. Built on Next-Concept Modeling (Kumbong et al., arXiv:2610.14162, MIT).