Views
No views yet
google/gemma-4-E4B-it
last-token logits, for AI-vs-human text classification.raw_logits[262144] → LayerNorm → Dropout(0.3) → Linear → cls_logits[4]| file | size | purpose |
|---|---|---|
head.safetensors | 6.3 MB | LayerNorm + Linear weights (fp32) |
config.json | <1 KB | vocab_size, dropout, training metrics |
1import json
2import torch
3from safetensors.torch import load_file
4from huggingface_hub import snapshot_download
5
6# See ai-detection-demo repo for the LinearDropoutHead class definition.
7from gemma_4_e4b.head import LinearDropoutHead, score_from_logits
8
9local = snapshot_download("DarrenJiaImbue/ai-detection-demo-gemma_4_e4b")
10with open(f"{local}/config.json") as f:
11 cfg = json.load(f)
12
13head = LinearDropoutHead(
14 vocab_size=cfg["vocab_size"], n_classes=cfg["n_classes"], dropout=cfg["dropout"]
15)
16head.load_state_dict(load_file(f"{local}/head.safetensors"))
17head.eval()
18
19# raw_logits: (batch, 262144) fp32 tensor of Gemma's last-token vocabulary logits.
20with torch.no_grad():
21 logits = head(raw_logits)
22 bucket = logits.argmax(dim=-1) # 0..3
23 ai_score = score_from_logits(logits) # continuous [0, 1]DarrenJiaImbue/ai-detection-demo-gemma-logits —
pre-computed int4 Gemma 4 E4B logits over
DarrenJiaImbue/ai-detection-demo-dataset.