DamonDemon/SpanUQ-Benchmark
Viewer β’ Updated β’ 99.8k β’ 24
Pre-trained SpanUQ Checkpoints
SpanUQ is a lightweight (25β35M parameter) DETR-style probe that estimates uncertainty at the span level from LLM hidden states in a single forward pass.
SpanUQ attaches to a frozen LLM backbone and reads intermediate hidden states to:
The probe is trained with Hungarian matching, UCIR (Uncertainty-Calibrated Importance Reweighting), and a two-phase schedule (span detection warmup β joint training).
| Backbone | Params | AUROC β | MAE β | Ο_span β | Ο_seq β | Size |
|---|---|---|---|---|---|---|
| Qwen3-14B | 29.1M | 0.939 | 0.106 | 0.790 | 0.839 | 111M |
| Qwen3-8B | 28.6M | 0.930 | 0.110 | 0.771 | 0.822 | 109M |
| Qwen3-4B | 25.6M | 0.944 | 0.112 | 0.791 | 0.826 | 98M |
| Qwen3-30B-A3B | 33.9M | 0.936 | 0.114 | 0.774 | 0.815 | 129M |
| Mistral-7B | 34.9M | 0.908 | 0.129 | 0.717 | 0.773 | 133M |
git clone https://github.com/DamonDemon/SpanUQ.git
cd SpanUQ
pip install -e .
import torch
import json
from spanuq.model import SpanUQ
from spanuq.config import SpanUQConfig
# Load model config
with open("checkpoints/Qwen3-14B/model_config.json") as f:
config_dict = json.load(f)
config = SpanUQConfig(**config_dict)
model = SpanUQ(config)
# Load weights
state_dict = torch.load("checkpoints/Qwen3-14B/best_model.pt", map_location="cpu")
model.load_state_dict(state_dict)
model.eval()
# 1. Generate response with target LLM
# 2. Extract hidden states from specified layers
# 3. Run SpanUQ probe
# Example: given hidden states tensor [1, seq_len, d_model]
with torch.no_grad():
outputs = model(hidden_states, attention_mask)
# outputs.span_scores: [n_detected_spans] uncertainty in [0, 1]
# outputs.span_boundaries: [n_detected_spans, 2] start/end positions
For models with temperature.json, apply post-hoc calibration:
with open("checkpoints/Qwen3-14B/temperature.json") as f:
T = json.load(f)["T"]
# Apply: calibrated_logit = raw_logit / T
Each model directory contains:
checkpoints/
βββ Qwen3-14B/
β βββ best_model.pt # Model weights
β βββ model_config.json # Architecture parameters (required for loading)
β βββ training_config.json # Training hyperparameters (for reproducibility)
β βββ temperature.json # Calibration temperature T
βββ Qwen3-8B/
β βββ ...
βββ Qwen3-4B/
β βββ ...
βββ Qwen3-30B-A3B/
β βββ ...
βββ Mistral-7B/
βββ best_model.pt
βββ model_config.json
βββ training_config.json # (no temperature.json)
| Component | Description |
|---|---|
| Input projection | Multi-layer hidden states β d_proj=512 |
| Encoder | 2-layer Transformer encoder |
| Decoder | 3-layer DETR decoder with n_queries learnable queries |
| Span head | Regression head predicting (center, width) |
| Scorer | MoB (K=3) Beta distribution head |
| Enrichment | Gated span-token attention |
| Seq aggregation | Importance-weighted span β sequence uncertainty |
Trained on SpanUQ-Benchmark β ~293K annotated spans across 20K prompts with continuous soft uncertainty labels derived from 20Γ sampling + cross-sample verification.
@article{zhang2026spanuq,
title={SpanUQ: Span-Level Uncertainty Quantification for Large Language Model Generation},
author={Zhang, Yimeng and Zhuang, Yingying and Wang, Ziyi and Lu, Yuxuan and Chen, Pei and Gupta, Aman and Su, Zhe and Tan, Ming and Zhang, Zhilin and Liu, Qun and others},
journal={arXiv preprint arXiv:2607.05721},
year={2026}
}
Apache License 2.0