Instructions to use secrets2/mesmer-ai-detector-4b-mlx-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use secrets2/mesmer-ai-detector-4b-mlx-8bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download secrets2/mesmer-ai-detector-4b-mlx-8bit --local-dir mesmer-ai-detector-4b-mlx-8bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Mesmer AI Detector 4B, MLX 8-bit
An unofficial MLX conversion of mesmertech/mesmer-ai-detector-4b for Apple silicon. It tells you whether English text is human-written, AI-written or AI-edited. All credit for the model goes to its authors; read the original card for training data, intended use and limitations.
Document-level only. The original also labels each sentence. That head is not ported here; this repo gives the document verdict and the three probabilities.
What was converted
- The weights are Mesmer's official int8 file (
int8/model.safetensors), packed into MLX 8-bit affine quantization without re-quantizing: codeq + 128, scalebf16(s), bias-128 * bf16(s). The only change is that each per-row scale is rounded to bf16. - Two numerics follow the torch reference instead of mlx-lm's defaults: the zero-centred RMSNorms keep
1 + win fp32 and compute in fp32, andA_log/dt_biasstay fp32. - Text normalization, tokenization, EOS pooling and the default verdict thresholds (
policy.json) are Mesmer's own.
Parity with the original
Same 199 validation texts, first 512 tokens, against the original torch int8 model:
| torch int8 (original) | this MLX port | |
|---|---|---|
| AUROC | 0.9524 | 0.9516 |
| TPR at 1% FPR | 86.3% | 86.3% |
| verdict agreement | 100% | |
| max / mean abs score difference | 0.022 / 0.0013 |
The uploaded files were re-checked after export against the port's own scores on the same 199 texts: verdicts 100% identical, max score difference 0.011.
4-bit versions were also tried and failed this check (q4g64: TPR -5.5 points; q4g32: AUROC -0.007), so only 8-bit is published.
Public benchmarks (partial)
Run with this port, first 512 tokens, on sample subsets (n shown), using Pangram's Open Pangram evaluation protocol. The full-set run is not finished, so treat these as a sanity check, not a replacement for the original card.
| Benchmark | Metric | This port | n | Original card (4B) |
|---|---|---|---|---|
| EditLens test | 3-way accuracy | 0.915 | 728 | 0.918 |
| EditLens Enron | 3-way accuracy | 0.893 | 600 | 0.912 |
| EditLens Llama | 3-way accuracy | 0.920 | 600 | 0.929 |
| Liang TOEFL | FPR | 0.044 | 91 | 0.044 |
| Human detectors | macro-F1 / FPR | 0.963 / 0.073 | 300 | 0.973 / 0.053 |
| RAID (10k sample) | macro-F1 / FNR | 0.998 / 0.003 | 592 | 0.994 / 0.003 |
Speed and memory (M4, 16 GB)
- 4.2 GB of weights; 4.6 to 5.4 GiB while scoring.
- About 1.0 s per document at up to 512 tokens (360 tokens/s) and 3.3 s at 1,024 tokens on an otherwise idle machine; 3.7 s per document at 512 tokens when other jobs were using memory.
Use
pip install mlx mlx-lm tokenizers emoji numpy huggingface_hub
hf download secrets2/mesmer-ai-detector-4b-mlx-8bit mesmer_mlx.py --local-dir .
python mesmer_mlx.py --model secrets2/mesmer-ai-detector-4b-mlx-8bit "Paste the text to check here."
from mesmer_mlx import MesmerMLX
det = MesmerMLX.from_pretrained("secrets2/mesmer-ai-detector-4b-mlx-8bit")
det.analyze(text) # {"verdict": "human" | "ai" | "ai_edited", "probs": {...}}
det.predict(texts) # [N, 3] probabilities from each text's first 1,023 tokens
Needs an mlx-lm release with Qwen3.5 support (tested with mlx 0.32.4, mlx-lm 0.32.2). Long texts are truncated, not
windowed as in the original Detector.analyze.
Limitations
The original card's limitations apply: English only, unreliable below about 50 words, and it flags more human writing than Pangram, mostly academic abstracts, news and poetry. No detector is proof. Never use a result as the only evidence against anyone.
License
CC BY-NC-SA 4.0, inherited from the original model: non-commercial use, with attribution and share-alike.
- Downloads last month
- 17
Quantized