Skip to content

Confidence Calibration ​

v0.6.7

Large language models systematically produce overconfident extraction scores — raw confidence values cluster between 0.85 and 1.0 regardless of actual correctness. This makes confidence-based filtering unreliable.

DocIntel applies temperature scaling to calibrate raw LLM confidence scores before they reach the per-profile threshold filter.

The problem ​

Without calibration:

  • A hallucinated entity gets confidence 0.88
  • A correct entity gets confidence 0.92
  • Your threshold of 0.75 lets both through
  • The hallucinated entity pollutes your knowledge graph

How it works ​

The _calibrate_confidence() method applies a logit → scale → sigmoid transform:

calibrated = σ(logit(raw) / T)

Where:

  • logit(p) = ln(p / (1 − p)) — converts probability to log-odds
  • T = 2.0 — temperature parameter (halves the log-odds)
  • σ(x) = 1 / (1 + e^−x) — sigmoid converts back to probability

Calibration table ​

Raw LLM scoreCalibrated scoreEffect
0.99~0.95High-confidence entities stay high
0.95~0.82Moderate reduction
0.90~0.74Significant spread
0.85~0.68Falls below 0.75 threshold → filtered out
0.80~0.62Large correction
0.70~0.58Aggressive correction for mid-range
0.500.50Fixed point — no change

Where it runs in the pipeline ​

Pass 1: Entity extraction (parallel windows)
Pass 2: Relationship extraction (parallel windows)
    ↓
Fuzzy deduplication (rapidfuzz WRatio ≥ 88)
    ↓
★ Confidence calibration (T = 2.0)          ← HERE
    ↓
Per-profile confidence threshold filter
    ↓
EmitPayload → Purple8 Graph

Calibration runs after fuzzy dedup (so duplicate scores are already merged) and before the threshold filter (so thresholds operate on calibrated values).

Results ​

Expected Calibration Error (ECE) ​

ECE measures how well confidence scores predict actual correctness. Lower is better.

DomainBefore (v0.6.6)After (v0.6.7)Target
Invoices0.300.130.08–0.20
Contracts0.450.42—
Scientific0.220.18—
BIM Models0.380.32—

Configuration ​

The temperature parameter T = 2.0 is currently hardcoded. Higher values produce more aggressive calibration:

T valueBehaviour
1.0No calibration (identity)
1.5Mild calibration
2.0Default — halves log-odds
3.0Aggressive calibration

TIP

The calibration is applied to both entity and relationship confidence scores. The fixed point at 0.50 means entities that the LLM is genuinely uncertain about are not affected.

Technical details ​

  • Edge cases: Scores of exactly 0.0 and 1.0 are clamped to [1e-9, 1 − 1e-9] before logit to avoid infinity
  • Idempotent: Applying calibration twice does further compress scores, so it is called exactly once
  • 238 tests passing including 8 dedicated calibration tests

Purple8 DocIntel v0.12.5 · Universal Document Intelligence · NVIDIA Inception Member · Red Hat Technology Partner.