Views
No views yet
pangram/editlens_iclr (held-out, 2400 rows):| Metric | Value |
|---|---|
| AUROC (AI vs human) | 0.955 |
| AUPR | 0.977 |
| correlation with edit-magnitude | +0.723 |
| mean score — AI | 3.194 |
| mean score — human | 0.044 |
1import torch
2import torch.nn as nn
3import torch.nn.functional as F
4from transformers import AutoTokenizer, AutoModel
5from peft import PeftModel
6
7device = "cuda"
8model_name = "reneeice/ood-editguard-qwen3-1.7b"
9base = "Qwen/Qwen3-1.7B-Base"
10
11tok = AutoTokenizer.from_pretrained(model_name, use_fast=True)
12backbone = PeftModel.from_pretrained(
13 AutoModel.from_pretrained(base, torch_dtype=torch.bfloat16).to(device),
14 model_name
15).eval()
16
17head = torch.hub.load_state_dict_from_url(
18 "https://huggingface.co/reneeice/ood-editguard-qwen3-1.7b/resolve/main/ood_head.pt",
19 map_location="cpu"
20)
21
22hidden = 2048 # Qwen3-1.7B hidden size
23proj = nn.Sequential(
24 nn.LayerNorm(hidden, dtype=torch.float32),
25 nn.Linear(hidden, head["out_dim"], bias=False, dtype=torch.float32),
26).to(device)
27proj.load_state_dict(head["proj"])
28center = head["center"].to(device)
29orientation = int(head["orientation"])
30
31def ai_edit_score(texts):
32 """Return oriented OOD distance — higher = more AI-edited."""
33 enc = tok(texts, truncation=True, max_length=512, padding=True, return_tensors="pt")
34 enc = {k: v.to(device) for k, v in enc.items()}
35 with torch.no_grad():
36 h = backbone(**enc).last_hidden_state
37 mask = enc["attention_mask"].unsqueeze(-1).to(h.dtype)
38 pooled = (h * mask).sum(1) / mask.sum(1).clamp(min=1)
39 z = proj(pooled.float())
40 z = F.normalize(z, dim=-1)
41 return (orientation * ((z - center) ** 2).sum(-1)).tolist()
42
43print(ai_edit_score(["A human-written sentence.", "This was entirely generated by an AI language model."]))Qwen/Qwen3-1.7B-Base, bf16 + LoRA (rank 8, all attn+MLP projections).c, push AI
embeddings away. Score = oriented squared distance to c.pangram/editlens_iclr (1 epoch).cosine_score (thresholds 0.03/0.15).| Model | Size | AUROC | Approach |
|---|---|---|---|
| ood-editguard-qwen3-0.6b | 0.6B | 0.941 | Trained OOD head |
| ood-editguard-qwen3-1.7b ← you are here | 1.7B | 0.955 | Trained OOD head |
| editlens-ood-adapter-qwen3-0.6b | 0.6B | 0.688 | Frozen-embedding adapter |
Qwen/Qwen3-1.7B-Base. The supervision labels derive from
the gated pangram/editlens_iclr dataset;
please honor its terms.