Add matched T0-cap seed 2
Browse files
README.md
CHANGED
|
@@ -1,63 +1,64 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
tags:
|
| 6 |
-
- tokenizer
|
| 7 |
-
- vector-quantization
|
| 8 |
-
- residual-vq
|
| 9 |
-
datasets:
|
| 10 |
-
- EdinburghNLP/xsum
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
# CruxTok tokenizers (XSum)
|
| 14 |
-
|
| 15 |
-
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](https://github.com/Zilch123/CruxTok).
|
| 16 |
-
|
| 17 |
-
CruxTok (T1) replaces the fixed-window pooling of [Next-Concept Modeling](https://github.com/HazyResearch/ncm) (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.
|
| 18 |
-
|
| 19 |
-
## Files
|
| 20 |
-
| Folder | Model | Params | Seed, precision | Text accuracy, k=1 / k=3 / full |
|
| 21 |
-
|---|---|---|---|---|
|
| 22 |
-
| `t1_seed42` | CruxTok (T1) | 73.2M | 42, bf16 | 23.5 / 60.1 / 98.8 |
|
| 23 |
-
| `t1_seed2` | CruxTok (T1) | 73.2M | 2, bf16 | 24.4 / 60.7 / 98.8 |
|
| 24 |
-
| `t0cap_seed42` | NCM, same budget (T0-cap) | 60.6M | 42, fp16 | 23.5 / 47.1 / 95.8 |
|
| 25 |
-
| `t0cap_seed2` | NCM, same budget (T0-cap) | 60.6M | 2, bf16 | 23.0 / 46.5 / 95.7 |
|
| 26 |
-
| `t0cap_matched` | NCM with 5 encoder and 3 decoder blocks | 73.1M | 42, bf16 | 19.3 / 45.6 / 97.8 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
```
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
print(tok.decode(codes))
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
from
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
| 56 |
-
|
|
| 57 |
-
| T0-cap
|
| 58 |
-
|
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- tokenizer
|
| 7 |
+
- vector-quantization
|
| 8 |
+
- residual-vq
|
| 9 |
+
datasets:
|
| 10 |
+
- EdinburghNLP/xsum
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# CruxTok tokenizers (XSum)
|
| 14 |
+
|
| 15 |
+
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](https://github.com/Zilch123/CruxTok).
|
| 16 |
+
|
| 17 |
+
CruxTok (T1) replaces the fixed-window pooling of [Next-Concept Modeling](https://github.com/HazyResearch/ncm) (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.
|
| 18 |
+
|
| 19 |
+
## Files
|
| 20 |
+
| Folder | Model | Params | Seed, precision | Text accuracy, k=1 / k=3 / full |
|
| 21 |
+
|---|---|---|---|---|
|
| 22 |
+
| `t1_seed42` | CruxTok (T1) | 73.2M | 42, bf16 | 23.5 / 60.1 / 98.8 |
|
| 23 |
+
| `t1_seed2` | CruxTok (T1) | 73.2M | 2, bf16 | 24.4 / 60.7 / 98.8 |
|
| 24 |
+
| `t0cap_seed42` | NCM, same budget (T0-cap) | 60.6M | 42, fp16 | 23.5 / 47.1 / 95.8 |
|
| 25 |
+
| `t0cap_seed2` | NCM, same budget (T0-cap) | 60.6M | 2, bf16 | 23.0 / 46.5 / 95.7 |
|
| 26 |
+
| `t0cap_matched` | NCM with 5 encoder and 3 decoder blocks | 73.1M | 42, bf16 | 19.3 / 45.6 / 97.8 |
|
| 27 |
+
| `t0cap_matched_seed2` | NCM with 5 encoder and 3 decoder blocks | 73.1M | 2, bf16 | 19.6 / 45.6 / 97.9 |
|
| 28 |
+
|
| 29 |
+
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).
|
| 30 |
+
|
| 31 |
+
All models were trained on XSum training summaries for 30,000 updates at batch 256, about 16x below NCM's tokenizer budget.
|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
```bash
|
| 35 |
+
git clone --recurse-submodules https://github.com/Zilch123/CruxTok && cd CruxTok && pip install -e .
|
| 36 |
+
```
|
| 37 |
+
```python
|
| 38 |
+
from cruxtok.model.cruxtok import CruxTok
|
| 39 |
+
|
| 40 |
+
tok = CruxTok.from_pretrained("TimothDevA/cruxtok", filename="t1_seed42/tokenizer.pt")
|
| 41 |
+
codes = tok.encode("West Ham striker Andy Carroll is facing up to six weeks out of action.")
|
| 42 |
+
print(tok.decode(codes, upto_level=1)) # from the first 4 codes only
|
| 43 |
+
print(tok.decode(codes)) # all levels
|
| 44 |
+
```
|
| 45 |
+
The NCM baselines load through the repository's NCM wrapper:
|
| 46 |
+
```python
|
| 47 |
+
from huggingface_hub import snapshot_download
|
| 48 |
+
from cruxtok.eval.semantic import load_run
|
| 49 |
+
|
| 50 |
+
path = snapshot_download("TimothDevA/cruxtok", allow_patterns="t0cap_matched/*")
|
| 51 |
+
tokenizer, cfg = load_run(f"{path}/t0cap_matched", "cpu")
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## Results at level 1
|
| 55 |
+
| | Embedding cosine to original | LLM judge, CruxTok win rate |
|
| 56 |
+
|---|---|---|
|
| 57 |
+
| T0-cap | 0.359 | 0.700 [0.678, 0.722] |
|
| 58 |
+
| T0-cap, matched (seeds 42 / 2) | 0.342 / 0.344 | 0.740 / 0.772 against seed 42; 0.742 / 0.766 against seed 2 (CruxTok seeds 42 / 2) |
|
| 59 |
+
| CruxTok (seeds 42 / 2) | 0.449 / 0.455 | |
|
| 60 |
+
|
| 61 |
+
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.
|
| 62 |
+
|
| 63 |
+
## Attribution and license
|
| 64 |
+
MIT. Built on [Next-Concept Modeling](https://github.com/HazyResearch/ncm) (Kumbong et al., arXiv:2610.14162, MIT).
|