Skip to main content

validity-screen

Check whether an LLM's confidence signal carries information about correctness before you build anything on it.

PyPI License: MIT

Abstention, routing and escalation all assume that a model's confidence varies with whether it is right. This package checks that assumption, using the logic psychological assessment applies to response validity: exclude responses the respondent did not give, rule out fixed response sets, and require evidence that responding follows content.

Install

pip install validity-screen

Quick start

from validity_screen import screen

# Binary confidence (1 = kept / high, 0 = withdrawn / low)
r = screen(correct, keep, answered=answered, model_name="Model A")

# Continuous confidence: state the cut point you will deploy at, on the same scale as the data
r = screen(correct, confidence_0_100, answered=answered, cut=90)

print(r.tier, r.reason_code, r.flags)   # e.g. Valid signal_detected []
print(r.vrs_table())                    # full validity report

answered marks rows to drop before scoring: declines, unparseable output, and values the pipeline supplied rather than the model (such as a parser default). Missing values on scored rows raise an error rather than being guessed; with cut, missing confidence values are excluded and counted.

What it reports

From the correct/wrong × kept/withdrawn table:

Index Formula Meaning
Kept-error rate L b / (b + d) share of errors on which confidence was kept
Withdrawn-correct rate Fp c / (a + c) share of correct answers withdrawn
Item sensitivity J (1 − Fp) − L Youden's J; binary AUROC = (1 + J) / 2

Tiers (version 0.4)

Tier Rule
Invalid blanket confidence (L ≥ .95) or blanket withdrawal (Fp ≥ .95), each certified by a Wilson lower bound > .90; or inversion (J < 0, one-sided mid-p < .025)
Uncertifiable fewer than 10 errors or 10 correct answers, and no certified response set
Indeterminate response set or inversion suspected but not certified, or no detectable sensitivity (reason_code says which)
Valid J > 0 (one-sided Fisher mid-p < .025) and no response set

Flags, reported beside the tier and never changing it: low_coverage (Fp ≥ .50), response_set_not_excluded (Valid, but the L or Fp 95% interval reaches .95), fixed_responding (one response on ≥ 95% of items).

Valid means better than chance, not good. Read J and its interval. With many items a very small J is Valid; use min_j= (chosen in advance) if you need a minimum effect.

Operating characteristics

  • False Valid (no real signal): at most .026 against a nominal .025 in typical cases (226 to 1,500 items, accuracy .70 to .97, keep rates .50 to .99). With only 10 to 12 errors it reaches about .030 at keep rates of .50 or more. At low keep rates (.10 to .30, as at very high cut points) it reaches about .037.
  • False Invalid: a model whose true kept-error rate is .93 is certified as blanket confidence up to about 23% of the time, depending on the number of errors. The guard is set at a Wilson lower bound of .90.
  • Power depends on the number of errors, not items. Use the planning functions:
from validity_screen import power_valid, power_invalid, items_needed, errors_needed
power_valid(n_items=1000, accuracy=0.90, keep_correct=0.95, keep_wrong=0.85)  # P(Valid) for J = .10
items_needed(accuracy=0.90, true_L=0.97, power=0.90)                          # 1600
errors_needed(withdrawn=0)                                                     # 35

Command line

validity-screen run --data results.csv --correct-col is_correct --confidence-col keep
validity-screen run --data results.csv --confidence-col confidence --cut 90
validity-screen plan --accuracy 0.92 --true-L 0.97

Cells are read strictly. Blank or unreadable cells, including words in a numeric column, are excluded and counted, never guessed.

Changes

See CHANGELOG.md. Results from 0.1 should be rerun. Version 0.4 changed the decision rules; the decision record, with the rationale for each rule, is in the repository.

Citation

Cacioli, J. P. (2026). Screen Before You Interpret: A Validity Screen for LLM Confidence Signals and Its Operating Characteristics. Preprint: arXiv:2604.17714.

License

MIT

Metadata

Release files for validity-screen 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for validity-screen 0.4.1
File Size Uploaded Provenance Actions
validity_screen-0.4.1.tar.gz 22.3 kB Without provenance Details for validity_screen-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for validity-screen 0.4.1
File Interpreter ABI Platform Actions
validity_screen-0.4.1-py3-none-any.whl Python 3 none any Details for validity_screen-0.4.1-py3-none-any.whl

Total release size: 40.0 kB

Release files / validity_screen-0.4.1.tar.gz

Download URL validity_screen-0.4.1.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e9d9133838e97eb6f2651fa18287eff8cc9f2b50c4c8b2e38785ff1d590c04d3
BLAKE2b-256 checksum
How to use checksums
bf226250daf01d85b3fc659ee1870deab9d4047a79f5c4ae7e7fcb14253ad275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / validity_screen-0.4.1-py3-none-any.whl

Download URL validity_screen-0.4.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bea6539c27f95af98d8d4eae5ef3a0b7b188c9e2409efdb427f65bd2d149dbe
BLAKE2b-256 checksum
How to use checksums
155b3449129e3ce45c43834a64d5ccd1a3ace3e80af6fd04f8ba513166ab7244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for validity-screen 0.4.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page