EU-Halt heads for google/gemma-2-27b-it (frontier-panel, NORMAL regime)
Lightweight epistemic-uncertainty detector: K=4 prediction heads sharing the frozen google/gemma-2-27b-it trunk. Configuration: mid_dim=128, K=4 (frontier-panel, NORMAL regime).
Calibrate the sign before deploying. The direction of the disagreement signal is trunk-family-specific: on some families it rises on out-of-distribution input, on others (Llama-70B-class, gpt-oss-120B) it falls. Score ~50 known-ID and ~50 known-OOD prompts once and check which direction separates. Details: the paper and repo below.
Paper: When Uncertainty Lies (CAISc 2026, oral) Β· Code: github.com/debajyotidasgupta/eu-halt
Quick start
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from eu_halt import attach
model = AutoModelForCausalLM.from_pretrained(
"google/gemma-2-27b-it", torch_dtype=torch.bfloat16,
).to("cuda").eval()
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-27b-it")
uncertainty = attach(
model,
heads_repo="debajyotidasgupta/eu-halt-gemma-2-27b-it",
mid_dim=128,
)
print(uncertainty("Who founded Quora in 2008?", tokenizer))
# Higher = more uncertain.
Files in this repo
model.safetensorsβ the K=4 head weights (preferred format; config embedded as metadata).config.jsonβ head geometry: num_heads, mid_dim, source_layers, base_model, dims.heads_final.ptβ the original torch checkpoint (kept for backward compatibility).heads_step{500,1000,1500,2000,2500}.ptβ intermediate checkpoints (where uploaded).source_layers.jsonβ the K=4 trunk-layer indices the heads read from.history.jsonβ per-step loss + disagreement + GPU stats.
Training
- Dataset:
HuggingFaceFW/fineweb-edu(streaming). - ~2-5M tokens, batch_size 2-4, seq_len 512, ~2000-2500 steps.
- AdamW (lr 3e-4 to 5e-4), 100-200 warmup steps.
- K=4 heads, mid_dim=128, training_noise_std=0.01, dropout=0.1 (or both 0 for
quietvariants). - Single GPU (~10-15 min on RTX A5000/A6000/L40S).
Evaluation
OOD AUROC (id vs ood), 1050 samples total:
| Signal | AUROC | 95% CI |
|---|---|---|
| disagreement | 0.8908 | [0.8644, 0.9158] |
| entropy | 0.6298 | [0.5982, 0.6661] |
| last_token_unc | 0.1200 | [0.0789, 0.1629] |
| mahalanobis | 0.7291 | [0.6262, 0.8281] |
| targ_margin | 0.1236 | [0.0815, 0.1679] |
| etc_trend | 0.6000 | [0.5611, 0.6363] |
| llm_check | 0.5006 | [0.4574, 0.5456] |
| mc_dropout | 0.5287 | [0.4927, 0.5674] |
| rauq | 0.1016 | [0.0832, 0.1222] |
| p_true | nan | [nan, nan] |
| semantic_entropy | nan | [nan, nan] |
| semantic_entropy_nli | nan | [nan, nan] |
| eigenscore | nan | [nan, nan] |
Best signal: disagreement
Intended use
- Hallucination flagging at inference time (score before / during generation).
- Dynamic-RAG gating (retrieve iff uncertainty > Ο).
- Selective prediction / risk-coverage trade-offs.
- Token-level uncertainty visualization via
uncertainty.per_token(text, tokenizer).
Limitations
- No fine-tuning of the trunk β only the auxiliary heads are trained.
- Heads are trained on web text. Specialized domains (medical, legal) may need a domain-specific recalibration.
- For Gemma's 256k vocab, head output projection is ~70-100M params per head β still small relative to the trunk.
License
Apache-2.0 for the heads.
The trunk model google/gemma-2-27b-it retains its own license (Qwen3 / Llama-3 / Phi / Gemma).
Citation
@inproceedings{dasgupta2026euhalt,
author = {Dasgupta, Debajyoti and Mondal, Arijit and Chakrabarti, Partha P.},
title = {When Uncertainty Lies: How Model Scale and Layer Geometry Quietly
Invert the Meaning of Internal Disagreement in Large Language Models},
booktitle = {1st Conference For AI Scientists (CAISc)},
year = {2026},
url = {https://huggingface.co/debajyotidasgupta/eu-halt-gemma-2-27b-it},
}
- Downloads last month
- 7