Skip to main content

Bytewise MIME detector

CI License: Apache-2.0 PyPI version

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 code
  • artifacts/: immutable model release bundle
  • configs/, scripts/: reproducible experiments and evaluation
  • reports/: curated D3 reports from early pilots through Full-v3
  • docs/: research and repository-extraction documentation
  • tests/: 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

bytewise-0.2.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bytewise-0.2.0-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file bytewise-0.2.0.tar.gz.

File metadata

  • Download URL: bytewise-0.2.0.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

Hashes for bytewise-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e47974fce657ca44509243e45a708ba7326fb857be84f5880951a93e8006c4a8
MD5 ec1157e4cdb50f9c361c128e0ff65c0c
BLAKE2b-256 311d9b214a3efc827818166e1e4bfab62bcfd646517144f86433a42bfefa83d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bytewise-0.2.0.tar.gz:

Publisher: publish.yml on chrismattmann/bytewise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bytewise-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bytewise-0.2.0-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

Hashes for bytewise-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a4c3538ae5db9a631c1d4c2a3bdc475dd8428f972111b5f9854dbbc3176fd2b
MD5 ae8d84935b9941a524ad7bf54c28a220
BLAKE2b-256 3699328a3b79a2c606a835011667eba72aaa9378eb358a66231e47cbfff75a3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bytewise-0.2.0-py3-none-any.whl:

Publisher: publish.yml on chrismattmann/bytewise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page