Instructions to use YatoVoid/forsakeai-detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use YatoVoid/forsakeai-detector with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'YatoVoid/forsakeai-detector');
forsakeai-detector
desklib/ai-text-detector-v1.01 (MIT) as a 438 MB ONNX model for the browser. It powers the AI check in ForsakeAI, which runs it with Transformers.js on WebGPU.
All credit for the model and its training goes to desklib. The ONNX graph comes from GabeuxDev/ai-text-detector-v1.01-onnx (fp32, 1.7 GB).
What changed
The weights are stored as int8. The math still runs in fp32:
- Every large MatMul weight is int8 with one scale per output column, followed by a
DequantizeLinearnode. - The word embeddings are int8 with one scale per row, looked up first and then scaled.
Ordinary dynamic int8 quantization also rounds the activations, and that breaks this model. On 160 paragraphs its logits correlated with fp32 at only 0.64. Storing only the weights as int8 keeps the scores:
| Build | Size | Correlation with fp32 | Mean abs. logit diff | Max | Same side of 0 |
|---|---|---|---|---|---|
| fp32 | 1.7 GB | 1 | 0 | 0 | 100% |
| this repo | 438 MB | 0.9999 | 0.04 | 0.13 | 100% |
| dynamic int8 | 435 MB | 0.64 | 3.3 | 9.6 | 91% |
The script that builds it is scripts/detector-quantize.py.
Use
import { AutoModelForSequenceClassification, AutoTokenizer } from '@huggingface/transformers';
const tokenizer = await AutoTokenizer.from_pretrained('YatoVoid/forsakeai-detector');
const model = await AutoModelForSequenceClassification.from_pretrained('YatoVoid/forsakeai-detector', { dtype: 'fp32', device: 'webgpu' });
const { logits } = await model(tokenizer(['Text to check.'], { padding: true, truncation: true, max_length: 512 }));
const pAI = 1 / (1 + Math.exp(-logits.data[0]));
The output is one logit, mean-pooled as in the original model. Apply a sigmoid to get P(AI). Use Transformers.js 4.x: according to the GabeuxDev card, 3.x tokenizes DeBERTa differently from Python.
On an RTX 3050 laptop GPU, Chromium loads it in about 4 seconds from cache and scores a 120-word paragraph in about 0.3 seconds.
Limits
These are desklib's limits, not new ones. It reads at most 512 tokens per pass, it was trained mostly on English, and it gives probabilities, not proof. Other detectors will score the same text differently.
- Downloads last month
- 12
Model tree for YatoVoid/forsakeai-detector
Base model
microsoft/deberta-v3-large