Downloads ยท 30 days
0
mjbommar/binary-tokenizer-001-4k
binary-tokenizer-001-4k 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 mit.
A cross-platform BPE tokenizer for binary executables and machine code. Trained on 13 GB of diverse binaries spanning Linux, Windows, macOS, and Android platforms.
Downloads ยท 30 days
0
Access
Public
Updated Nov 13, 2025
Repo size
295 KB
Likes
0
Public
Click a slice to open those files.
.json295 KB ยท 98%
From the Hugging Face model README
A cross-platform BPE tokenizer for binary executables and machine code. Trained on 13 GB of diverse binaries spanning Linux, Windows, macOS, and Android platforms.
๐ Model: mjbommar/binary-tokenizer-001-4k
๐ 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 | 6.3% | Base bytes |
| 2 bytes | 1,974 | 48.3% | Byte pairs |
| 3 bytes | 841 | 20.6% | Complete x86-64 instructions |
| 4 bytes | 649 | 15.9% | Instructions with operands |
| 5 bytes | 95 | 2.3% | Complex patterns |
| 6 bytes | 86 | 2.1% | Complex patterns |
| 7 bytes | 40 | 1.0% | Complex patterns |
| 8 bytes | 59 | 1.4% | Complex patterns |
| 9+ bytes | 89 | 2.2% | Long patterns |
Average Token Length: 3.000 bytes
Content Categories:
Most Common Bytes in Tokens:
0x00 (NULL): 2,468 occurrences - Padding and alignment0xFF: 404 occurrences - Sentinel values0x48 (REX.W): 340 occurrences - x86-64 REX prefix0x8B (MOV): 233 occurrences - x86-64 MOV opcode0xCC (INT3): 170 occurrences - Debug breakpoint paddingN-byte Sequence Diversity:
| Length | Learned Tokens | Possible Sequences | Coverage |
|---|---|---|---|
| 1-byte | 256 | 256 | 100.00% |
| 2-byte | 1,974 | 65,536 | 3.01% |
| 3-byte | 841 | 16,777,216 | 0.005% |
| 4-byte | 649 | 4,294,967,296 | 0.000015% |
tokenizer-4096.json - Trained tokenizer model (286 KB)analysis_results.json - Detailed analysis statisticstraining.log - Training output logtraining_stats.txt - Training summaryLoad from HuggingFace Hub:
from tokenizers import Tokenizer
# Load directly from HuggingFace
tokenizer = Tokenizer.from_pretrained("mjbommar/binary-tokenizer-001-4k")
Load from local file:
# With bbpe CLI
bbpe encode --tokenizer tokenizer-4096.json /path/to/binary
bbpe info tokenizer-4096.json
Complete Python Example:
from tokenizers import Tokenizer
# Load from HuggingFace or local file
tokenizer = Tokenizer.from_pretrained("mjbommar/binary-tokenizer-001-4k")
# OR: tokenizer = Tokenizer.from_file("tokenizer-4096.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: 71272
Compression: 1.997 bytes/token
First 10 tokens:
Token 0: ID= 127 hex=7f (1 bytes)
Token 1: ID= 3732 hex=454c (2 bytes)
Token 2: ID= 70 hex=46 (1 bytes)
Token 3: ID= 2 hex=02 (1 bytes)
Token 4: ID= 392 hex=0101 (2 bytes)
Token 5: ID= 662 hex=000000000000000000 (9 bytes)
Token 6: ID= 265 hex=0300 (2 bytes)
Token 7: ID= 1369 hex=3e00 (2 bytes)
Token 8: ID= 279 hex=01000000 (4 bytes)
Token 9: ID= 48 hex=30 (1 bytes)
Decoded: 7f454c4602010100000000000000000003003e000100000030...
(ELF header: 7f 45 4c 46 = ELF magic bytes)
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}
}
Author: Michael J. Bommarito II ([email protected])
Generated: November 12, 2025
Training Script: train_tokenizers.sh
Analysis Script: analyze_tokenizer.py