Rejection Sampling
Generating multiple AI outputs and selecting the best one based on specific criteria.
Rejection sampling is a way to get better results from an AI. Instead of just taking the first answer the AI gives, you ask it to generate several answers. Then, you or the system pick the one that is the best according to certain rules.
For example, imagine you ask an AI to write a poem about a cat. It might give you a few different poems. Rejection sampling would involve looking at each poem and choosing the one that best fits what you wanted, like the one that rhymes well or captures the cat's personality most accurately.
Rejection sampling is a Monte Carlo method used for sampling from a probability distribution. It works by proposing samples from a simpler proposal distribution and accepting them with a probability proportional to the ratio of the target distribution to the proposal distribution. This method is often used when direct sampling from the target distribution is difficult.
In the context of language models, rejection sampling can be used during inference to improve output quality. Multiple candidate responses are generated, and a scoring function or classifier is used to select the most desirable output, effectively filtering out less suitable generations. This is related to techniques like self-consistency or diverse beam search, where multiple paths are explored to find a better final result.
Rejection sampling is relevant now as frontier labs focus on improving the quality and safety of AI outputs. Methods like red teaming, mentioned in the Anthropic item, can use rejection sampling to filter out harmful generations. Similarly, improving factual accuracy, as seen in OpenAI's WebGPT, can involve generating multiple answers and selecting the most accurate one.
- Red Teaming Language Models to Reduce Harms: Methods, Scaling Behaviors, and Lessons LearnedAnthropic · Anthropic Research ·
- WebGPT: Improving the factual accuracy of language models through web browsingOpenAI · OpenAI News ·
- Anthropic Claude
- Anthropic's red teaming efforts likely involve generating multiple AI responses and using rejection sampling to identify and filter out harmful outputs.
- OpenAI ChatGPT
- OpenAI's WebGPT demonstrates a form of rejection sampling by generating multiple answers and selecting the one that is most factually accurate and verifiable.
- Importance Sampling
- Importance sampling uses weighted samples from a proposal d
- Metropolis-Hastings
- Metropolis-Hastings is a Markov chain Monte Carlo method th
- Gibbs Sampling
- Gibbs sampling is a specific type of Markov chain Monte Carlo al
Rejection sampling was introduced by Alan Hastings in 1970 as a method for obtaining a random sample from a probability distribution. Source ↗
Ask your AI assistant to generate three short stories about a robot learning to cook. Then, read them and pick the one you like best based on creativity or humor. This mimics rejection sampling by generating multiple options and selecting the most desirable one.
The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.
- PromptRole-play a student struggling with math for AI tutor simulationSimulate a student's math struggles and uncertainty for AI tutor evaluation. · 5 min
- TemplateReusable workflow templates for healthcare teamsTeams can create and share templates for common workflows like documentation or prior authorizations. · 15 min
- TemplateTemplate for building an AI tool tailored to your workA structured approach to defining and building a custom AI tool for specific business needs. · 15 min
- TemplateEvals CSV prompt list for agent skillsA CSV file template for listing prompts used in evaluating agent skills. · 20 min
- HeuristicDouble coding agent task completion with docs linksProviding coding agents with a documentation link significantly increases their task completion rate. · 2 min
Questions people ask
- Why use rejection sampling instead of just asking for one good answer?
- Generating multiple answers increases the chance that at least one of them will be high quality or meet specific criteria, which might be missed with a single generation.
- Is rejection sampling always efficient?
- No, if the proposal distribution is very different from the target distribution, many samples might be rejected, making the process inefficient.
First seen on Subvolts Dec 16, 2021. Updated Sep 15, 2026. Written by an AI model from the items above and reviewed against them weekly; report an error.

