liamdugan commited on
Commit
9baaff9
·
verified ·
1 Parent(s): 0770a87

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +107 -108
README.md CHANGED
@@ -2,125 +2,124 @@
2
  library_name: detectorscope
3
  license: gemma
4
  base_model: google/gemma-2-2b
 
5
  tags:
6
  - ai-text-detection
7
  - sparse-autoencoder
8
  - interpretability
9
  ---
10
 
11
- # COLING · Gemma-2 base
12
 
13
- An auditable AI-text detector from *Building Auditable AI Text Detectors with
14
- Sparse Autoencoders*: a Gemma-2-2b language model with hooks (bundled under
15
- `extractor/`; Gemma Terms of Use, see `NOTICE`), one JumpReLU sparse
16
- autoencoder per hooked layer (from [Gemma
17
- Scope](https://huggingface.co/google/gemma-scope-2b-pt-res), CC-BY-4.0, as
18
- are the heads), and sparse heads over the max-pooled SAE features. Every decision is the sum
19
- of per-feature contributions, each with a validated natural-language
20
- description.
 
 
 
21
 
22
  ```python
23
- from detectorscope import AuditableDetector # pip install detectorscope
24
 
25
  det = AuditableDetector.from_pretrained("liamdugan/detector-scope")
26
  out = det("The authors propose a novel framework for ...")
27
- out.p_ai, out.label # P(AI); "ai" or "human" at the head's threshold
28
- out.features[:3] # Feature(id, importance, description, highlights), |importance| descending
 
 
29
  ```
30
 
31
- `head="xgboost"` or `tau=0.5` on `from_pretrained` or on the call pick
32
- another head below; `return_highlights=True` adds `out.tokens` and, per
33
- feature, the `(token index, activation)` pairs where it fires.
34
-
35
- ## Branches
36
-
37
- Each branch of this repo is a complete detector: `main` is the paper's
38
- flagship setting (fine-tuned model and fine-tuned SAEs); `ft-sae` keeps
39
- `google/gemma-2-2b` with the fine-tuned SAEs and `base-sae` keeps it with the
40
- Gemma Scope SAEs. For the peer-review repo the branch also names the target
41
- generator (`llama`, `gpt4o-ft-sae`, ...; `gpt4o` is `main`). Pass the branch
42
- as `revision=` to `from_pretrained`.
43
-
44
- ## Files
45
-
46
- - `extractor/`: the language model as a transformers checkpoint
47
- (`AutoModelForSequenceClassification.from_pretrained(repo, subfolder="extractor")`
48
- for the fine-tuned ones).
49
- - `model.safetensors`: the SAEs, read into `AuditableDetector` by
50
- `from_pretrained` (`config.json` holds the hook points and default head).
51
- - `heads/<type>_tau<tau>.<safetensors|json>`: one head per type and
52
- auto-interpretation threshold tau; each carries its decision threshold.
53
- - `features.jsonl`: one record per described SAE feature, verbatim from the
54
- auto-interpretation stage, with its log-odds ratio on the training split.
55
-
56
- ## Heads
57
-
58
- The default is logreg at tau 0.85, the paper's operating point.
59
-
60
- | head | tau | decision threshold (logit) | source |
61
- |---|---|---|---|
62
- | logreg | 0.00 | 0.3011 | `sgd_lr1e-02_l1-1e-01_threshold0.0_coling_logreg_ep3.pkl` |
63
- | logreg | 0.05 | 0.2593 | `sgd_lr1e-02_l1-1e-01_threshold0.05_coling_logreg_ep3.pkl` |
64
- | logreg | 0.10 | 0.2527 | `sgd_lr1e-02_l1-1e-01_threshold0.10_coling_logreg_ep3.pkl` |
65
- | logreg | 0.15 | 0.2481 | `sgd_lr1e-02_l1-1e-01_threshold0.15_coling_logreg_ep3.pkl` |
66
- | logreg | 0.20 | 0.2511 | `sgd_lr1e-02_l1-1e-01_threshold0.20_coling_logreg_ep3.pkl` |
67
- | logreg | 0.25 | 0.2512 | `sgd_lr1e-02_l1-1e-01_threshold0.25_coling_logreg_ep3.pkl` |
68
- | logreg | 0.30 | 0.2572 | `sgd_lr1e-02_l1-1e-01_threshold0.30_coling_logreg_ep3.pkl` |
69
- | logreg | 0.35 | 0.3022 | `sgd_lr1e-02_l1-1e-01_threshold0.35_coling_logreg_ep3.pkl` |
70
- | logreg | 0.40 | 0.2969 | `sgd_lr1e-02_l1-1e-01_threshold0.40_coling_logreg_ep3.pkl` |
71
- | logreg | 0.45 | 0.2839 | `sgd_lr1e-02_l1-1e-01_threshold0.45_coling_logreg_ep3.pkl` |
72
- | logreg | 0.50 | 0.3375 | `sgd_lr1e-02_l1-1e-01_threshold0.50_coling_logreg_ep3.pkl` |
73
- | logreg | 0.55 | 0.3544 | `sgd_lr1e-02_l1-1e-01_threshold0.55_coling_logreg_ep3.pkl` |
74
- | logreg | 0.60 | 0.3616 | `sgd_lr1e-02_l1-1e-01_threshold0.60_coling_logreg_ep3.pkl` |
75
- | logreg | 0.65 | 0.3854 | `sgd_lr1e-02_l1-1e-01_threshold0.65_coling_logreg_ep3.pkl` |
76
- | logreg | 0.70 | 0.3597 | `sgd_lr1e-02_l1-1e-01_threshold0.70_coling_logreg_ep3.pkl` |
77
- | logreg | 0.75 | 0.4081 | `sgd_lr1e-02_l1-1e-01_threshold0.75_coling_logreg_ep3.pkl` |
78
- | logreg | 0.80 | 0.4447 | `sgd_lr1e-02_l1-1e-01_threshold0.80_coling_logreg_ep3.pkl` |
79
- | logreg | 0.85 | 0.5008 | `sgd_lr1e-02_l1-1e-01_threshold0.85_coling_logreg_ep3.pkl` |
80
- | logreg | 0.90 | 0.5354 | `sgd_lr1e-02_l1-1e-01_threshold0.90_coling_logreg_ep3.pkl` |
81
- | logreg | 0.95 | inf | `sgd_lr1e-02_l1-1e-01_threshold0.95_coling_logreg_ep3.pkl` |
82
- | xgboost | 0.00 | 0.6842 | `threshold0.0_coling_xgbmodel.pkl` |
83
- | xgboost | 0.05 | 0.7290 | `threshold0.05_coling_xgbmodel.pkl` |
84
- | xgboost | 0.10 | 0.7455 | `threshold0.1_coling_xgbmodel.pkl` |
85
- | xgboost | 0.15 | 0.7075 | `threshold0.15_coling_xgbmodel.pkl` |
86
- | xgboost | 0.20 | 0.7255 | `threshold0.2_coling_xgbmodel.pkl` |
87
- | xgboost | 0.25 | 0.6771 | `threshold0.25_coling_xgbmodel.pkl` |
88
- | xgboost | 0.30 | 0.5776 | `threshold0.3_coling_xgbmodel.pkl` |
89
- | xgboost | 0.35 | 0.6960 | `threshold0.35_coling_xgbmodel.pkl` |
90
- | xgboost | 0.40 | 0.7782 | `threshold0.4_coling_xgbmodel.pkl` |
91
- | xgboost | 0.45 | 0.8097 | `threshold0.45_coling_xgbmodel.pkl` |
92
- | xgboost | 0.50 | 0.8531 | `threshold0.5_coling_xgbmodel.pkl` |
93
- | xgboost | 0.55 | 0.8291 | `threshold0.55_coling_xgbmodel.pkl` |
94
- | xgboost | 0.60 | 0.7867 | `threshold0.6_coling_xgbmodel.pkl` |
95
- | xgboost | 0.65 | 0.7935 | `threshold0.65_coling_xgbmodel.pkl` |
96
- | xgboost | 0.70 | 0.8680 | `threshold0.7_coling_xgbmodel.pkl` |
97
- | xgboost | 0.75 | 0.7816 | `threshold0.75_coling_xgbmodel.pkl` |
98
- | xgboost | 0.80 | 0.8019 | `threshold0.8_coling_xgbmodel.pkl` |
99
- | xgboost | 0.85 | 0.6463 | `threshold0.85_coling_xgbmodel.pkl` |
100
- | xgboost | 0.90 | 0.1872 | `threshold0.9_coling_xgbmodel.pkl` |
101
- | xgboost | 0.95 | 0.6281 | `threshold0.95_coling_xgbmodel.pkl` |
102
-
103
- ## Features with the largest weights (default head)
104
-
105
- | id | weight | description |
106
- |---|---|---|
107
- | 20122 | +0.1577 | introductory phrases or filler text commonly used by ai language models when declining personal questions |
108
- | 17929 | +0.1263 | academic and scientific research methodology and technical analysis terminology |
109
- | 1262 | -0.1218 | contractions containing the letter n and apostrophe specifically focusing on the n't ending |
110
- | 9535 | -0.1091 | newline characters in scientific or technical text |
111
- | 1076 | +0.0803 | conversational filler phrases used in informal speech |
112
- | 14666 | -0.0796 | wikipedia category and navigation section headers |
113
- | 14967 | -0.0780 | comma punctuation following a newline or preceding sentence start |
114
- | 44946 | +0.0648 | critical commentary or argumentative analysis of student policies and social responsibility |
115
- | 32030 | -0.0596 | markdown editing and formatting indicators |
116
- | 5896 | -0.0593 | newline characters in scientific or technical text |
117
- | 7178 | -0.0549 | parenthetical clauses or aside remarks in text |
118
- | 10954 | -0.0481 | neuron fires on the digit 0 inside url placeholders like url 0 |
119
- | 41406 | +0.0452 | neuron activates on random text fragments and noisy character sequences often found in garbled or fragmented data |
120
- | 15058 | -0.0435 | wikipedia category and list formatting specifically numerical prefixes and lists |
121
- | 7991 | +0.0381 | reads more or similar web page navigation links |
122
- | 13528 | -0.0321 | tokenized components of medical or diagnostic phrasing and lists |
123
- | 33943 | +0.0309 | repeated phrases or sequences in text |
124
- | 25049 | -0.0302 | newline characters and line breaks within technical or academic documents |
125
- | 6780 | -0.0298 | commas occurring within parenthetical or descriptive clauses |
126
- | 27535 | -0.0296 | newline characters in mathematical or technical contexts |
 
2
  library_name: detectorscope
3
  license: gemma
4
  base_model: google/gemma-2-2b
5
+ pipeline_tag: text-classification
6
  tags:
7
  - ai-text-detection
8
  - sparse-autoencoder
9
  - interpretability
10
  ---
11
 
12
+ # detector-scope
13
 
14
+ Detects AI-generated text across domains and generators (trained on the COLING 2025 GenAI Detection shared task: news, essays, reviews and more, written by people or by 40 language models). The unmodified Gemma-2-2b, sparse autoencoders fine-tuned on this data, and a sparse logistic-regression head over their features: the best general-domain detector of the paper. Every prediction is a sum of contributions from sparse-autoencoder
15
+ features, each with a validated natural-language description, so the detector
16
+ can say which properties of the text drove its decision and where they occur.
17
+ Paper: [Building Auditable AI Text Detectors with Sparse Autoencoders](https://arxiv.org/abs/2610.30006);
18
+ code: [google-deepmind/detectorscope](https://github.com/google-deepmind/detectorscope).
19
+
20
+ ## Use
21
+
22
+ ```bash
23
+ pip install detectorscope
24
+ ```
25
 
26
  ```python
27
+ from detectorscope import AuditableDetector
28
 
29
  det = AuditableDetector.from_pretrained("liamdugan/detector-scope")
30
  out = det("The authors propose a novel framework for ...")
31
+
32
+ out.p_ai # probability that the text is AI-written
33
+ out.label # "ai" or "human" (logit threshold +0.50)
34
+ out.features # [Feature(id, importance, description, highlights), ...]
35
  ```
36
 
37
+ `out.features` lists every feature active in the text with a non-zero effect,
38
+ largest effect first. `importance` is how much the logit falls if that feature
39
+ is silenced: positive pushes toward AI, negative toward human, and
40
+ `out.logit == out.bias + sum(f.importance for f in out.features)`. A list of
41
+ texts returns a list of detections.
42
+
43
+ To see where a feature fires:
44
+
45
+ ```python
46
+ out = det(text, return_highlights=True)
47
+ out.tokens # the text as a list of tokens
48
+ out.features[0].highlights # [(token index, activation), ...] of the top feature
49
+ ```
50
+
51
+ The default head is logistic regression over the features whose
52
+ auto-interpretation score is at least 0.85. `head="xgboost"` or another
53
+ `tau` (0.00 to 0.95 in steps of 0.05), on `from_pretrained` or on the call,
54
+ selects one of the other 39 heads.
55
+
56
+ ## Performance
57
+
58
+ Default head; the decision threshold is fixed on the development data.
59
+
60
+ | split | AUROC | F1 | accuracy | documents |
61
+ |---|---|---|---|---|
62
+ | COLING dev | 0.932 | 0.867 | 0.839 | 261,758 |
63
+ | COLING dev-test | 0.916 | 0.866 | 0.854 | 32,557 |
64
+ | COLING test | 0.857 | 0.751 | 0.770 | 73,941 |
65
+
66
+ ## What it looks at
67
+
68
+ The features with the largest average contribution on the training data
69
+ (weight × mean activation when active; density = share of the documents of
70
+ each class in which the feature fires).
71
+
72
+ **Toward AI**
73
+
74
+ | feature | description | mean contribution | AI density | human density |
75
+ |---|---|---|---|---|
76
+ | 13_3738 | introductory phrases or filler text commonly used by ai language models when declining personal questions | +0.987 | 25% | 2% |
77
+ | 13_1545 | academic and scientific research methodology and technical analysis terminology | +0.909 | 13% | 3% |
78
+ | 17_12178 | critical commentary or argumentative analysis of student policies and social responsibility | +0.558 | 38% | 11% |
79
+ | 17_8638 | neuron activates on random text fragments and noisy character sequences often found in garbled or fragmented data | +0.372 | 13% | 13% |
80
+ | 17_1175 | repeated phrases or sequences in text | +0.363 | 41% | 31% |
81
+ | 13_2153 | exclamation points used at the end of emotional or emphatic sentences | +0.318 | 16% | 15% |
82
+ | 22_9579 | markdown formatting for headers or list items | +0.297 | 25% | 13% |
83
+ | 7_1076 | conversational filler phrases used in informal speech | +0.261 | 15% | 13% |
84
+ | 7_7991 | reads more or similar web page navigation links | +0.239 | 8% | 7% |
85
+ | 17_4337 | introductory transition words signaling a summary or final thought | +0.210 | 25% | 7% |
86
+
87
+ **Toward human**
88
+
89
+ | feature | description | mean contribution | AI density | human density |
90
+ |---|---|---|---|---|
91
+ | 7_14967 | comma punctuation following a newline or preceding sentence start | -1.563 | 3% | 14% |
92
+ | 7_10954 | neuron fires on the digit 0 inside url placeholders like url 0 | -0.951 | 1% | 5% |
93
+ | 7_9535 | newline characters in scientific or technical text | -0.842 | 1% | 11% |
94
+ | 7_1262 | contractions containing the letter n and apostrophe specifically focusing on the n't ending | -0.785 | 3% | 14% |
95
+ | 7_5896 | newline characters in scientific or technical text | -0.658 | 1% | 11% |
96
+ | 13_11151 | newline characters in mathematical or technical contexts | -0.473 | 2% | 12% |
97
+ | 7_14666 | wikipedia category and navigation section headers | -0.454 | 4% | 10% |
98
+ | 22_3894 | semicolon followed by a newline character | -0.394 | 3% | 10% |
99
+ | 17_15548 | opening double quotation marks following a closing single quote and comma | -0.374 | 1% | 4% |
100
+ | 13_15646 | markdown editing and formatting indicators | -0.366 | 14% | 29% |
101
+
102
+ ## Variants
103
+
104
+ Branches of this repo hold the paper's other two settings on the same data: `ft-model-sae` (Gemma-2-2b fine-tuned as a classifier, with SAEs fine-tuned on it) and `base-sae` (the unmodified Gemma-2-2b with the Gemma Scope SAEs). Load one with `revision="ft-model-sae"` or `revision="base-sae"`. For reviews of machine-learning papers use [detector-scope-peer-review-gpt4o](https://huggingface.co/liamdugan/detector-scope-peer-review-gpt4o) or [detector-scope-peer-review-llama](https://huggingface.co/liamdugan/detector-scope-peer-review-llama).
105
+
106
+ ## Licence
107
+
108
+ The language model under `extractor/` is Gemma-2-2b, provided under
109
+ and subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms)
110
+ (see `NOTICE`). The sparse autoencoders derive from
111
+ [Gemma Scope](https://huggingface.co/google/gemma-scope-2b-pt-res) (CC-BY-4.0);
112
+ the heads and feature descriptions are CC-BY-4.0.
113
+
114
+ ## Citation
115
+
116
+ ```bibtex
117
+ @misc{dugan2026detectorscope,
118
+ title={Building Auditable AI Text Detectors with Sparse Autoencoders},
119
+ author={Liam Dugan and Callum McDougall and Matthew Denton and Phillip Pham and Christine Kaeser-Chen and Chris Callison-Burch},
120
+ year={2026},
121
+ eprint={2610.30006},
122
+ archivePrefix={arXiv},
123
+ url={https://arxiv.org/abs/2610.30006},
124
+ }
125
+ ```