TinyDetect: Lightweight AI Text and Image Detector Released with ONNX Runtime Web
By Mr.Xu Community Post
Published: · 17 views
Summary:Ritabrata Maiti has open-sourced TinyDetect, a tool that compresses existing RoBERTa-based text and Community Forensics image detection models for client-side execution using ONNX Runtime Web. The text model is reduced to 97MB, and the image model to 26MB, enabling AI detection without content uploads. The tool achieves text detection in ~60ms for ~100 tokens and image detection in ~200ms on a laptop, prioritizing privacy and offline usage while acknowledging limitations in handling short or hea
Technical Mechanism Analysis
The core innovation of TinyDetect lies in leveraging ONNX Runtime Web to enable client-side execution of AI models, addressing the privacy and latency issues associated with traditional cloud-based AI detection tools. Here are the technical details:
-
Model Compression and Optimization
- Text Model: The RoBERTa-based AI text detector is compressed from ~500MB to ~97MB. The process includes fine-tuning on a mix of human and AI corpora and applying WiSE-FT (weight-space interpolation) to prevent the model from drifting too far from its original performance. The word embedding matrix is extracted and stored as int4 precision, then dequantized in JavaScript and fed into the Transformer body. The Transformer body uses mixed-precision quantization, resulting in a final model size of ~75MB.
- Image Model: The Community Forensics ViT model is quantized and its output scores are calibrated, reducing it to 26MB. Image preprocessing (e.g., resizing, center cropping, and normalization) is done locally.
-
Runtime Optimization
- ONNX Runtime Web 1.30: Depending on device support, it uses either WebGPU builds or threaded WASM (WebAssembly). A service worker adds COOP/COEP headers to enable threaded WASM and caches model and runtime files. A warm-up run precompiles GPU shaders to speed up subsequent detections.
-
Performance
- On a laptop, a 100-token text check takes ~60ms, and an image check takes ~200ms. While the model performance degrades for short texts, heavily edited content, or new generators, its advantages in privacy and offline usage are significant.
Engineering Trade-offs and Real-world Performance
TinyDetect makes important trade-offs in model compression and runtime optimization:
- Model Accuracy vs. Compression Rate: By using mixed-precision quantization and weight-space interpolation, the model maintains high detection accuracy while significantly reducing its size. However, the compressed model shows noticeable performance degradation in handling complex or edge cases.
- Computational Resources vs. Latency: Local execution eliminates cloud-based latency but is constrained by the computational capabilities of client devices, potentially leading to suboptimal performance on low-end hardware.
- Privacy Protection vs. Functionality: Local execution enhances user privacy but limits the model's scalability and update capabilities.
Developer Implementation and Deployment Recommendations
For developers, TinyDetect offers a solution for implementing AI detection without the need for complex server infrastructure. Here are some deployment suggestions:
- Frontend Integration: TinyDetect can be easily integrated into web applications, with simple JavaScript calls enabling text and image detection functionality.
- Performance Optimization: It is recommended to run TinyDetect on high-performance devices for optimal performance. For mobile devices, consider using the native compilation feature of WebAssembly to improve speed.
- Model Updates: Since the model runs on the client side, updating the model requires users to download it again or use an incremental update mechanism, which should be considered in the design.
Conclusion
TinyDetect demonstrates the potential of implementing AI detection in scenarios where privacy and offline usage are prioritized. While it has limitations in handling complex or edge cases, its lightweight and local execution characteristics make it valuable in specific application contexts.
— END —Source: Reddit r/MachineLearning (2026-10-12)
Tags: #TinyDetect #ONNX Runtime #AI Detection #Model Compression #Client-side AI
Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.
Community Comments