Downloads · 30 days
0
mjbommar/glaurung-binary-tokenizer-002
glaurung-binary-tokenizer-002 is a feature extraction model from mjbommar. Use it when you need embeddings to search or compare text. It is set up for tokenizers. The card lists the license as apache-2.0.
A cross-platform BPE tokenizer for binary executables and machine code. Trained using advanced chunked training with deduplication on 23 GB of diverse binaries spanning Linux and Windows platforms.
Downloads · 30 days
0
Access
Public
Updated Nov 13, 2025
Repo size
—
Likes
1
Public
Click a slice to open those files.
.json2.5 MB · 100%
From the Hugging Face model README
A cross-platform BPE tokenizer for binary executables and machine code. Trained using advanced chunked training with deduplication on 23 GB of diverse binaries spanning Linux and Windows platforms.
🔗 Model: mjbommar/glaurung-binary-tokenizer-002
📊 Dataset: mjbommar/binary-30k-tokenized
📄 Paper: Binary BPE: Cross-Platform Tokenization for Binary Analysis (arXiv preprint coming soon)
Training Corpus:
mjbommar/binary-30k-tokenizedTraining Parameters:
Composition:
<|start|>, <|end|>, <|pad|>, <|unk|>, <|cls|>, <|sep|>, <|mask|>)Quality Metrics:
| Length | Count | Percentage | Description |
|---|---|---|---|
| 1 byte | 256 | 0.4% | Base bytes |
| 2 bytes | 28,561 | 43.6% | Byte pairs (most common patterns) |
| 3 bytes | 10,800 | 16.5% | Complete x86-64 instructions |
| 4 bytes | 14,376 | 21.9% | Instructions with operands |
| 5 bytes | 2,780 | 4.2% | Complex patterns |
| 6 bytes | 2,213 | 3.4% | Complex patterns |
| 7 bytes | 1,167 | 1.8% | Complex patterns |
| 8 bytes | 2,329 | 3.6% | Multi-byte sequences |
| 9+ bytes | 3,045 | 4.6% | Long patterns |
Average Token Length: 3.749 bytes
Content Categories:
Most Common Bytes in Tokens:
0x00 (NULL): 34,482 occurrences - Padding and alignment0xFF: 6,545 occurrences - Sentinel values0x48 (REX.W): 3,419 occurrences - x86-64 REX prefix0x8B (MOV): 2,486 occurrences - x86-64 MOV opcode0x40 (@): 4,538 occurrences - ASCII and instruction patternsN-byte Sequence Diversity:
| Length | Learned Tokens | Possible Sequences | Coverage |
|---|---|---|---|
| 1-byte | 256 | 256 | 100.00% |
| 2-byte | 28,561 | 65,536 | 43.58% |
| 3-byte | 10,800 | 16,777,216 | 0.064% |
| 4-byte | 14,376 | 4,294,967,296 | 0.00034% |
Notable Achievement: 43.6% coverage of all possible 2-byte sequences - excellent for pattern recognition.
tokenizer-65536.json - Trained tokenizer model (2.4 MB)analysis_results.json - Detailed analysis statisticsoriginal_README.md - Original README from HuggingFaceLoad from HuggingFace Hub:
from tokenizers import Tokenizer
# Load directly from HuggingFace
tokenizer = Tokenizer.from_pretrained("mjbommar/glaurung-binary-tokenizer-002")
Load from local file:
# With bbpe CLI
bbpe encode --tokenizer tokenizer-65536.json /path/to/binary
bbpe info tokenizer-65536.json
Complete Python Example:
from tokenizers import Tokenizer
# Load from HuggingFace or local file
tokenizer = Tokenizer.from_pretrained("mjbommar/glaurung-binary-tokenizer-002")
# OR: tokenizer = Tokenizer.from_file("tokenizer-65536.json")
# Read binary file and decode as latin-1 (preserves all byte values 0-255)
with open("/usr/bin/ls", "rb") as f:
data = f.read()
data_str = data.decode("latin-1")
# Encode the binary data
encoding = tokenizer.encode(data_str)
print(f"File size: {len(data)} bytes")
print(f"Total tokens: {len(encoding.ids)}")
print(f"Compression: {len(data) / len(encoding.ids):.3f} bytes/token")
# First 10 tokens
for i, (token_id, token) in enumerate(zip(encoding.ids[:10], encoding.tokens[:10])):
token_bytes = token.encode("latin-1")
print(f" Token {i}: ID={token_id:5d} hex={token_bytes.hex():20s} ({len(token_bytes)} bytes)")
# Decode tokens back to bytes
decoded_str = tokenizer.decode(encoding.ids)
decoded_bytes = decoded_str.encode("latin-1")
assert decoded_bytes == data # Perfect reconstruction
Example output for /usr/bin/ls (142,312 bytes):
File size: 142312 bytes
Total tokens: 54537
Compression: 2.609 bytes/token
First 10 tokens:
Token 0: ID= 127 hex=7f (1 bytes)
Token 1: ID= 2382 hex=454c (2 bytes)
Token 2: ID= 5923 hex=4602 (2 bytes)
Token 3: ID= 394 hex=0101 (2 bytes)
Token 4: ID= 268 hex=000000000000 (6 bytes)
Token 5: ID= 259 hex=000000 (3 bytes)
Token 6: ID= 295 hex=0300 (2 bytes)
Token 7: ID= 2124 hex=3e00 (2 bytes)
Token 8: ID= 271 hex=01000000 (4 bytes)
Token 9: ID=59106 hex=306d (2 bytes)
Decoded: 7f454c4602010100000000000000000003003e0001000000306d...
(ELF header: 7f 45 4c 46 = ELF magic bytes)
Compression on Real-World Binaries:
| Binary | Size | Tokens | bytes/token |
|---|---|---|---|
| bash | 1.38 MB | 602,719 | 2.399 |
| python3.12 | 7.65 MB | 2,997,303 | 2.676 |
| gcc-13 | 0.98 MB | 375,331 | 2.726 |
| ls | 0.14 MB | 54,537 | 2.609 |
| grep | 0.18 MB | 73,500 | 2.542 |
Average: 2.590 bytes/token
Information-Theoretic Efficiency:
Instruction-Aware Patterns:
0x48, 0x4c, 0x4d (x86-64 64-bit operands)0x8b (MOV), 0x89 (MOV), 0xe8 (CALL)0xc0, 0x45, 0x5dCommon Binary Patterns:
0xcc 0xcc (INT3 debug breakpoints), 0x90 0x90 (NOP sleds)0x00 0x00 0x00 0x00 (NULL padding)0x00 at word boundariesString-Rich Vocabulary:
vs. binary-tokenizer-001 Series (this repository):
| Metric | 4K | 8K | 16K | 64K (this) | Improvement |
|---|---|---|---|---|---|
| Vocab size | 4,096 | 8,192 | 16,384 | 65,536 | 4-16x larger |
| Avg token length | 3.000 | 3.312 | 3.498 | 3.749 | +25% vs 4K |
| 3-byte tokens % | 20.6% | 21.7% | 20.5% | 16.5% | Different focus |
| 2-byte coverage | 3.0% | 5.6% | 10.9% | 43.6% | 14x better |
| Compression (ls) | 2.00 | 2.17 | 2.39 | 2.61 | +30% vs 4K |
| Training method | Standard | Standard | Standard | Chunked+dedup | Advanced |
Key Advantages of 64K Vocabulary:
If you use this tokenizer in your research, please cite:
@article{bommarito2025binarybpe,
title={Binary BPE: Cross-Platform Tokenization for Binary Analysis},
author={Bommarito II, Michael J.},
journal={arXiv preprint},
year={2025},
note={Preprint coming soon}
}
Also cite the original Glaurung tokenizer:
Glaurung Binary Tokenizer 002
64K Binary Tokenizer for Neural Language Models
Vocabulary: 65,536 tokens (256 base + 65,273 merges + 7 special)
Training: October-November 2025
Training Method: Chunked BPE with deduplication (bbpe v0.3.2)
Dataset: 23GB binaries-small (40,574 chunks, 8,454 duplicates)
Performance: 2.590 bytes/token (95% of theoretical optimum)
HuggingFace: mjbommar/glaurung-binary-tokenizer-002
Author: Michael J. Bommarito II ([email protected])
Apache License 2.0
This tokenizer is part of the Glaurung project.
Generated: November 13, 2025
Original Model: mjbommar/glaurung-binary-tokenizer-002
Training Tool: bbpe v0.3.2
Analysis Script: analyze_tokenizer.py