Download README.md from ElderRyan/ProseGuard-ML: direct link, hf CLI and curl.
- Browser
- Download file 4.87 kB
-
https://huggingface.co/ElderRyan/ProseGuard-ML/resolve/main/README.md
- Command line
-
hf download hf://ElderRyan/ProseGuard-ML/README.md
-
curl -L -o README.md https://huggingface.co/ElderRyan/ProseGuard-ML/resolve/main/README.md
license: mit
language:
- en
- zh
- ja
pipeline_tag: text-classification
library_name: generic
tags:
- ai-detection
- machine-generated-text
- stylometry
- webassembly
- rust
- lightgbm
- treeshap
ProseGuard-ML
ProseGuard-ML is a zero-dependency Rust and WebAssembly engine for client-side AI-generated text detection and sentence-level attribution across English, Simplified Chinese, Traditional Chinese, and Japanese.
The entire compiled binary and quantized statistical parameters fit in 679 KiB (prose_guard_wasm.wasm, 389 KiB gzipped) and execute locally in 2.5 to 6.8 ms per document with zero network uploads.
- Live Demo: https://aidetect.rist.edu.rs
- Technical Report: Ryan Kung, AIDetect: Sub-Megabyte Client-Side AI Text Detection via Hashed Statistical Models, Calibrated Gradient Boosted Trees, and Exact TreeSHAP in WebAssembly (
RIST-CS-AI-2026-03). - Neural Companion Models:
ElderRyan/ProseGuard-mmBERT-small(distilled 22-layer multilingual encoder,51.8 MBWeb Q4) andElderRyan/ProseGuard-mmBERT-base(295.9 MBINT8 ONNX).
Architecture
ProseGuard-ML maps each input UTF-8 document onto a 28-dimensional feature vector backed by two immutable binary tables (weights/ml_tables.bin at 320 KiB and weights/gbdt_forest.bin at 154 KiB):
- Dual-Distribution Hashed PPM (
Dual-PPM): Orders 1 to 3 hashed Markov transition log-likelihood ratios with empirical Bayes shrinkage and conditional Shannon surprisal estimation. - Concave Distributional Mixture MLE: Estimates the document AI mixture fraction $\hat{\alpha} \in [0, 1]$ via damped Newton-Raphson iteration over smoothed unigram and bigram likelihoods.
- Surprisal Rhythm & Hurst Exponent: 9D conditional surprisal derivatives paired with a Rescaled-Range ($R/S$) Hurst exponent.
- Word Co-occurrence Network Topology: Local clustering coefficient and degree assortativity on sliding lexical graphs.
- Formatting-Invariant Signed Feature-Hashed NBSVM: 65,536-bucket Rademacher-signed sublinear TF n-gram linear scorer with zero-byte Traditional-to-Simplified CJK folding and Japanese Kana hash-salt isolation (
0x4A41_0000). - Out-of-Fold LightGBM + Exact Stack-Allocated TreeSHAP: A 115-tree calibrated gradient-boosted forest trained on disjoint folds with Isotonic + Platt tail calibration and exact path-dependent Shapley attributions in WebAssembly.
Repository Contents
prose_guard_wasm.wasm: Compiledwasm32-unknown-unknownrelease module (679 KiB).wasm-loader.js: Self-contained ES/CommonJS loader with SHA-256 and IEEE 802.3 CRC32 verification.weights/ml_tables.bin: Packed 65,536-bucket Dual-PPM, Mixture MLE, and NBSVM table (320 KiB).weights/gbdt_forest.bin: Calibrated 115-tree LightGBM forest with node cover statistics (154 KiB).rust_src/: Complete zero-dependency Rust source crate ([dependencies]inCargo.tomlis empty).
Quick Start (Node.js / Browser)
import './wasm-loader.js';
const ProseGuard = globalThis.ProseGuardWasm;
await ProseGuard.initWasmEngine();
const report = ProseGuard.analyzeArticle(
'Paste any English, Chinese, or Japanese article here for local inspection.',
{ genreCode: 0, sensitivityCode: 1 }
);
console.log({
aiPct: report.aiPct,
verdict: report.verdict,
mleAlphaPct: report.mleAlphaPct,
sentences: report.sentences,
});
Benchmark
On OOD-2026 Modern (338 human vs 56 AI passages, 2026 generators), ProseGuard-ML reaches 0.864 ROC-AUC and 39.3% TPR@1%FPR (95% CI 21 to 52%). That is below Oxidane/TMR (50.0%) and above e5-small-lora (25.0%). It misses all 12 Claude Opus 5 passages at 1% FPR. At a 0.5 threshold it flags 3.8% (7/183) of non-native PubMed papers.
Held-out splits (N=1,400, TPR@1%FPR): NLPCC-2025 Chinese 58.3%, C-ReD 97.1%, AnxForever 79.8%, RAID+MAGE 44.5%.
Use it as a 2 to 7 ms first pass and send borderline text to mmbert-small or mmbert-base. Commercial APIs (GPTZero, Originality.ai, Pangram, ZeroGPT) have not been tested on this split. Full caveats: main Model Card.
Limitations
Without deep transformer representations, sub-megabyte n-gram and rhythm models miss unseen frontier generators that deliberately suppress standard transition templates and vary sentence cadence (such as Claude Opus 5 in OOD-2026). For high-stakes verification against frontier models, pair ProseGuard-ML as a fast first-pass filter with ProseGuard-mmBERT-small or ProseGuard-mmBERT-base.
License
Released under the MIT License.
