Skip to main content

Calibrate raw LLM uncertainty scores into truth-aligned scores.

Project description

TruthAnchor

TruthAnChor (TAC) calibrates raw uncertainty scores of LLM responses into truth-aligned scores. Given score-label pairs ${S_i, C_i}_{i=1}^{n}$, where $S\in{0,1}$, with $S=1$ indicating a correct response, we approximate the target $p^\star(S)=P(C=1\mid S)$ by learning the mapping:

$$ m_\theta: \mathbb{R} \to [0,1], $$

where $m_\theta$ is instantiated with a lightweight MLP.

Usage

Installation

conda create -n anchor python=3.11
conda activate anchor
pip install truthanchor

Quick Start

Run the end-to-end example pipeline to reproduce results in the paper. Datasets and models can be modified directly in the Python script.

python3 examples/tac_eval.py

This runs:

  1. generation
  2. uncertainty scoring
  3. mapper training
  4. held-out evaluation

The pipeline writes results under outputs/<dataset>/<model>/, including:

  • uncertainty_scores.npz
  • mapper_eval/results.csv
  • mapper_eval/scores/*.npz
  • optional comparison and calibration plots

A step-by-step notebook example is available at:examples/tac_eval_walkthrough.ipynb. TruthAnchor currently supports:

  • response generation for benchmark datasets: TriviaQA, SciQ, and PopQA
  • select raw uncertainty score computation
  • truth-anchored score mapping with a lightweight MLP
  • optional CUE comparison
  • metric reporting with AUROC, ECE, and PRR
  • plotting for calibration and score comparison
  • custom score-label CSV input: first column for uncertainty scores, second for labels with 1 = correct and 0 = incorrect.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

truthanchor-0.1.1.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

truthanchor-0.1.1-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file truthanchor-0.1.1.tar.gz.

File metadata

  • Download URL: truthanchor-0.1.1.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for truthanchor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6b65c2c1ddf5a4c3493013139bc3a5db8342b005cc5dc29d655727d74ab88588
MD5 57e840c41e8dc8cf9381657e51517c02
BLAKE2b-256 a7441e9c68b1c3e1313f3bd35ac6fa4747d435793e02bdb8bafbb083d9067ca8

See more details on using hashes here.

File details

Details for the file truthanchor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: truthanchor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for truthanchor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f2ea7b8e0e4c6e4df25afcdbfc6cb43b7cc2c6178094be98ade4ce9d3686e18
MD5 5c1183da7706b465d9aba6b3ae9a808f
BLAKE2b-256 6586d503e727f16eb3ad4b2ea394f8be5652a84dd98033edbbe6c7ed6976f7db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page