Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: pytorch
|
| 6 |
+
tags:
|
| 7 |
+
- tokenization
|
| 8 |
+
- superword
|
| 9 |
+
- bpe
|
| 10 |
+
- pretraining
|
| 11 |
+
- mechanistic-interpretability
|
| 12 |
+
- test-time-compute
|
| 13 |
+
datasets:
|
| 14 |
+
- HuggingFaceFW/fineweb-edu
|
| 15 |
+
- roneneldan/TinyStories
|
| 16 |
+
- nyu-mll/blimp
|
| 17 |
+
- allenai/ai2_arc
|
| 18 |
+
- allenai/sciq
|
| 19 |
+
metrics:
|
| 20 |
+
- accuracy
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# BT3-FullSynthesis (`30.4M` & `149.6M`) + `BT2_AttnDemux_16384` Tokenizer
|
| 24 |
+
|
| 25 |
+
Official model checkpoints, `16,384`-entry multi-word tokenizers, and evaluation artifacts for **"What Earns a Phrase Its Own Token? Mechanistic Multi-Word Vocabulary Allocation, Compositional-Residual Folding, and Test-Time Compute Gearshifting."**
|
| 26 |
+
|
| 27 |
+
## Model & Tokenizer Highlights
|
| 28 |
+
|
| 29 |
+
- **Zero Deployment Overhead (`0.0` Float Folding Error):** Trained with **Foldable Compositional-Residual Superwords** ($W_P = \frac{1}{|P|}\sum_{t\in P} W_t + \Delta_P$, decoupled $\lambda_\Delta = 0.30$), then algebraically folded into a standard `[16384, d]` embedding matrix—requiring **zero architectural modifications** at inference.
|
| 30 |
+
- **Attention-Query De-Multiplexed Vocabulary (`BT2_AttnDemux_16384`):** Shares a lossless `14,336` Byte-BPE base + `2,048` boundary-guarded superwords (`96%+` active slot utilization vs. `62.8%` in `SuperBPE`), vetoing high-JSD multi-binding relational phrases ($D_{\text{bind}} > 0.0549$ bits).
|
| 31 |
+
- **Zero-Retraining Prefix-Cone Decoding:** Cures Superword Vote-Splitting (`+0.93%` to `+1.59%` next-word recovery with `0.00%` perturbation to subword baselines).
|
| 32 |
+
- **Test-Time Compute Gearshifting:** Trained with `20%` dual-granularity unmerging ($q = 0.20$), allowing a **single frozen checkpoint** to run `+5.8%` faster in Superword High Gear or downshift to Subword Low Gear on high-entropy clauses for **`+1.58%` higher accuracy** at `149.6M` scale without Chain-of-Thought tokens.
|
| 33 |
+
|
| 34 |
+
## Benchmark Summary (`300M` Unique Non-Repeated `FineWeb-Edu` Tokens)
|
| 35 |
+
|
| 36 |
+
| Model | Params | Bytes/Tok | `BLiMP` (Fert-Matched) ↑ | `ARC-Easy` ↑ | Next-Word (Cone) ↑ | Perturb $\Delta\text{BPB}$ ↓ |
|
| 37 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 38 |
+
| `B1_ByteBPE` (3-seed) | `30.42M` | `4.322` | `85.89% ± 0.45%` | `38.13%` | `23.27%` | `+0.00019` |
|
| 39 |
+
| `B4_SuperBPE` (3-seed) | `30.42M` | `4.665` | `83.51% ± 0.73%` | `38.53%` | `16.22%` | `+0.00016` |
|
| 40 |
+
| `B5_SupraTok` (3-seed) | `30.42M` | `4.422` | `83.64% ± 1.80%` | `37.27%` | `18.75%` | `+0.00058` |
|
| 41 |
+
| **`BT3_FullSynthesis` (3-seed)** | **`30.42M`** | **`4.571`** | **`86.44% ± 0.31%` (#1)** | `37.93%` | **`22.83%`** | **`-0.00021` (#1)** |
|
| 42 |
+
| `150M_B1_ByteBPE` | `149.58M` | `4.322` | `86.20%` | `38.40%` | `25.66%` | `-0.00017` |
|
| 43 |
+
| `150M_B4_SuperBPE` | `149.58M` | `4.665` | `86.39%` | `38.80%` | `18.88%` | `+0.00005` |
|
| 44 |
+
| `150M_B5_SupraTok` | `149.58M` | `4.422` | `86.56%` | `38.40%` | `21.94%` | `+0.00042` |
|
| 45 |
+
| **`150M_BT3_FullSynthesis` (Zero-Shot)** | **`149.58M`** | **`4.571`** | **`86.81%` (#1 All)** | **`39.20%` (#1)** | **`24.07%`** | **`-0.00020` (#1)** |
|
| 46 |
+
|
| 47 |
+
## Usage
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
import torch
|
| 51 |
+
from src.config import TokenizerSpec
|
| 52 |
+
from src.model import ResearchTransformerLM
|
| 53 |
+
from src.tokenizer_core import PhraseAugmentedTokenizer
|
| 54 |
+
from src.breakthroughs import PrefixConeDecoder
|
| 55 |
+
from scripts.run_stage_cde_mechanistic import STAGE_E_150M_SPEC
|
| 56 |
+
|
| 57 |
+
tok = PhraseAugmentedTokenizer.load("tokenizers/BT2_AttnDemux_16384", spec=TokenizerSpec())
|
| 58 |
+
model = ResearchTransformerLM(STAGE_E_150M_SPEC).cuda().eval()
|
| 59 |
+
ckpt = torch.load("runs/stageE_150M_BT3_FullSynthesis_seed1001/ckpt_final.pt", map_location="cuda")
|
| 60 |
+
model.load_state_dict(ckpt["model"])
|
| 61 |
+
|
| 62 |
+
cone = PrefixConeDecoder(tok, device=torch.device("cuda"))
|
| 63 |
+
ids = torch.tensor([[tok.eos_id] + tok.encode("In the midst of", add_eos=False)], device="cuda")
|
| 64 |
+
with torch.no_grad():
|
| 65 |
+
logits, _ = model(ids, active_output_vocab=tok.vocab_size)
|
| 66 |
+
next_id = cone.argmax_step(logits[:, -1, :])
|
| 67 |
+
print(tok.decode(next_id.tolist()))
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Author & Citation
|
| 71 |
+
|
| 72 |
+
**Andrew Rober Fouad Samy** ([GitHub](https://github.com/AndrewRober) · [LinkedIn](https://www.linkedin.com/in/andrew-rober/) · `andrew.rober@bytesglue.com`)
|
| 73 |
+
|
| 74 |
+
```bibtex
|
| 75 |
+
@article{samy2026phrase,
|
| 76 |
+
title={What Earns a Phrase Its Own Token? Mechanistic Multi-Word Vocabulary Allocation, Compositional-Residual Folding, and Test-Time Compute Gearshifting},
|
| 77 |
+
author={Samy, Andrew Rober Fouad},
|
| 78 |
+
year={2026},
|
| 79 |
+
url={https://github.com/AndrewRober/MechanisticPhraseTokenization}
|
| 80 |
+
}
|
| 81 |
+
```
|