Downloads · 30 days
20
10% of all-time downloads
DarrenJiaImbue/ai-detection-demo-qwen_3_4b
ai-detection-demo-qwen_3_4b is a text classification model from DarrenJiaImbue. Use it when you need a label for a piece of text. It is set up for peft. The card lists the license as cc-by-nc-sa-4.0.
A QLoRA'd Qwen/Qwen3-4B fine-tuned for AI-vs-human text classification. Matches state-of-the-art numbers on our 2026-vintage dataset reproduction.
Downloads · 30 days
20
10% of all-time downloads
All-time downloads
204
Public
Repo size
144 MB
Likes
0
Public
Click a slice to open those files.
.safetensors66.2 MB · 85%
From the Hugging Face model README
A QLoRA'd
Qwen/Qwen3-4B fine-tuned for
AI-vs-human text classification. Matches state-of-the-art numbers on our
2026-vintage dataset reproduction.
| Mode | Accuracy | Macro F1 |
|---|---|---|
human_vs_ai | 0.998 | 0.998 |
human_vs_rest | 0.955 | 0.949 |
ai_vs_rest | 0.962 | 0.958 |
| Ternary | 0.917 | 0.916 |
human_vs_ai mode drops ai_edited rows (n=5,106 remaining).
Qwen/Qwen3-4B (3.2B params), loaded in 4-bit NF4 (QLoRA)q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)NormedLinear = LayerNorm(hidden_size) → Linear(hidden_size, 4).
Replaces the default score head; the LayerNorm keeps initial loss
well-scaled. Saved via PEFT's modules_to_save=["score"] convention so
the head weights ship inside adapter_model.safetensors.| file | purpose |
|---|---|
adapter_model.safetensors | LoRA A/B weights + score head |
adapter_config.json | PEFT config (target_modules, r, alpha) |
tokenizer.json, tokenizer_config.json | Qwen3 tokenizer |
chat_template.jinja | Qwen3 chat template (unused at inference, kept for compatibility) |
trainer_state.json | training metrics per step |
Recommended: use the reproducible pipeline in
imbue-ai/ai-detection-demo
— it handles base-model loading, adapter application, and score-head
reattachment automatically.
git clone https://github.com/imbue-ai/ai-detection-demo
cd ai-detection-demo && pip install -r requirements.txt
python -m qwen_3_4b.inference # scores our test split, writes predictions.jsonl
Manual loading, if you must:
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
# ai-detection-demo repo defines NormedLinear (LayerNorm + Linear).
from qwen_3_4b.train import NormedLinear
qcfg = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16)
base = AutoModelForSequenceClassification.from_pretrained(
"Qwen/Qwen3-4B", num_labels=4, quantization_config=qcfg,
)
# swap in NormedLinear where the default score head goes
hidden = base.config.hidden_size
base.score = NormedLinear(hidden, 4, device=base.device, dtype=torch.bfloat16)
model = PeftModel.from_pretrained(base, "DarrenJiaImbue/ai-detection-demo-qwen_3_4b")
model.eval()
Trained on
DarrenJiaImbue/ai-detection-demo-dataset
— 75,316 / 3,234 / 7,658 train/val/test rows across 6 source domains and 3
generator models.
Config: 1 epoch, effective batch 24 (per-device 3 × 8 GPUs × accum 1),
constant LR 3e-5, bf16 compute, min_words=20 filter (matches original v3
provenance). Full config.yaml in the demo repo.
At inference the model produces 4-class logits. The demo pipeline exposes one derived column per input row:
qwen_3_4b_score — E[bucket] / (n_buckets - 1) ∈ [0, 1] (higher = more AI)CC BY-NC-SA 4.0. Non-commercial research use only.