SAFER: Risk-Constrained Sample-then-Filter in Large Language Models

Qingni Wang, Yue Fan, Xin Eric Wang

Ensuring the reliability of Large Language Models (LLMs) is a major hurdle for their deployment in risk-sensitive fields like medicine or law. While "conformal prediction" has emerged as a powerful statistical tool to guarantee that a model's output contains the correct answer, it often falls short in open-ended scenarios where a correct answer might not even be generated within a reasonable number of tries.

In this paper, researchers introduce SAFER (SAmpling and conformalized FiltERing), a two-stage framework designed to provide rigorous statistical guarantees for open-ended question answering (QA) while explicitly handling cases where the model should simply remain silent.

TL;DR

SAFER is a two-stage framework that provides rigorous statistical guarantees for LLM reliability in open-ended QA. It calibrates a sampling budget to ensure a correct answer is likely present and then applies a conformal filter to prune unreliable "distractor" outputs, all while maintaining a user-defined risk level.

What Problem Does This Paper Address?

Existing methods for "selective conformal prediction" (SCP) typically assume that if you sample enough times, you will eventually find the correct answer. In the messy reality of open-ended QA, this isn't always true; an LLM might hallucinate consistently or simply lack the knowledge to answer a specific query.

Furthermore, even if a correct answer is generated among a set of candidates, it is often buried under "distractors"—incorrect or irrelevant responses. Previous work failed to provide a unified way to:

  1. Abstain when the risk of not finding a correct answer is too high.
  2. Filter the candidate set to provide a concise, reliable list of answers to the user.

Methods

SAFER breaks the problem into two distinct calibration stages, as illustrated in the overview below:

Overview of SAFER’s two-stage calibration and test-time process.

Stage I: Abstention-Aware Sampling

Instead of assuming success, SAFER uses a calibration set to determine a minimum sampling budget ($\hat{s}$) required to meet a user-specified risk level ($\alpha$). This risk represents the maximum allowable rate of "miscoverage"—failing to include a correct answer in the sample set.

  • The "Safety Valve": If the required risk level cannot be met even with a maximum allowed number of samples ($M$), the system abstains from answering. This ensures the framework never produces invalid prediction sets under unreachable risk levels.
  • Technique: It employs the Clopper–Pearson exact method to establish a high-probability upper bound on the miscoverage risk.

Stage II: Conformalized Filtering

Once a candidate set is secured, SAFER filters out unreliable answers using an uncertainty threshold ($\hat{t}$).

  • The Filter: It calculates an uncertainty score (like sentence entropy) for each candidate.
  • Calibration: Using Conformal Risk Control (CRC), it determines a threshold that removes as many incorrect answers as possible while ensuring that the risk of accidentally removing a correct answer stays below a second risk level ($\beta$).

The final result is a prediction set with a total guaranteed risk bound of $\alpha + \beta - \alpha\beta$.

Datasets

The authors evaluated SAFER across five popular open-source LLMs (including Llama-3.1-8B and Qwen2.5 variants) using:

  • TriviaQA: A large-scale closed-book QA dataset.
  • ScienceQA: A dataset for complex scientific questions.
  • CoQA: A conversational QA dataset used here in an open-book setting.
  • MMVet: A multimodal reasoning benchmark used to test the framework's generalization to vision-language tasks.

Key Insights and Ideas

  • Abstention is a Feature: By incorporating an upper bound on sampling ($M$), SAFER acknowledges model limitations. If a model is likely to fail, it's safer to say nothing than to provide a set of wrong answers.
  • Decoupling "Finding" from "Identifying": Separating the sampling budget from the filtering threshold allows for more precise control. You first ensure the "needle" is in the "haystack" (Stage I), then you remove as much "hay" as possible (Stage II).
  • Metric Agnosticism: SAFER isn't tied to a specific way of defining "correct." It works equally well whether you use simple string matching, Rouge-L scores, or even another LLM to judge answer correctness.

Key Results

The experiments demonstrate that SAFER rigorously maintains the user-specified risk levels across all models and datasets.

  • Rigorous Risk Control: SAFER consistently stays below the theoretical error bound. As shown below, across various models, the test-time empirical risk remains strictly bounded by the upper limit of the system risk.
Test-time empirical risk compared to the upper bound of system risk across different LLMs.
  • Efficiency Gains: The filtering stage significantly prunes the output. For example, on TriviaQA with Llama-3.1-8B, the average prediction set size was reduced from 7.9 candidates to just 5.5 while still maintaining the required coverage of correct answers.
  • Data Efficiency: SAFER is highly robust to the amount of calibration data available. It achieves stable risk control even when the calibration set is small relative to the test set.

Limitations and Future Work

The authors note that SAFER currently relies on the exchangeability assumption—the idea that the data the model sees at test time will look like the data used for calibration. If the real-world distribution shifts significantly, the statistical guarantees might weaken. Future work will likely focus on optimizing the framework to handle such distribution shifts and exploring more sophisticated uncertainty heuristics to further shrink the size of the final prediction sets.

Summary updated

BibTeX
@inproceedings{wang2026safer,
  author = {Qingni Wang and Yue Fan and Xin Eric Wang},
  title = {{SAFER: Risk-Constrained Sample-then-Filter in Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=kJmLmOvwLC},
}
Figure