Bytewise MIME detector
Bytewise is a standalone neural MIME detector trained on raw file bytes. It does not require Java, a Tika server, a filename, or a file extension. The repository preserves its complete research lineage: BFA/BFC baselines, neural experiments, strict-host validation, deduplication audits, and D3 reports.
The frozen v1 model is a compact Transformer trained on the first 4,096 bytes of 863,871 TREC-DD POLAR payloads. It predicts 57 MIME classes.
Usage
Homebrew Python is an externally managed environment and must not be modified
with pip --break-system-packages. For the command-line application, install
Bytewise into an isolated Python 3.12 environment with uv:
uv tool install --python 3.12 "bytewise[metal]"
uv tool update-shell
Open a new terminal (or add $HOME/.local/bin to PATH) and verify it:
bytewise --version
bytewise model-info
Choose the runtime extra for the target platform:
# Apple Silicon GPU
python -m pip install "bytewise[metal]"
# Linux with an NVIDIA GPU and a current NVIDIA driver
python -m pip install "bytewise[cuda]"
# CPU inference on Linux or Windows
python -m pip install "bytewise[inference]"
The metal extra pins the validated TensorFlow 2.18 and tensorflow-metal
1.2 runtime. The cuda extra installs TensorFlow's pip-managed CUDA and cuDNN
libraries; the host still needs a compatible NVIDIA driver. Confirm CUDA is
visible with:
python -c 'import tensorflow as tf; print(tf.config.list_physical_devices("GPU"))'
For development or library use, keep the dependency in a project environment:
cd "$HOME/git/bytewise"
uv sync --python 3.12 --extra metal --group tests
uv run bytewise model-info
uv run python
Inside that uv run python session:
from bytewise import Detector
detector = Detector.load_default()
result = detector.detect_file("document.bin")
print(result.mime_type)
print(result.confidence)
print(result.alternatives)
The same model is available from the command line:
bytewise detect document.bin image.dat
bytewise detect document.bin --top-k 5 --threshold 0.80 --json
cat unknown.bin | bytewise detect -
bytewise supported
bytewise model-info
Routine TensorFlow startup diagnostics are suppressed so CLI output remains script-friendly. To diagnose device selection or CUDA loading, enable them for one invocation:
bytewise detect --tensorflow-logs document.bin
Allow uncertain inputs to abstain so another detector can handle them:
detector = Detector.load_default(confidence_threshold=0.80)
result = detector.detect_bytes(payload)
if result.abstained:
# Fall back to tika-python, libmagic, or another detector.
pass
Frozen v1 model
The selected model is polar-byte-transformer-seed550-v1:
- Validation accuracy: 96.77%
- Independent-reference accuracy: 94.59%
- Input: first 4,096 raw bytes
- Labels: 57 MIME types
- Model SHA-256:
72a2f5f2dd0fbb4ffaf88488618bc8e034c03876c7cea94d11da23439ed5b849
See the model card and Full-v3 report for the complete evidence.
Repository organization
src/bytewise/: production API and migrated byte-frequency research codeartifacts/: immutable model release bundleconfigs/,scripts/: reproducible experiments and evaluationreports/: curated D3 reports from early pilots through Full-v3docs/: research and repository-extraction documentationtests/: standalone production and research regression tests
Dataset bytes, feature caches, databases, raw predictions, and transient logs are intentionally kept outside Git.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bytewise-0.2.1.tar.gz.
File metadata
- Download URL: bytewise-0.2.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797d27334ff4f468f1b70186a344b73c33b1efe0d2ddc48b3b02e7369b5291b9
|
|
| MD5 |
c53f4dd6bd58b7e336e3f0ad27867d4f
|
|
| BLAKE2b-256 |
b23c893b7a525d39580c7dbdfe6029380bfaec5e262b059ba2fb6e6d8664f59e
|
Provenance
The following attestation bundles were made for bytewise-0.2.1.tar.gz:
Publisher:
publish.yml on chrismattmann/bytewise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytewise-0.2.1.tar.gz -
Subject digest:
797d27334ff4f468f1b70186a344b73c33b1efe0d2ddc48b3b02e7369b5291b9 - Sigstore transparency entry: 2341703526
- Sigstore integration time:
-
Permalink:
chrismattmann/bytewise@eeec5526113ca24f2604aadddc900f0a27fb29b1 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/chrismattmann
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eeec5526113ca24f2604aadddc900f0a27fb29b1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bytewise-0.2.1-py3-none-any.whl.
File metadata
- Download URL: bytewise-0.2.1-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bd0de23a6cb28650a687b8f2e56ae7c29f4ef9dc7fba0bcc34154e43e82cde4
|
|
| MD5 |
693d37996c8094943c67f83570825807
|
|
| BLAKE2b-256 |
74b83c6737cef29826ab0448a5b5c690bc79711036921761dd5d9e0ddf6bab3a
|
Provenance
The following attestation bundles were made for bytewise-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on chrismattmann/bytewise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytewise-0.2.1-py3-none-any.whl -
Subject digest:
0bd0de23a6cb28650a687b8f2e56ae7c29f4ef9dc7fba0bcc34154e43e82cde4 - Sigstore transparency entry: 2341703538
- Sigstore integration time:
-
Permalink:
chrismattmann/bytewise@eeec5526113ca24f2604aadddc900f0a27fb29b1 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/chrismattmann
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eeec5526113ca24f2604aadddc900f0a27fb29b1 -
Trigger Event:
release
-
Statement type: