omniuq
State-of-the-art uncertainty quantification methods for large language models.
omniuq brings together rigorous, paper-faithful
implementations of methods that measure when an
LLM is unsure and why.
Install
pip install omniuq
For low-VRAM setups (e.g. Phi-4 14B on a 24 GB card), enable quantization:
pip install "omniuq[quantize]"
Spectral Uncertainty needs an OpenAI API key for the clarifier and judge (P(True) and Verbalized Confidence run fully locally):
export OPENAI_API_KEY=sk-...
The big picture: LLM Reliability
When we say "I want a reliable LLM," we usually mean three different things at once. Researchers split the field into three branches that build on each other.
LLM Reliability
│
├── 1. Uncertainty Quantification (UQ)
│ │
│ ├── What is uncertain?
│ │ ├── Input
│ │ ├── Reasoning
│ │ ├── Parameters / knowledge
│ │ └── Prediction / generated output
│ │
│ ├── Why is it uncertain?
│ │ ├── Aleatoric uncertainty
│ │ └── Epistemic uncertainty
│ │
│ └── How do we measure it?
│ ├── Single-generation methods
│ ├── Multi-generation methods
│ ├── External semantic-model methods
│ ├── Fine-tuning / trainable estimators
│ └── Conformal prediction methods
│
├── 2. Confidence Estimation
│ │
│ ├── Confidence in one answer
│ ├── Probability of generated sequence
│ ├── Verbalized confidence
│ ├── LLM-as-a-judge confidence
│ └── Trainable confidence estimators
│
└── 3. Evaluation
│
├── Ranking quality
│ ├── Can the score separate right from wrong?
│ └── Metrics: AUROC, AUARC / AURC
│
└── Calibration quality
├── Are the confidence numbers truthful?
└── Metric: ECE
Uncertainty Quantification asks is the model unsure, and why? The "what" branch locates the source of uncertainty. The "why" branch separates ambiguity in the question (aleatoric) from gaps in the model's knowledge (epistemic). The "how" branch covers the algorithmic families used to estimate these signals.
Confidence Estimation turns uncertainty into a single trustworthiness number per answer — a score the application layer can act on (gate a response, escalate to a human, abstain).
Evaluation is how we judge the previous two. Ranking quality asks whether high-uncertainty answers really are the wrong ones (AUROC, AURC). Calibration quality asks whether the numbers themselves are honest — when the model says "90% sure," is it correct 90% of the time? (ECE).
A method can rank well but be miscalibrated, or be calibrated but rank poorly. Good UQ requires both.
Categories of UQ Methods
omniuq focuses on the UQ branch above. Within
UQ, methods can be organized by the algorithmic
family they belong to.
UQ Methods
│
├── 1. Input Uncertainty Methods
│ │
│ ├── 1.1 Prompt clarification
│ │ └── Resolves ambiguity by generating clarified versions of the input
│ │
│ ├── 1.2 Prompt perturbation
│ │ └── Measures stability under small input changes
│ │
│ └── 1.3 In-context sample variation
│ └── Measures sensitivity to examples or demonstrations
│
├── 2. Reasoning Uncertainty Methods
│ │
│ ├── 2.1 Chain-of-thought uncertainty
│ │ └── Measures disagreement across reasoning traces
│ │
│ ├── 2.2 Tree-of-thought uncertainty
│ │ └── Measures uncertainty across explored reasoning paths
│ │
│ ├── 2.3 Topology-based reasoning graphs
│ │ └── Measures structure and stability of reasoning graphs
│ │
│ └── 2.4 Uncertainty-guided reasoning repair
│ └── Uses uncertainty to revise weak or unstable reasoning
│
├── 3. Parameter Uncertainty Methods
│ │
│ ├── 3.1 Bayesian LoRA
│ │ └── Approximates posterior uncertainty over adapter weights
│ │
│ ├── 3.2 LoRA ensembles
│ │ └── Uses multiple fine-tuned adapters as an ensemble
│ │
│ ├── 3.3 Supervised uncertainty estimation
│ │ └── Trains a model to predict its own correctness or confidence
│ │
│ └── 3.4 Uncertainty-aware instruction tuning
│ └── Fine-tunes models to express calibrated uncertainty
│
└── 4. Prediction Uncertainty Methods
│
├── 4.1 Single-Generation Methods
│ │
│ ├── 4.1.1 Perplexity
│ │ └── Higher perplexity often indicates lower confidence
│ │
│ ├── 4.1.2 Log probability
│ │ └── Uses token likelihood as a confidence signal
│ │
│ ├── 4.1.3 Entropy
│ │ └── Measures uncertainty in the token distribution
│ │
│ ├── 4.1.4 phi_first
│ │ └── Uses first-token confidence or entropy from a single decode
│ │
│ ├── 4.1.5 Response improbability
│ │ └── Scores how unlikely the generated response is
│ │
│ └── 4.1.6 P(True)
│ └── Probability the model assigns to "True" when asked whether its own answer is correct
│
├── 4.2 Multi-Generation Methods
│ │
│ ├── 4.2.1 Self-consistency
│ │ └── Measures agreement across multiple sampled answers
│ │
│ ├── 4.2.2 Predictive entropy
│ │ └── Measures entropy over generated answer distributions
│ │
│ ├── 4.2.3 Token-level entropy
│ │ └── Aggregates uncertainty over generated tokens
│ │
│ └── 4.2.4 Conformal prediction
│ └── Produces prediction sets with coverage guarantees
│
└── 4.3 Multi-Generation + External Model Methods
│
├── 4.3.1 Semantic entropy
│ └── Groups semantically equivalent answers before computing entropy
│
├── 4.3.2 NLI clustering
│ └── Uses an external NLI model to cluster equivalent answers
│
├── 4.3.3 ICE answer grouping
│ └── Groups answers conditioned on generated clarifications
│
├── 4.3.4 Pairwise similarity graphs
│ └── Builds graphs from answer-to-answer similarity
│
├── 4.3.5 Graph degree
│ └── Measures how centrally connected an answer is
│
├── 4.3.6 Eccentricity
│ └── Measures how far an answer is from other answers in the graph
│
└── 4.3.7 Eigenvalue-based metrics
└── Computes uncertainty from eigenvalues of similarity matrices
The first tree is the map of the research landscape. The second tree is the map of the algorithms. They sit at different levels: the first tells you what question you're answering; the second tells you which tool to use.
Methods
The Category column refers to the numbered nodes in the UQ Methods tree above.
| Method | Category | Decomposes | Paper | Code | Reproduced | Status |
|---|---|---|---|---|---|---|
| Spectral Uncertainty (Walha et al., AAAI 2026) | 1.1 & 4.3.7 | AU + EU | arXiv | GitHub | TriviaQA: AUROC 89.66% vs. paper 91.92% — Colab | ✅ Available |
| Verbalized Confidence (Xiong et al., ICLR 2024) | 4.1.6 & 4.2.1 | — | arXiv | GitHub | GSM8K: AUROC Vanilla 56.23% → CoT+M5+AvgConf 90.92% (+34.7 pts) — Colab | ✅ Available |
| P(True) (Kadavath et al., 2022) | 4.1.6 | — | arXiv | Not released | TriviaQA: AUROC 91.1% (Qwen2.5-7B) vs. paper ≈88% (52B, private); accuracy 45.6% → 70.9% when P(True) > 0.5 — Colab | ✅ Available |
Demo 1 — Spectral Uncertainty
Phi-4 14B as target, GPT-4o as clarifier, GPT-4.1 as judge — exactly the paper's setup.
import os
from omniuq import (
SpectralUncertainty,
load_llm_model,
load_openai_client,
)
tokenizer, model = load_llm_model("microsoft/phi-4")
clarifier = load_openai_client(
api_key=os.environ["OPENAI_API_KEY"],
model="gpt-4o",
)
judge = load_openai_client(
api_key=os.environ["OPENAI_API_KEY"],
model="gpt-4.1",
)
uq = SpectralUncertainty(
tokenizer, model,
clarifier=clarifier,
judge=judge,
)
print(uq.score("What is the capital of France?"))
Demo 2 — Verbalized Confidence (Xiong et al.)
Llama-3.1-8B as target. No API keys needed — the model verbalizes its own confidence.
from omniuq import load_llm_model
from omniuq.verbalized_xiong import run_xiong
tokenizer, model = load_llm_model(
"meta-llama/Llama-3.1-8B-Instruct"
)
device = model.device
# Strongest configuration: CoT + Self-Random M=5 + AvgConf
result = run_xiong(
model, tokenizer,
"If 7 cars need 14 hours to complete a task, "
"how long do 5 cars need?",
device,
prompting="cot",
n_samples=5,
aggregation="avg_conf",
)
print(result["answer"], result["confidence"])
Demo 3 — P(True) (Kadavath et al.)
Qwen2.5-7B base model. No API keys, no quantization: bf16 on a single 24 GB GPU (e.g. L4).
from omniuq import load_llm_model
from omniuq.ptrue_kadavath import run_kadavath
tokenizer, model = load_llm_model(
"Qwen/Qwen2.5-7B", device="cuda:0"
)
result = run_kadavath(
model, tokenizer,
"Which 1986 Peter Weir movie starred "
"Harrison Ford, Helen Mirren and River Phoenix?",
)
print(result["answer"], result["p_true"], result["pe"])
How it works. The model samples 5 answers at
temperature 1. It then reads the paper's prompt —
the question, its own samples as "brainstormed
ideas", the first sample as the possible answer —
and P(True) is the probability it gives to
(A) True versus (B) False. Predictive entropy
(PE) over the 5 samples is returned as a baseline.
Replication (TriviaQA, 1,000 questions).
Qwen2.5-7B base, bf16; TriviaQA rc.nocontext
validation, de-duplicated, seed 1234. Base accuracy
45.6%. Full run in the
Colab.
| Method | AUROC | Brier | ECE | Acc. at P(True) > 0.5 | Coverage |
|---|---|---|---|---|---|
| P(True), 20-shot | 0.911 | 0.150 | 0.141 | 0.709 | 0.611 |
| P(True), paper prompt (A.5), with samples | 0.921 | 0.182 | 0.190 | 0.673 | 0.646 |
| P(True), paper prompt (A.5), without samples | 0.898 | 0.178 | 0.181 | 0.672 | 0.646 |
| Predictive entropy | 0.850 | — | — | — | — |
The paper's main findings hold: P(True) separates right from wrong answers better than PE; keeping answers with P(True) > 0.5 raises accuracy (45.6% → 70.9%); showing the model its own samples helps; and 20-shot examples mainly improve calibration. The paper's private 52B model is not available, so compare patterns, not exact numbers.
License
MIT
Metadata
Release files for omniuq 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| omniuq-0.4.2.tar.gz | 34.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| omniuq-0.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.4 kB
Release files / omniuq-0.4.2.tar.gz
| Download URL | omniuq-0.4.2.tar.gz |
|---|---|
| Size | 34.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4951973808e66a06febf57abf29ef22c807ce7149e0877f75cd5ab39616f003
|
|
BLAKE2b-256 checksum How to use checksums |
dd9a3b5d45b7d4f5438f54a8289ad868ed80fae80db05d32c02b48e9379485ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / omniuq-0.4.2-py3-none-any.whl
| Download URL | omniuq-0.4.2-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37b63ef8adc57cf2af3315847dce664ce237af484b7108d86f8e99475e2cb7f6
|
|
BLAKE2b-256 checksum How to use checksums |
bf642556cb344c9cde29ee4dcd4b687a5562a870afa3c5c09281ac4beda5aca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for omniuq 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.