n4nAI

Topic

Sampling Parameters: Top-p, Top-k & Penalties

11 posts on sampling parameters: top-p, top-k & penalties — part of glossary on the n4n AI blog.

11 postsGlossaryAll posts
GlossaryDefinition

What is top-k sampling and how does it work?

A precise technical explanation of top-k sampling for LLM inference, covering mechanics, trade-offs, and practical configuration guidance.

5 min read
GlossaryDefinition

What is nucleus sampling (top-p) in language models?

Nucleus sampling (top-p) dynamically selects tokens from the smallest probability mass covering p% of the distribution, balancing coherence and diversity in LLM output.

3 min read
GlossaryComparison

Top-p vs top-k sampling: what's the difference?

A practitioner's comparison of top-p and top-k sampling, covering mechanics, trade-offs, and when to use each for LLM inference.

5 min read
GlossaryGuide

How top-p and temperature work together

A practical guide to how top-p and temperature interact during LLM sampling, with code examples, common pitfalls, and parameter combinations for different use cases.

5 min read
GlossaryAnalysis

How sampling parameters affect code generation quality

A practitioner's breakdown of how temperature, top-p, top-k, and penalties change code output quality — with concrete API examples and per-use-case settings.

7 min read
GlossaryAnalysis

How random sampling makes every LLM answer a bit different

Understand why LLMs produce different outputs for the same prompt — sampling mechanics, temperature, top-p, and how to control randomness in production.

5 min read
GlossaryGuide

How OpenAI's frequency_penalty parameter actually works

A practical guide to OpenAI's frequency_penalty parameter — how the math works, when to apply it, tuning strategies, and common mistakes that waste tokens.

5 min read
GlossaryComparison

Frequency penalty vs presence penalty, explained

Understand the mathematical difference between frequency penalty and presence penalty, when each reduces repetition, and how to tune them for your use case.

6 min read
GlossaryComparison

Default sampling settings across GPT-4o, Claude, and Llama 3

Compare default sampling parameters across GPT-4o, Claude, and Llama 3 — temperature, top-p, top-k, and penalties — with a verdict on which to choose per use case.

7 min read
GlossaryGuide

Combining top-p, top-k and temperature: a practical guide

A practical guide to combining top-p, top-k, and temperature sampling parameters for LLM inference, with code examples and common pitfalls.

6 min read
GlossaryHow-to

Best top-p value for factual, low-variance answers

Find the best top-p value for factual answers with a repeatable tuning process, code examples, and verification steps for production LLM pipelines.

4 min read