exp_vocab_64k
A production-grade, general-purpose Byte-Level Byte Pair Encoding (BPE) Tokenizer built from scratch for modern generative language models.
π Highlights
- Zero Out-Of-Vocabulary (0.00% UNK Rate): Full byte fallback ensures every single arbitrary byte sequence (0β255) is representable.
- 100% Lossless Roundtrip Fidelity:
decode(encode(text)) == textacross arbitrary code, LaTeX, emojis, whitespaces, tabs, and Unicode scripts. - Optimized Subword Compression: Achieves an overall compression ratio of 3.1294 Bytes/Token with average fertility of 2.9073 Tokens/Word.
- GPT-4 Style Regex Pre-Tokenization: Isolates contractions (
's,'t,'re,'ve), words, punctuation, and consecutive spaces.
π Benchmark Evaluation
| Domain Slice | Total Bytes | Total Tokens | Compression Ratio | Fertility |
|---|---|---|---|---|
| Prose | 733 | 149 | 4.92 B/T | 1.42 T/W |
| Technical | 745 | 151 | 4.93 B/T | 1.45 T/W |
| Scientific | 858 | 277 | 3.10 B/T | 2.50 T/W |
| Code | 1,401 | 417 | 3.36 B/T | 2.88 T/W |
| Numbers | 478 | 248 | 1.93 B/T | 5.51 T/W |
| Urls | 536 | 188 | 2.85 B/T | 17.09 T/W |
| Edge_cases | 644 | 294 | 2.19 B/T | 4.08 T/W |
π Training Corpus Composition
Trained on a 250 MB balanced multi-domain corpus:
- FineWeb (70% / 175 MB): High-quality filtered web prose
- WikiText-103 (10% / 25 MB): Encyclopedic, knowledge-dense prose
- CodeSearchNet (10% / 25 MB): Multi-language code and comments (Python, Java, Go, JS, PHP, Ruby)
- ArXiv / Math (5% / 12.5 MB): Scientific LaTeX and numerical notations
- OpenWebText (5% / 12.5 MB): Conversational and forum discourse
π Quickstart Usage
You can load and use this tokenizer directly via Hugging Face transformers:
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ZyroGod/exp-vocab-64k")
text = "def calculate_loss(predictions: torch.Tensor) -> float:\n return float(loss.item())"
tokens = tokenizer.encode(text)
print("Encoded token IDs:", tokens)
decoded = tokenizer.decode(tokens)
print("Decoded text:", decoded)
assert decoded == text, "Roundtrip must be 100% lossless!"
π¦ Artifacts Included
tokenizer.json: Hugging Face Fast Tokenizer formatvocab.json: Token-to-ID mappingmerges.txt: Ranked BPE merge rules (GPT-2 compatible)tokenizer_config.json: Fast tokenizer configurationspecial_tokens_map.json: Reserved special tokensREADME.md: Auto-generated model card
Created with the Byte-Level BPE Tokenizer Engineering Framework.