EU-Halt heads for deepseek-ai/DeepSeek-R1-Distill-Qwen-7B (reasoning-distilled)
Lightweight epistemic-uncertainty detector: K=4 prediction heads sharing the frozen deepseek-ai/DeepSeek-R1-Distill-Qwen-7B trunk. Configuration: mid_dim=256, K=4 (reasoning-distilled).
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(
"deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", torch_dtype=torch.bfloat16,
).to("cuda").eval()
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
uncertainty = attach(
model,
heads_repo="debajyotidasgupta/eu-halt-r1-distill-qwen-7b",
mid_dim=256,
)
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=256, 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), 700 samples total:
| Signal | AUROC | 95% CI |
|---|---|---|
| disagreement | 0.9069 | [0.8773, 0.9305] |
| entropy | 0.6381 | [0.5984, 0.6784] |
| last_token_unc | 0.4695 | [0.4078, 0.5336] |
| mahalanobis | 0.5942 | [0.4450, 0.7364] |
| targ_margin | 0.4936 | [0.4338, 0.5548] |
| etc_trend | 0.6380 | [0.5980, 0.6793] |
| llm_check | 0.0385 | [0.0213, 0.0598] |
| mc_dropout | 0.4417 | [0.3943, 0.4887] |
| rauq | 0.0787 | [0.0545, 0.1042] |
| p_true | 0.6093 | [0.5489, 0.6601] |
| semantic_entropy | 0.4918 | [0.4819, 0.5052] |
| semantic_entropy_nli | nan | [nan, nan] |
| eigenscore | 0.5013 | [0.4417, 0.5549] |
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 deepseek-ai/DeepSeek-R1-Distill-Qwen-7B 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-r1-distill-qwen-7b},
}
- Downloads last month
- 14
Model tree for debajyotidasgupta/eu-halt-r1-distill-qwen-7b
Base model
deepseek-ai/DeepSeek-R1-Distill-Qwen-7B