Skip to main content

DeFacto

CI PyPI version Python versions License

DeFacto checks whether an LLM evaluation result is true. It finds benchmark leakage, measures how reliable an LLM judge or reward model is, flags reward hacking, tracks distribution drift, and writes an audit report mapped to AI governance frameworks.

Judge dashboard

A benchmark can look good because its test set leaked into training. A judge can agree with itself and not with people. A reward model can be gamed into praising answers that fail the task. These are silent failures. The results are fluent and well scored, and they are still wrong. DeFacto makes them measurable.

Install

pip install defacto-eval             # core, NumPy only
pip install "defacto-eval[viz]"      # add plots
pip install "defacto-eval[pandas]"   # add DataFrame export
pip install "defacto-eval[all,dev]"  # everything for development

Python 3.10 or newer. The package installs as defacto-eval and imports as defacto.

Quickstart

Command line

defacto judge records.json -o report.md --plot dashboard.png
defacto contamination --train train.txt --test test.txt --n 13
defacto probe --texts items.txt --groups groups.txt
defacto hack rewards.json -o report.md
defacto drift --expected reference.json --actual live.json
defacto report findings.json --format json

Every command accepts --format markdown, --format json, or --format csv.

Python

from defacto import analyze_judge, detect_hacking, ngram_containment, psi

result = analyze_judge(gold, judge, confidence=confidence)
print(result["agreement"]["kappa"])
print(result["classification"]["macro_f1"])

contamination = ngram_containment(train_texts, test_texts)
hacking = detect_hacking(rewards, successes)
drift = psi(reference_scores, live_scores)

See examples/quickstart.py and docs/quickstart.md.

What DeFacto checks

Question Module Output
Did the test data leak into training? defacto.leakage n-gram containment, MinHash near-duplicates, a held-out ridge identity probe with a permutation test and cluster-bootstrap CI
Is the judge or reward model reliable? defacto.judge Cohen's and Fleiss' kappa, weighted kappa, calibration error, risk-coverage, confident errors, abstention, subgroup gaps, precision, recall, F1
Is the reward being gamed? defacto.hack reward vs verifiable success, reward gap, drift over time
Did the score distribution shift? defacto.monitoring Population Stability Index, two-sample Kolmogorov-Smirnov
What does this mean for compliance? defacto.report Markdown, JSON, or CSV audit mapped to NIST AI RMF, OSFI E-23, and the EU AI Act

Does it work

A controlled experiment in docs/case-study.md injects a known amount of contamination into a test set and shows the metrics track it. The held-out identity probe reports 0.933 balanced accuracy against 0.500 chance on held-out documents.

docs/gsm8k-overlap.md runs the same checks on the real GSM8K train and test questions, with no GPU and no model. No test question reaches 0.8 13-gram containment against the train split. No near-duplicate pair crosses the split. The identity probe scores 0.522 against 0.500 chance (p = 0.14).

Leakage detection covers verbatim and near-verbatim overlap. A paraphrased test item needs an embedding model to catch, and DeFacto does not include one.

Plots

Every check has a plot. The viz extra adds these:

Reward vs success

  • reliability_diagram: binned confidence against observed accuracy
  • plot_confusion_matrix: gold labels against predictions
  • risk_coverage_curve: error rate against coverage
  • reward_success_scatter and reward_drift_plot
  • containment_histogram, identity_probe_bar, bootstrap_histogram
  • judge_dashboard: one figure with three panels

Generate the examples with python examples/plot_gallery.py.

Why the numbers are reproducible

DeFacto has one hard dependency, NumPy. Every statistic is implemented from its definition on NumPy plus the Python standard library, so the results are auditable and easy to install.

  • Cluster bootstrap with bias-corrected and accelerated, percentile, or basic intervals.
  • Exact permutation p-values. The formula (1 + count) / (n + 1) never reports a zero.
  • A seed on every stochastic routine.

The methods extend published work on evaluation validity: within-program evaluation leaking program identity, silent versus detectable failures, and confident errors that pass the checks, packaged here as tooling.

Project layout

src/defacto/
├── _stats.py          # bootstrap, permutation, correlation, ranks
├── judge/             # agreement, calibration, metrics, risk-coverage
├── leakage/           # contamination, near-duplicates, identity probe
├── hack/              # reward-hacking and drift
├── monitoring/        # PSI and Kolmogorov-Smirnov
├── viz/               # matplotlib plots
├── report/            # findings, governance mapping, Markdown/JSON/CSV
└── cli.py             # command-line interface

Citing

A CITATION.cff file is included. Cite DeFacto with it, or link to the repository.

Further reading

  • docs/case-study.md: the contamination-recovery experiment
  • docs/gsm8k-overlap.md: train/test overlap on GSM8K
  • docs/comparison.md: how DeFacto compares to Evidently, Deepchecks, Cleanlab, and lm-eval-harness
  • docs/evaluation-validity.md: the research idea behind the checks

Roadmap

  • A verifier fine-tuning recipe (SFT then DPO on a small open model) that DeFacto audits in one loop.
  • More governance frameworks: ISO/IEC 42001, Singapore FEAT, Canada's AIDA.

Contributing

Contributions are welcome, new checks and governance mappings especially. See CONTRIBUTING.md.

License

Apache-2.0. See LICENSE.

Metadata

Release files for defacto-eval 0.2.0

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

Source distribution (sdist)

Source distribution for defacto-eval 0.2.0
File Size Uploaded Provenance Actions
defacto_eval-0.2.0.tar.gz 47.1 kB With provenance Details for defacto_eval-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for defacto-eval 0.2.0
File Interpreter ABI Platform Actions
defacto_eval-0.2.0-py3-none-any.whl Python 3 none any Details for defacto_eval-0.2.0-py3-none-any.whl

Total release size: 93.8 kB

Release files / defacto_eval-0.2.0.tar.gz

Download URL defacto_eval-0.2.0.tar.gz
Size 47.1 kB
Tags Source
SHA-256 checksum
How to use checksums
632b28ba6b329328713eb7c86a433115330cc08eb180bac7dc6a048fc63e3c0c
BLAKE2b-256 checksum
How to use checksums
8e362fa0657e0356dd1d54455928aa2e117ec52f4cf474ee2597a46924379d56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / defacto_eval-0.2.0-py3-none-any.whl

Download URL defacto_eval-0.2.0-py3-none-any.whl
Size 46.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cb36f033537777608f68dc873a51000228153898ff3e315e4a590015c967c47
BLAKE2b-256 checksum
How to use checksums
4d223e08bebe2a57e7e8d0fb1782a52ccad11013f146cbb36111895d29a89a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for defacto-eval 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for defacto_eval-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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