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: 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 quiet variants).
  • Single GPU (~10-15 min on RTX A5000/A6000/L40S).

Evaluation

OOD AUROC (id vs ood), 1364 samples total:

Signal AUROC 95% CI
disagreement 0.8121 [0.7807, 0.8396]
entropy 0.4480 [0.4119, 0.4826]
last_token_unc 0.4163 [0.3714, 0.4599]
mahalanobis 0.7235 [0.6464, 0.7991]
targ_margin 0.4435 [0.4039, 0.4874]
etc_trend 0.3454 [0.3115, 0.3800]
llm_check 0.0968 [0.0798, 0.1142]
mc_dropout 0.4834 [0.4458, 0.5161]
rauq 0.1021 [0.0828, 0.1206]
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 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},
}
Downloads last month
50
Safetensors
Model size
54.4M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for debajyotidasgupta/eu-halt-phi4-14b

Base model

microsoft/phi-4
Finetuned
(101)
this model

Collection including debajyotidasgupta/eu-halt-phi4-14b