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 with a lightweight MLP.
What It Does
TruthAnchor supports:
- response generation for benchmark datasets
- 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
Installation
pip install truthanchor
For local development from this repository:
pip install -e .
Quickstart
Run the end-to-end example pipeline:
python3 examples/tac_eval.py
This runs:
- generation
- uncertainty scoring
- mapper training
- held-out evaluation
Custom Score-Label CSV Input
You can also run the pipeline on a custom CSV containing:
- first column: uncertainty scores
- second column: binary labels
Example:
python3 examples/tac_eval.py \
--datasets my_dataset \
--models custom \
--custom_scores_csv data/my_dataset.csv \
--custom_method_name my_score \
--higher_worse true
Note: custom CSV labels are assumed to use 1 = correct and 0 = incorrect.
Outputs
The example pipeline writes results under:
outputs/<dataset>/<sanitized-model>/
Including:
uncertainty_scores.npzmapper_eval/results.csvmapper_eval/scores/*.npz- optional comparison and calibration plots
Notebook Walkthrough
A step-by-step notebook example is available at:
examples/tac_eval_walkthrough.ipynb
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file truthanchor-0.1.0.tar.gz.
File metadata
- Download URL: truthanchor-0.1.0.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c1e1a2a9ea344181fd6dedbe389f7bfcf29f18e880b65c8f3857e45ec79334
|
|
| MD5 |
91cab822ea77deb45e2c1725195607d6
|
|
| BLAKE2b-256 |
7e228376284e3db5e169e2c52a7231d28b11e973b3f876e8e5cea4bb4101a7e3
|
File details
Details for the file truthanchor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: truthanchor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47ebea3acd4a324776da619a2a6222fe6fb80e1358a45f90662cea75d2e6f1f
|
|
| MD5 |
0ba313b619e928a0a21fa94df595116d
|
|
| BLAKE2b-256 |
31d9119aa63f90486518fd35221fe2e0d232dfe60c3a23ffa87597d87c1b1426
|