Views
No views yet
mjbommar/binary-tokenizer-001-32k
📊 Dataset: mjbommar/binary-30k-tokenized
📄 Paper: Binary BPE: Cross-Platform Tokenization for Binary Analysis (arXiv preprint coming soon)mjbommar/binary-30k-tokenized<|start|>, <|end|>, <|pad|>, <|unk|>, <|cls|>, <|sep|>, <|mask|>)| Length | Count | Percentage | Description |
|---|---|---|---|
| 1 byte | 256 | 0.8% | Base bytes |
| 2 bytes | 13,428 | 41.0% | Byte pairs |
| 3 bytes | 6,380 | 19.5% | Complete x86-64 instructions |
| 4 bytes | 6,236 | 19.0% | Instructions with operands |
| 5 bytes | 1,763 | 5.4% | Complex patterns |
| 6 bytes | 1,395 | 4.3% | Complex patterns |
| 7 bytes | 676 | 2.1% | Complex patterns |
| 8 bytes | 963 | 2.9% | Complex patterns |
| 9+ bytes | 1,467 | 4.5% | Long patterns |
0x00 (NULL): 20,462 occurrences - Padding and alignment0xFF: 3,502 occurrences - Sentinel values0x48 (REX.W): 2,883 occurrences - x86-64 REX prefix0x8B (MOV): 1,934 occurrences - x86-64 MOV opcode0xCC (INT3): 1,366 occurrences - Debug breakpoint padding| Length | Learned Tokens | Possible Sequences | Coverage |
|---|---|---|---|
| 1-byte | 256 | 256 | 100.00% |
| 2-byte | 13,428 | 65,536 | 20.49% |
| 3-byte | 6,380 | 16,777,216 | 0.038% |
| 4-byte | 6,236 | 4,294,967,296 | 0.00015% |
tokenizer-32768.json - Trained tokenizer model (2.5 MB)analysis_results.json - Detailed analysis statisticstraining.log - Training output log (if available)training_stats.txt - Training summary (if available)1from tokenizers import Tokenizer
2
3# Load directly from HuggingFace
4tokenizer = Tokenizer.from_pretrained("mjbommar/binary-tokenizer-001-32k")1# With bbpe CLI
2bbpe encode --tokenizer tokenizer-32768.json /path/to/binary
3bbpe info tokenizer-32768.json1from tokenizers import Tokenizer
2
3# Load from HuggingFace or local file
4tokenizer = Tokenizer.from_pretrained("mjbommar/binary-tokenizer-001-32k")
5# OR: tokenizer = Tokenizer.from_file("tokenizer-32768.json")
6
7# Read binary file and decode as latin-1 (preserves all byte values 0-255)
8with open("/usr/bin/ls", "rb") as f:
9 data = f.read()
10 data_str = data.decode("latin-1")
11
12# Encode the binary data
13encoding = tokenizer.encode(data_str)
14print(f"File size: {len(data)} bytes")
15print(f"Total tokens: {len(encoding.ids)}")
16print(f"Compression: {len(data) / len(encoding.ids):.3f} bytes/token")
17
18# First 10 tokens
19for i, (token_id, token) in enumerate(zip(encoding.ids[:10], encoding.tokens[:10])):
20 token_bytes = token.encode("latin-1")
21 print(f" Token {i}: ID={token_id:5d} hex={token_bytes.hex():20s} ({len(token_bytes)} bytes)")
22
23# Decode tokens back to bytes
24decoded_str = tokenizer.decode(encoding.ids)
25decoded_bytes = decoded_str.encode("latin-1")
26assert decoded_bytes == data # Perfect reconstruction/usr/bin/ls (142,312 bytes):File size: 142312 bytes
Total tokens: 53184
Compression: 2.676 bytes/token
First 10 tokens:
Token 0: ID= 127 hex=7f (1 bytes)
Token 1: ID= 3732 hex=454c (2 bytes)
Token 2: ID= 4707 hex=4602 (2 bytes)
Token 3: ID= 392 hex=0101 (2 bytes)
Token 4: ID= 662 hex=000000000000000000 (9 bytes)
Token 5: ID= 265 hex=0300 (2 bytes)
Token 6: ID= 1369 hex=3e00 (2 bytes)
Token 7: ID= 279 hex=01000000 (4 bytes)
Token 8: ID= 48 hex=30 (1 bytes)
Token 9: ID= 109 hex=6d (1 bytes)
Decoded: 7f454c4602010100000000000000000003003e0001000000306d...
(ELF header: 7f 45 4c 46 = ELF magic bytes)1@article{bommarito2025binarybpe,
2 title={Binary BPE: Cross-Platform Tokenization for Binary Analysis},
3 author={Bommarito II, Michael J.},
4 journal={arXiv preprint},
5 year={2025},
6 note={Preprint coming soon}
7}train_tokenizers.sh
Analysis Script: analyze_tokenizer.py