FactTest: Factuality Testing in Large Language Models with Finite-Sample and Distribution-Free Guarantees

Fan Nie, Xiaotian Hou, Shuhang Lin, James Zou, Huaxiu Yao +1 more
2/12/2026

No official code found. Best implementation: fannie1208/FactTest (9 stars, last commit 2025-05-29).

Abstract

The propensity of Large Language Models (LLMs) to generate hallucinations and non-factual content undermines their reliability in high-stakes domains, where rigorous control over Type I errors (the conditional probability of incorrectly classifying hallucinations as truthful content) is essential. Despite its importance, formal verification of LLM factuality with such guarantees remains largely unexplored. In this paper, we introduce FactTest, a novel framework that statistically assesses whether a LLM can confidently provide correct answers to given questions with high-probability correctness guarantees. We formulate factuality testing as hypothesis testing problem to enforce an upper bound of Type I errors at user-specified significance levels. Notably, we prove that our framework also ensures strong Type II error control under mild conditions and can be extended to maintain its effectiveness when covariate shifts exist. Our approach is distribution-free and works for any number of human-annotated samples. It is model-agnostic and applies to any black-box or white-box LM. Extensive experiments on question-answering (QA) and multiple-choice benchmarks demonstrate that FactTest effectively detects hallucinations and improves the model's ability to abstain from answering unknown questions, leading to an over 40% accuracy improvement.

View on arXivView PDF

Code Implementations(1)

[ICML2025] "FactTest: Factuality Testing in Large Language Models with Finite-Sample and Distribution-Free Guarantees"

91PythonApr 8, 20251 years ago
conformal-predictionhallucination-detectionhypothesis-testinglarge-language-modelsneyman-pearson-classification

Similar Papers

Cite this paper

@article{nie2026facttest,
  title  = {FactTest: Factuality Testing in Large Language Models with Finite-Sample and Distribution-Free Guarantees},
  author = {Fan Nie and Xiaotian Hou and Shuhang Lin and James Zou and Huaxiu Yao and Linjun Zhang},
  year   = {2026},
  eprint = {2411.02603},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2411.02603},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.02603.svg)](https://codeofpaper.com/paper/2411.02603)

Discussion