Downloads · 30 days
5
8% of all-time downloads
mjbommar/mimelens-001-tiny-byte-s2
mimelens-001-tiny-byte-s2 is a text classification model from mjbommar. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
A 3.15M-backbone-parameter BERT-style encoder for position-agnostic file-content-type detection from binary data. It reads a byte window taken from any offset in a file (the first ~1{,}022 tokens of whatever you pass)…
Downloads · 30 days
5
8% of all-time downloads
All-time downloads
63
Public
Parameters
3.3M
13.1 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors13.1 MB · 100%
From the Hugging Face model README
A 3.15M-backbone-parameter BERT-style encoder for position-agnostic file-content-type detection from binary data. It reads a byte window taken from any offset in a file (the first ~1{,}022 tokens of whatever you pass) and produces a 256-dimensional embedding that classifiers map to one of libmagic's 125 MIME labels. Designed for inputs where you only have a chunk: a forensic-carved fragment, a random disk-block read, a streaming HTTP upload, a single network packet payload.
mjbommar/mimelens-001-tiny-byte-s2mjbommar/mimelens-001 (36 released cells: 28 parent + 8 short-sequence)mjbommar/mimelens-trainingmjbommar/binary-30k-tokenized plus magic-corpus extracts, packed binaries, a glaurung-sourced binary corpus, and Windows drivers (33 GB stratified; the full corpus is not redistributable)MimeLens classifies file content type from a byte window taken at any offset, not just the header of a complete file.
Existing tools assume whole-file access at a known offset:
libmagic and Apache Tika match handcrafted magic-byte signatures, almost always anchored at the file head.These break down on a fragment. MimeLens is pretrained MLM-only on 1024-token windows sampled uniformly at random across files and 64 KB fragments, with no privileged head-of-file position. One checkpoint handles streaming, partial-arrival, mid-file, packet-payload, and forensic-carved inputs uniformly. The trade-off is CPU latency (roughly two orders of magnitude slower than Magika at the medium size; hardware-dependent) in exchange for libmagic's 125-class taxonomy plus position arbitrariness.
The family ships 28 parent cells (3 sizes × 4 vocabs × 2-3 seeds at seq_len=1024) plus an 8-cell short-sequence extension (medium tier × 4 vocabs × 2 seeds at seq_len=256). This README documents one of them.
Short-sequence sibling available. If your inputs are sub-KB (DNS payloads, sub-MTU packets, small forensic fragments), use
mjbommar/mimelens-001-tiny-byte-s2-seq256instead. Same architecture, 4× shorter context, ~5× lower CPU latency, BPE-cell accuracy ties or beats this cell on the magic-files probe-fit. See paper Appendix B.5.
tiny tier, byte input pipeline, seed 2byte. Raw 256-byte vocabulary plus 5 special tokens (CLS, SEP, PAD, UNK, MASK); id = byte_value + 5. The model reads exactly the first 1,022 bytes that arrive.| Benchmark | Value |
|---|---|
| MIME-125 top-1 (magic-frags, 4 KB head, n=4,096) | 0.739 |
| MIME-125 macro-F1 (magic-frags, 4 KB head) | 0.593 |
| kNN R@1 (magic-frags, 3,147-file gallery / 949 queries) | 0.679 |
Full evaluation (within-cube bootstrap CIs, adversarial sweep, calibration, real-network curves, disk-block matrix, baselines against libmagic 5.46 and TrID 2.24) is in the paper.
This cell publishes the encoder only (no classifier head baked in). Use it to extract embeddings, then fit a probe, run kNN over a labelled gallery, or fine-tune a head:
import torch
from transformers import AutoModel, AutoTokenizer
repo = "mjbommar/mimelens-001-tiny-byte-s2"
model = AutoModel.from_pretrained(repo, trust_remote_code=True).eval()
tok = AutoTokenizer.from_pretrained(repo)
window = open("path/to/file", "rb").read(4096)
inputs = tok(window.decode("latin-1"), max_length=1024, truncation=True,
padding="max_length", return_tensors="pt")
with torch.no_grad():
embedding = model(**inputs).pooler_output # (1, 256)
The pre-fit LR probe weights for this cell are not bundled here. The deployed cells and per-size winners (e.g. mimelens-001-medium-bpe-16k-s1) ship a baked classifier head for a one-line pipeline() path.
The model reads the first ~1{,}022 tokens of whatever you pass — a prefix of the buffer (the first 1{,}022 bytes for this byte cell), not the whole window.
application/octet-stream on a mostly-opaque window — correct behaviour for genuinely high-entropy input, not a bug.See the family hub README (mjbommar/mimelens-001) for the regime decision tree.
This cell is one point of the 3 × 4 × 2 factorial cube described in the paper.
binary-30k (assorted ELF/PE/Mach-O), magic-frags (random 64 KB chunks across libmagic's full corpus), assorted packed/raw binaries, a glaurung-sourced binary corpus, Windows drivers.[MASK], 10% random, 10% original); tied input/output embeddings.cls_pool linear projection is not used: under MLM-only training it receives no gradient and remains byte-identical to its random initialisation across all 28 cube cells (paper §3.4 verifies this; left in the saved weights for architectural completeness only).medium size is ~155× slower than Magika v1.1 on a desktop CPU (hardware-dependent). For sub-millisecond whole-file triage on broad categories, Magika is purpose-built and is the right tool. MimeLens occupies a different point on the deployment surface (position-arbitrary inputs + libmagic's 125-class taxonomy), not a drop-in replacement.@misc{bommarito2026mimelens,
title = {MimeLens: Position-Agnostic Content-Type Detection for Binary Fragments},
author = {Bommarito II, Michael J.},
year = {2026},
note = {https://github.com/mjbommar/mimelens-training},
}