debajyotidasgupta/eu-halt-phi4-14b
021
EU-Halt heads for microsoft/phi-4 (default)
Lightweight epistemic-uncertainty detector: K=4 prediction heads sharing the frozen microsoft/phi-4 trunk. Configuration: mid_dim=256, K=4 (default).
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(
"microsoft/phi-4", torch_dtype=torch.bfloat16,
).to("cuda").eval()
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-4")
uncertainty = attach(
model,
heads_repo="debajyotidasgupta/eu-halt-phi4-14b",
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: numheads, middim, sourcelayers, basemodel, 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, batchsize 2-4, seqlen 512, ~2000-2500 steps.
- AdamW (lr 3e-4 to 5e-4), 100-200 warmup steps.
- K=4 heads, middim=256, trainingnoise_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), 1364 samples total:
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 microsoft/phi-4 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-phi4-14b},
}