Goyal commited on
Commit
15ca46e
·
verified ·
1 Parent(s): 669fd78

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +120 -0
README.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language: en
4
+ tags:
5
+ - ai-detection
6
+ - text-classification
7
+ - regression
8
+ base_model: microsoft/deberta-v3-base
9
+ datasets:
10
+ - rounaksaha12/giga-editlens
11
+ ---
12
+
13
+ # deberta-v3-detect
14
+
15
+ Predicts a **continuous score in [0, 1]** for how much AI contributed to a
16
+ document, rather than a binary AI/human verdict. A full fine-tune of
17
+ [DeBERTa-v3-base](https://huggingface.co/microsoft/deberta-v3-base) (184M) with
18
+ an 11-bin soft ordinal head: targets are Gaussian-smoothed over the bins,
19
+ trained with KL divergence, and decoded by expected value. Mean pooling over
20
+ the final hidden states.
21
+
22
+ Code, evaluation harness and full reports:
23
+ https://github.com/darkengross/ai_detector
24
+
25
+ ## Which model should you use?
26
+
27
+ This is the **fast** option. A Qwen3-4B decoder trained identically ranks
28
+ better on every evaluation set, at ~5.5x the inference cost:
29
+
30
+ | Spearman | this (DeBERTa-v3, 184M) | [qwen3-4b-detect](https://huggingface.co/Khushal2403/qwen3-4b-detect) |
31
+ |---|---|---|
32
+ | In-domain test | 0.9324 | **0.9592** |
33
+ | APT-Eval | 0.6029 | **0.7986** |
34
+ | BEEMO | 0.5889 | **0.7168** |
35
+ | CoAuthor | 0.3059 | **0.3907** |
36
+ | Throughput | **~55 samples/s** | ~10 samples/s |
37
+
38
+ Use this one when throughput or memory matters, or as a baseline. Use the
39
+ decoder when out-of-domain accuracy matters more than latency.
40
+
41
+ MAE for this model: 0.0969 in-domain, 0.2302 APT-Eval, 0.2200 BEEMO, 0.1933
42
+ CoAuthor.
43
+
44
+ **Read Spearman, not thresholded accuracy.** Spearman is threshold- and
45
+ calibration-free. Fixed Human/Mixed/AI cut points are misleading here because
46
+ the predicted-score distribution sits differently on each domain.
47
+
48
+ ## Contents
49
+
50
+ | File | What it is |
51
+ |---|---|
52
+ | `checkpoint.pt` | `model_state` (backbone + head), plus `backbone` and `k_bins` |
53
+ | `tokenizer.json`, etc. | DeBERTa-v3 tokenizer, saved beside the checkpoint |
54
+
55
+ `checkpoint.pt` is a PyTorch pickle, so the Hub flags it as a format that can
56
+ execute code on load. Load it only if you trust this repo, or inspect it first
57
+ with `torch.load(..., weights_only=True)`.
58
+
59
+ ## Known limits
60
+
61
+ - **Out-of-domain scores are poorly calibrated even where ranking is
62
+ acceptable.** Fit a calibration layer on held-out target-domain data before
63
+ reading a raw score as a percentage. On CoAuthor the fitted affine scale is
64
+ 0.30, meaning most of the raw spread there is not signal.
65
+ - **Light-touch assistance is underestimated.** CoAuthor is the weakest case
66
+ (0.31): its AI insertions average ~10-word spans, versus ~3-word edits in
67
+ training.
68
+ - **Unseen generators are under-detected.**
69
+ - Trained on English text of 50+ words. Shorter inputs are out of scope.
70
+
71
+ ## Provenance and licensing
72
+
73
+ Released for **non-commercial research use** (CC BY-NC 4.0). That reflects the
74
+ training data's lineage rather than a preference:
75
+
76
+ - Trained on
77
+ [rounaksaha12/giga-editlens](https://huggingface.co/datasets/rounaksaha12/giga-editlens),
78
+ which **declares no license**. No license is not the same as permissive -- it
79
+ means no explicit grant of rights was given.
80
+ - That dataset derives its human text from
81
+ [FineWeb](https://huggingface.co/datasets/HuggingFaceFW/fineweb), which is
82
+ **ODC-By 1.0** and requires attribution. Attribution is given here; whether
83
+ trained weights constitute a "derivative database" under ODC-By is unsettled.
84
+ - Its `ai_generated` and `ai_edited` rows were produced by LLMs recorded in the
85
+ dataset's `model` column. **If any generator's terms of service restrict
86
+ using its outputs to train competing models, that restriction flows through
87
+ to these weights.** This has not been verified, and is the main reason not to
88
+ assume these weights are safe for commercial use.
89
+
90
+ The DeBERTa-v3-base model is MIT and poses no constraint. The evaluation sets
91
+ -- BEEMO (MIT), APT-Eval (MIT), CoAuthor (Stanford terms) -- were used only for
92
+ measurement, are not redistributed here, and are not represented in the
93
+ weights.
94
+
95
+ Anyone considering commercial use should resolve the giga-editlens license gap
96
+ and the generator-terms question first. This is a description of what was
97
+ used, not legal advice.
98
+
99
+ ## Usage
100
+
101
+ ```bash
102
+ hf download Khushal2403/deberta-v3-detect --local-dir ./deberta-v3-detect
103
+ git clone https://github.com/darkengross/ai_detector && cd ai_detector/src
104
+ python eval/run_eval.py --arch encoder \
105
+ --checkpoint-dir ../../deberta-v3-detect --batch-size 128
106
+ ```
107
+
108
+ Scoring a single document:
109
+
110
+ ```python
111
+ import torch, sys; sys.path.insert(0, "ai_detector/src")
112
+ from common.checkpoints import load_model
113
+ from common.binning import bin_centers
114
+ from common.loop import predict_scores
115
+
116
+ device = torch.device("cuda")
117
+ model, tok, k = load_model("encoder", "./deberta-v3-detect", device)
118
+ scores, _ = predict_scores(model, [my_text], tok, bin_centers(k, device=device), device)
119
+ print(f"AI contribution: {scores[0]:.3f}")
120
+ ```