NEW
A decoding approach that generates multiple candidates and selects the best according to a scoring function.
DESCRIPTION
Best-of-N sampling draws N independent generations from a model and returns the candidate with the highest score, such as log probability or a learned reranker. It improves response quality and reduces randomness at increased computational cost. For reasoning tasks, variants combine with self-consistency or vote aggregation. Server-side best-of can hide candidate enumeration and only return the best output. Careful choice of N and scoring prevents mode collapse and maintains diversity when needed.
ALTERNATIVE DEFINITIONS
OpenAI
Generates multiple completions server-side and returns the βbestβ (the one with the highest log probability per token).
Vendor parameter defining server-side candidate reranking by log probability.
Cohere
You can request multiple generations and choose the best output according to your criteria.
Exposes multi-generation capability for client-side selection.
RELATED TERMS
Temperature Reranking Self-Consistency Log Probability Decoding Strategies Diversity Sampling Candidate Generation
COMPETING TERMS
Beam Search Top-k Sampling Nucleus Sampling
RELATIONS
- Broader: Decoding Strategies Sampling
KNOWLEDGE AREAS
TARGET AUDIENCE
AI Engineer Data Scientist MLOps Engineer AI Product Manager
EXTERNAL SOURCES
- Wikipedia - Beam search
- Hugging Face - Guide to text generation strategies
- arXiv - Self-consistency prompting paper
TOP QUESTIONS
When should I use Best-of-N Sampling?
Use it when you can afford extra compute to improve quality, and you have a reliable scoring function like log probability or a task-specific reranker.
Category: Requirements
How does Best-of-N Sampling differ from Beam Search?
Beam search explores a shared tree with pruning, while best-of-N draws independent candidates and selects the highest-scoring one.
Category: Alternatives
What are common pitfalls with Best-of-N Sampling?
Overfitting to log probability can reduce diversity; choosing N too high increases cost without proportional gains.
Category: Mistakes
What is a hot topic around Best-of-N Sampling?
Combining best-of-N with reranking models or self-consistency to enhance reasoning and factuality is active exploration.
Category: Topic
How do I choose N in Best-of-N Sampling?
Empirically evaluate quality vs. latency/cost; many applications see diminishing returns beyond N=5β10.
Category: Management
Does Best-of-N Sampling increase hallucinations?
It can reduce them if the scoring favors factuality; poor scoring might select plausible but incorrect outputs.
Category: Risks
Can I use task-specific rerankers with Best-of-N Sampling?
Yes. Rerankers trained on quality or relevance often outperform log-probability-only selection.
Category: Example
How does temperature interact with Best-of-N Sampling?
Higher temperature increases diversity among candidates, making best-of selection more impactful but potentially less stable.
Category: Requirements
Is Best-of-N Sampling deterministic?
No. It depends on stochastic generation; fixing seeds and settings can improve reproducibility.
Category: Misunderstanding