Sampling and Decoding

How a language model's next-token scores become text: greedy and beam search, temperature and truncation samplers, logit processors and repetition controls, and grammar-constrained (structured) output. Every distribution on this page is real, computed offline from small open models. Part of Topic: inference-and-serving; data as of October 2026. Reading: 22 min, plus 4 in closed details.

The idea in one screen

A model only scores every token in its vocabulary; a separate rule, the decoder, edits those scores, reshapes them, cuts the unlikely tail and picks one token, and which tokens survive that rule decides whether the same model writes loops, sensible prose, noise or valid JSON.

Fig. 1 is one real next-token distribution through the decoder, 151,936 scores in and one token out: Qwen2.5-0.5B-Instruct writing the opening of a lighthouse story, second token (after "The") measured here (src/reading_numbers.mjs).

  1. Logits. The model scores all 151,936 tokens. The 12 highest stand on the back plinth: " l" (the start of "lighthouse") leads with 14.11; the other 151,924 score from 11.26 down to about −19.7. Only differences between logits matter.
  2. Processors. Penalties, logit bias and a grammar mask would edit the logits here (sections 4 and 5). This request uses none, so the scores pass through unchanged.
  3. Temperature, then softmax. Dividing the logits by T 1.5 shrinks every gap: the top token " l" falls from 22.0% at T 1 to 5.4%, and the tall block on the right, the other 151,924 tokens together, grows from 37.3% to 77.3% of the mass outside the top 12.
  4. Truncate: min-p 0.1. The cut is 0.1 × 5.4% = 0.54%. Min-p 0.1 keeps 22 of 151,936 tokens, the 12 shown and 10 more; the rest of the tail is gone. Top-p 0.9 on the same distribution would keep 6,102 (section 2).
  5. Renormalise. The 22 survivors held 29.2% of the mass; rescaled to sum to 1, the top token rises to 18.6% and the 10 survivors from the tail hold 22.4%.
  6. Choose. Sampling draws one token from the result (this seeded draw picks " l"). Greedy skips steps 3 to 5 and takes the argmax; beam search keeps the B best whole sequences instead of one token (section 1).

You need: logits and softmax (assumed), and what a token is (Tokenizers), which matters for constrained decoding. Where the sampler runs inside a serving engine's step is on vLLM: inside the default engine.

Decoder
the rule that turns one next-token distribution into the next token.
Logit processor
a function that edits the logits before the choice: penalties, logit bias, a grammar mask.
Temperature T
divides the logits; below 1 sharpens, above 1 flattens.
Truncation
dropping the tail before sampling: top-k (a fixed count), top-p or nucleus (a probability mass), min-p (a share of the top token).
Beam search
keeps the B most probable partial sequences instead of one.
Constrained decoding
masking every token that would break a grammar (a JSON schema, a regular expression) at every step.
Perplexity
exp of minus the mean log-probability per token: how surprised a model is by a text.

Numbers are published, with the source linked, unless marked derived (formula shown), measured here (computed offline on a small open model, scripts in the page source) or unconfirmed. Training draws from the same stack for RL rollouts and rejection sampling (Topic: llm-training-and-post-training).

The formula behind steps 1 to 3: one forward pass ends in a vector of logits z, one per vocabulary entry (151,936 for Qwen2.5-0.5B-Instruct, 50,257 for GPT-2), and the softmax with temperature turns them into probabilities:

pi = exp(zi / T) / Σj exp(zj / T)
zi
logit of token i (only differences between logits matter)
T
T = 1 is the model's own distribution; T → 0 puts all the mass on the top token (greedy)

Decoders fall into two families: search is deterministic and looks for a high-probability sequence (greedy, beam); sampling draws at random from a reshaped distribution. Constraints sit before either, as a logit processor.

1. Search: greedy and beam

Greedy decoding takes the argmax token at every step: what temperature 0 means. It is locally optimal and, for open-ended text, repetitive and dull. Beam search keeps the B highest-probability partial sequences: each is extended by its best next tokens, all candidates are scored by total log-probability, and the top B survive. Beam search is the standard for machine translation and summarisation, where outputs are short and closed-ended; chat LLMs essentially do not use it, and greedy is fine only for short factual answers.

In Fig. 2 both run on GPT-2 small continuing a sentence from Jerome K. Jerome's Three Men in a Boat (1889); every score is the model's own log-probability measured here. Each column is one step; a box's height is its sequence's total log-probability (taller is more probable), and faded boxes are hypotheses the decoder dropped.

  1. One hypothesis. The prompt ends "It made me awfully wild,". Greedy keeps a single sequence: each step appends the most probable token and never looks back.
  2. Step 1: " and". Log-probability −0.68, ahead of " but" (−2.23) and " so" (−3.08); the other two are never revisited.
  3. Step 2: " I". −0.73; running total −1.41.
  4. Step 3: " was". −2.12 (total −3.53), ahead of " had" (−2.76) and " couldn" (−3.31).
  5. Step 4: " very". " very" (−2.64) edges out " so" (−2.66) by 0.02. Greedy commits; whatever follows must live with it.
  6. Step 5: " angry". −2.43; running total −8.61.
  7. Step 6: done. "and I was very angry." Six tokens, total log-probability −9.44 (probability 7.9e-5). Switch to beam search to see a more probable path greedy could not find.

Try: step to 4 in beam mode. Greedy's "was very" is still a candidate but scores below three other branches, so beam search drops it. After six tokens the best beam is 6.7 times more probable than greedy's text measured here (exp(−7.54 + 9.44); recompute.py).

More probable is not better. Run both for 80 tokens on the same prompt measured here: both searches fall into a loop the model rates as highly probable; the sample wanders but does not repeat.

Greedy, 80 tokens

Beam search, 4 beams, 80 tokens

Sampled, T = 1, top-p 0.95

Holtzman et al. named this: "using likelihood as a decoding objective leads to text that is bland and strangely repetitive", and natural text's per-token probability is "on average, much lower than text generated by beam search" (§4.3). On 5,000 WebText continuations with GPT-2 Large (762M) they measured perplexity 12.38 for human text against 1.50 for greedy and 1.48 for beam search with 16 beams, and 73.66% of greedy texts repeating (Table 1, Holtzman et al., 2019). Section 3 reruns that comparison on twelve decoders.

Correction: temperature 0 is greedy, but not reproducible on a server
Greedy is deterministic for a fixed computation; a served model is not one, because the batch it shares with other requests changes the kernels' reduction order. Thinking Machines sent the same prompt 1,000 times to Qwen3-235B at temperature 0 and got 80 different completions, diverging at token 103; batch-invariant kernels made all 1,000 identical (He, September 2025; how a server reshapes that batch every step is on Batching, KV cache and scheduling in depth). Anthropic says the same of its API: "temperature = 0 ... never guaranteed identical outputs" (Opus 5.5 migration guide), and its newer models and API version no longer accept a temperature at all (section 6).

At high temperature, top-p's cut chases the tail; min-p's follows the top token

The top 12 of 151,936 tokens are drawn; the last row is every other token together. Grey bar: probability before the cut; blue bar: after. Counts include the tail, computed from a binned summary of all 151,936 logits and checked against the exact count in recompute.py (6,102 against an exact 6,099 kept tokens at T 1.5) measured here.

2. Sampling: temperature, then truncation

Pure sampling at T = 1 lets the long tail in, and a few bad draws derail the text (Holtzman et al. measured perplexity 22.73 for pure sampling against 12.38 for human text). So the stack reshapes first: temperature, then truncation, then renormalise, then sample.

  • Temperature T divides the logits. T < 1 sharpens towards greedy, T > 1 flattens towards uniform. Reasoning models are usually run at T 0.6 to 1.0 so they keep exploring (section 6).
  • Top-k keeps the k most probable tokens (Fan et al., 2018, k = 10 for stories). A fixed k ignores the shape: on a sharp step it lets junk in, on a flat one it cuts good options.
  • Top-p (nucleus) keeps the smallest set whose cumulative probability reaches p, the smallest V(p) with Σx∈V(p) P(x) ≥ p (Holtzman et al., Eq. 2). The set adapts to the distribution; it was the long-time default for open-ended text.
  • Min-p keeps tokens with probability at least pmin × P(top token), typically 0.05 to 0.1 (Nguyen et al., ICLR 2025 oral). The cut follows the model's confidence: confident steps become near-greedy, uncertain ones stay diverse. It is in Hugging Face transformers, vLLM, SGLang and llama.cpp, which enables it by default (min-p 0.05, common.h).
Predict, then open: at T 1.5, on a step where the model is 96% sure of "Canberra", how many of 151,936 tokens does top-p 0.9 keep: one, about fifty, or thousands?
Thousands: 5,166 (exact full-vocabulary count; the animation's binned estimate says 5,209) measured here. At T 1.5 "Canberra" falls from 96% to 59% and about 30% of the mass spreads thinly beyond the top 12 tokens, which top-p must collect back token by token; min-p 0.1 keeps only "Canberra". Check it below with the confident step.

The before/after runs the same real distribution through top-p, the method min-p was proposed to replace, and through min-p: an uncertain step (the lighthouse story of the hero, top token 22%) and a confident one (after "The capital of Australia is", "Canberra" 96%).

  1. Logits. The model's raw scores for the next token, highest first. Only differences matter; the last row, every other token together, has lower logits but very many of them.
  2. Divide by T. A temperature above 1 shrinks every gap between logits by the same factor, so the softmax will be flatter; at T 1 nothing changes.
  3. Softmax. Probabilities. At T 1.5 the top token loses most of its share and the tokens outside the top 12 gain it (the panel under the bars counts them).
  4. Truncate. Top-p sorts the tokens and keeps adding them until their probabilities sum to 0.9: with the mass spread thinly it has to go deep into the tail. Min-p keeps the tokens with at least 0.1 times the top token's probability: its cut follows the top token, not the tail.
  5. Renormalise. The survivors are rescaled to sum to 1; "Effective choices" is exp of the entropy, how many equally likely tokens the result is worth.
  6. Sample. One seeded draw from the final distribution, ringed in green; "Outside top 10" is the chance that a draw lands outside the model's top 10.

Try: the uncertain step at T 2: top-p keeps about 35,700 tokens and min-p 46. That is the whole argument for min-p, on a real distribution.

Disputed: "min-p beats top-p"
The min-p paper reports better quality and diversity on GPQA, GSM8K and AlpacaEval creative writing, and a human preference for min-p. A re-analysis by Schaeffer, Kazdan and Denisov-Blanch (June 2025) found omitted data and incorrect statistical tests in the human evaluation, found that "min-p did not outperform baselines in quality, diversity, or a trade-off between quality and diversity" once hyperparameter counts were controlled, and noted that the community-adoption figures were removed from the paper as unsubstantiated. The mechanism above is not in dispute; whether it buys quality is. Tune both on your own task.

The order is not universal

Hugging Face transformers applies its warpers as temperature, top-k, top-p, min-p, typical; vLLM as penalties, temperature, min-p, then top-k and top-p. llama.cpp applies temperature last by default (penalties, DRY, top-n-sigma, top-k, typical, top-p, min-p, XTC, temperature), so its truncation sees the T = 1 distribution. With llama.cpp's defaults (top-k 40, top-p 0.95, min-p 0.05) at T 1.5, the uncertain step keeps 14 tokens with temperature last and 34 with temperature first measured here. The Sampler lab has the switch, every knob on this page and 32 real distributions.

The long tail of samplers (typical, mirostat, top-a, XTC, DRY)
SamplerRuleSource
Typical samplingKeep the tokens whose surprisal −log p is closest to the distribution's entropy, until their mass reaches typical_p ("entropy-relative"). At 0.5 it drops the single most likely token on four of the five uncertain steps tried in the lab (Lighthouse 1 and 2, Kitten 1 and 3), because its surprisal is far below the entropy measured here.Meister et al., 2022; in the lab
MirostatAdjust a top-k-like cut on the fly so that the text's surprise stays near a target (τ = 5 by default in llama.cpp)Basu et al., 2020
Top-aKeep tokens above a threshold proportional to the square of the top probabilitylocal-model community; origin unconfirmed
XTC (exclude top choices)With some probability, remove every token above a threshold except the least likely of them: cuts the most likely tokens, not the least, to break clichésp-e-w, text-generation-webui PR 6335 (2024)
DRY (don't repeat yourself)Penalise a token that would extend a sequence already in the context, by multiplier × base(length − allowed length) (base 1.75, allowed length 2 in llama.cpp)llama.cpp common.h

Most are niche, from the local-model community. Mirostat and DRY act on a generated sequence rather than one distribution, so the lab leaves them out.

3. Diversity against quality: twelve decoders on real text

Every truncation trades diversity for staying in the model's high-probability region, and human text sits in between. GPT-2 small (124M) is given the first 48 tokens of four paragraphs of Three Men in a Boat and writes 48 more, 16 times per decoder; the book's real next 48 tokens are the human reference measured here.

  • Search loops. Greedy and beam search sit far below human perplexity (2.3 and 2.4 against 31.0 for the real continuation), and 53% of greedy's 4-grams are repeats.
  • Top-p 0.95 at T 1 lands closest to human text (31.6 against 31.0), as nucleus sampling did in the paper (13.13 against 12.38); pure sampling overshoots (47.2).
  • Raise the temperature and top-p falls apart (perplexity about 3,900 at T 1.5) while min-p 0.1 stays near human text up to T 2 (16.1 at T 1.5, 40.0 at T 2): the mechanism of section 2, measured on text. This is likelihood under the same model, not quality as judged by people.

Defaults reproduce the ordering of Holtzman et al.'s Table 1 independently (GPT-2 small and 4 passages here; GPT-2 Large and 5,000 WebText passages there): search far below human perplexity (greedy 2.26, beam 2.37 against 31.0; theirs 1.50 and 1.48 against 12.38), pure sampling above it (47.2; theirs 22.73) and top-p 0.95 closest (31.6; theirs 13.13). The absolute values do not compare across the two studies: a smaller model is more surprised by everything. Perplexity near human is a necessary condition for human-like text, not a measure of quality.

Search sits far below human perplexity; top-p explodes with temperature, min-p does not

Perplexity: exp of minus the mean log-probability per token under GPT-2 small at T = 1 (human text is the target, not the minimum). Diversity: distinct-2 over the 16 samples of a passage (greedy and beam give one text 16 times, so their figure is divided by 16). Hover a dot for its decoder; the table in the closed block below has every value.

Every decoder's numbers, and the texts themselves (table and sample reader)

Repetition: share of a text's 4-grams that repeat an earlier 4-gram.

Every sampled decoder starts from the same random seed, so pure sampling and top-p 0.95 often write the same words until the first draw that top-p's cut removes. Texts are GPT-2's, unedited except that newlines are shown as ↵ and any em-dash the model wrote is shown as "--". Three samples per passage are shown, skipping any that match a short list of slurs, sexual and violent words (GPT-2 at high temperature produces them); the measures use all 16. Em-dashes in Jerome's text were replaced by commas before tokenising. Script: src/make_data.py degen; numbers: src/recompute.py.

4. Logit processors: penalties, bias and masks

Step 2 of Fig. 1 is one interface in every framework: a logit processor takes the tokens so far and the logits, and returns edited logits. In transformers it is LogitsProcessor.__call__(input_ids, scores), and the repetition penalty, no-repeat n-gram, minimum length (suppress the end token) and token bans are all processors applied before the warpers. OpenAI-style APIs and open servers expose the simplest one as logit bias: a value from −100 to 100 added to a token's logit before sampling, where −100 effectively bans it (OpenAI API reference; vLLM's logit_bias and allowed_token_ids in sampling_params.py). A grammar mask (section 5) is a processor that adds −∞.

The repetition controls are processors that use counts of what is already in the context:

  • Repetition penalty (CTRL, Keskar et al., 2019, who found θ ≈ 1.2 a good balance with greedy sampling): every token already in the context has its logit divided by θ if positive and multiplied by θ if negative; transformers counts the prompt too.
  • Presence and frequency penalties (the OpenAI pair): zj → zj − cj·αfrequency − [cj > 0]·αpresence, where cj counts how often token j was already sampled; "around 0.1 to 1" to reduce repetition somewhat, up to 2 to suppress it strongly at a cost in quality (OpenAI docs). Qwen3's card suggests presence_penalty 0 to 2 against endless repetition, warning of language mixing at high values (card).
  • No-repeat n-gram bans any token that would complete an n-gram already generated (transformers' no_repeat_ngram_size).

A repetition penalty cannot tell a loop from a correct repeat

Qwen2.5-0.5B-Instruct continuing the pattern "red, blue, red, blue, red," at position 7 of its reply ("red, blue, red,"): the right next token " blue" is already in the context three times (the prompt counts) and was generated once. Repetition penalty 1.3 divides its logit 25.72 by 1.3, so the runner-up " and" (17.59) gains, and " blue" falls from 99.9% to 73.6%; a frequency penalty of 1 subtracts 1 per generated occurrence and barely moves it (99.7%) measured here. Penalties are blunt instruments, needed less as models improved and still useful for small models.

5. Constrained decoding: JSON schemas and grammars

Constrained (or structured) decoding guarantees that the output matches a format, a JSON schema, a regular expression or a context-free grammar, by masking every token that would break it at every step: an engine compiles the constraint to an automaton over the tokenizer's vocabulary, tracks the automaton's state as tokens are emitted, and before the sampler runs sets every disallowed logit to −∞. The running example: Qwen2.5-0.5B-Instruct, greedy, asked to extract {"name": string, "age": integer} from one sentence. Its favourite first token is a Markdown fence, which no JSON parser accepts.

  1. The model's first step. Its favourite first token is the Markdown fence ``` (56.9%), then {↵ (35.4%); the other 151,657 tokens hold 1.3% together.
  2. The mask. The grammar allows 4 of 151,665 tokens to start the object (the bright sliver of the vocabulary strip, widened to be visible). An allowed token gets 0 added to its logit, every other one −∞.
  3. Add it. Every masked logit becomes −∞, so its probability becomes exactly 0: the fence and the prose openings drop out. The 4 allowed tokens held 35.5% of the mass.
  4. Renormalise. The softmax renormalises the survivors: {↵ goes from 35.4% to 99.5%, {" from 0.16% to 0.44%.
  5. Choose. The sampler (greedy here) runs on the masked distribution as usual and takes {↵, the model's second choice. The grammar's state moves on, and the next step gets a new mask (Fig. 4 counts them).

The model's real probabilities at the first step measured here; the formula, in the same names:

z′i = zi + mi,   mi = 0 if token i keeps the grammar completable, else −∞  ⇒   p′i = pi / Σj allowed pj
m
the mask: a bit per vocabulary entry, recomputed from the grammar's state after every token
p′
at T = 1, masking then softmax is the model's distribution conditioned on the allowed set

The mask changes size at every step, and that is what makes it expensive or cheap. Inside a string almost anything is allowed; at a structural position only a handful of tokens are.

Fig. 4 · How many tokens the grammar allows, token by token

The constrained run's 19 steps, picked token under each bar. Inside the name about 76,660 of 151,665 tokens are allowed; at structural positions 1 to 17. Orange bars are steps where the allowed tokens held under 5% of the model's probability, so the grammar overruled it: step 2 (0.0004%) and step 10 (2.5%), both whitespace, explained below. At step 13 the model gave 22.6% to a quote, which would have made the age a string; the integer type masked it measured here.

The whole run, without and with the mask, is a widget you step through (24 tokens unconstrained, 19 constrained): the token list shows the model's top 8 at each step with its own probabilities, a tick marking those the grammar allows; in the constrained mode the masked ones are struck out and the picked token is ringed. Same weights, same greedy rule: the unconstrained run writes its fences and fails to parse, the constrained one parses.

Try: step 0 in both modes: the model puts 57% on ```; the constrained run starts with {. Then step 2 of the constrained run: the model wants two spaces of indentation, the toy grammar's whitespace cap forbids the second, and it is forced onto a token it gave 0.0004%. The output is still valid JSON, with one-space indentation.

Same weights, same greedy rule: only the mask differs

The request is illustrative (a made-up person); everything else is the model's real output measured here. A tick marks tokens the grammar allows.

The toy grammar and how the masks were computed

The grammar is a regular expression, with whitespace capped at two characters between JSON tokens:

\{[ \n]{0,2}"name"[ \n]{0,2}:[ \n]{0,2}"[A-Za-z .\-]{1,40}"[ \n]{0,2},[ \n]{0,2}"age"[ \n]{0,2}:[ \n]{0,2}(0|[1-9][0-9]{0,2})[ \n]{0,2}\}

At every step each of the 151,665 tokenizer strings was checked with the regex package's partial matching: a token is allowed when the text so far plus the token can still complete a match (src/make_data.py json). That is a brute-force check of the whole vocabulary at every step; the engines below exist to avoid it.

How engines make the mask fast

EngineGrammar and methodMask cost and where it runs
OutlinesRegular expression or JSON schema compiled to a finite-state machine over tokens, with an index of which tokens are allowed in every state: "transitions between the states of a finite-state machine" (Willard and Louf, 2023). The approach that popularised near-zero-overhead structured output.a lookup per step once the index is built
XGrammarFull context-free grammars with a pushdown automaton. Tokens are split into context-independent ones, whose validity depends only on the automaton's position and is precomputed, and context-dependent ones, checked at runtime against a persistent stack: for Llama-3.1 and a JSON grammar the context-dependent tokens are "less than 1% (1134 out of 128k)", cut to 120 by context expansion (Dong et al.).under 40 µs per token for JSON schema, overlapped with the GPU's forward pass. Default backend in vLLM (the "auto" backend tries XGrammar first and falls back to llguidance: sampling_params.py), SGLang (serving_hook.py), TensorRT-LLM and MLC-LLM (README); where SGLang calls it in its scheduler, and the jump-forward decoding SGLang removed in v0.4.4, are on SGLang, section 6
llguidance (behind Guidance)An Earley parser on top of a lexer built from regular-expression derivatives; masks computed lazily by walking a trie of the vocabulary.about 50 µs per token for a 128k tokenizer. "LLGuidance shipped in OpenAI for JSON Schema"; in llama.cpp, vLLM (from 0.8.2), SGLang (from 0.4.4) and Chromium (README)

Provider "structured outputs" and strict function calling are this mechanism plus training. OpenAI's Structured Outputs works "by constraining OpenAI models to match developer-supplied schemas and by training our models to better understand complicated schemas"; the schema is converted to a context-free grammar; gpt-4o-2024-08-06 scored 100% on its complex-schema eval against under 40% for gpt-4-0613 (OpenAI, 6 August 2024, archived). JSON mode guarantees valid JSON; only Structured Outputs guarantees schema adherence (docs). Grammar-constrained tool-call parsing is standard in serving stacks.

What the mask costs in quality
  • It guarantees the format, not the content. When the model wanted a token you masked, the rest of the answer is conditioned on text it would not have written (0.0004% at step 2 above). Schema design (field order, letting the model think before the JSON) mitigates it. The size of the effect is disputed: Tam et al., 2024 report "a significant decline in LLMs reasoning abilities under format restrictions"; the Outlines team re-ran their tasks with matched prompts and found structured generation slightly better (GSM8K 0.78 against 0.77, Last Letter 0.77 against 0.73, Shuffled Objects 0.44 against 0.41: .txt, "Say what you mean").
  • Whitespace and token boundaries are the classic bugs. A token can straddle a grammar boundary (": closes a key and starts the colon), whitespace rules decide which tokenisations are reachable (steps 2 and 10 above), and an unbounded whitespace rule lets a model emit spaces forever.

6. Settings in practice

UseTypical settingWhere it comes from
ChatT about 0.7 with top-p 0.9 to 0.95, or min-p 0.05Rule of thumb from the original page unconfirmed as a standard; close to published defaults: llama.cpp T 0.8, top-k 40, top-p 0.95, min-p 0.05 (common.h); Qwen3 non-thinking T 0.7, top-p 0.8, top-k 20 (card)
Reasoning modelsT 0.6, top-p 0.95; never greedyQwen3 thinking mode: T 0.6, top-p 0.95, top-k 20, min-p 0, "DO NOT use greedy decoding" (endless repetitions, card). DeepSeek-R1: T 0.5 to 0.7, 0.6 recommended, "to prevent endless repetitions or incoherent outputs" (card)
Code and maths, one answerGreedy or near it, T 0 to 0.3Codex found the best temperature for pass@1 is 0.2 and for pass@100 is 0.8 (Chen et al., 2021)
EvaluationsFix seeds and settings, or sample k answers and report pass@k or majority voteDeepSeek-R1 reports pass@1 as the mean over 64 samples at T 0.6, top-p 0.95 (card); majority vote is self-consistency (Wang et al., 2022)
Closed reasoning APIs fix the sampler for you
The knobs on this page are mainly for open models you serve yourself; on the large closed reasoning APIs the provider fixes sampling. Claude 4.7 and later models accept only the default values: with API version 2023-06-01 any non-default temperature, top_p or top_k "returns a 400 error" (Anthropic, Opus 5.5 migration guide), and API version 2026-10-21 (21 October 2026) removes the three parameters altogether: sending one returns 400 "even at the parameter's default value", and a request samples at the defaults, temperature 1.0. On an older model that still honoured a lowered temperature, such as Sonnet 4.6, the new version loses that effect and "No other setting replaces it"; such a request has to stay on 2023-06-01 (migration guide). OpenAI's reasoning models other than GPT-6 Astra do not support temperature, top_p, presence_penalty, frequency_penalty, logprobs or logit_bias; GPT-6 Astra supports temperature and top_p (Azure OpenAI reasoning docs, 21 September 2026). What stays in the caller's hands on those APIs is the output's shape (structured outputs, section 5) and how much it thinks, not the sampler.

7. Built on sampling (owned elsewhere)

  • Self-consistency and best-of-n sample n answers and return the majority answer (Wang et al., 2022) or the one a verifier or reward model rates highest; best-of-n is also a baseline alignment method and a reward-hacking amplifier (Reward Hacking). The maths of pass@k, voting and best-of-n, with a sampling lab: Test-time compute and reasoning, sections 2 and 3.
  • Speculative decoding drafts several tokens cheaply (a draft model, n-gram lookup, or extra heads such as Medusa and EAGLE) and verifies them in one target pass with an acceptance rule that leaves the output distribution exactly the target's, so every sampler on this page works unchanged. The rule, every kind of drafter and the batch size where it stops paying: Speculative decoding.
  • Test-time compute scaling, longer chains of thought and parallel sampling with a verifier, is the decoding-side half of the reasoning-model story; the training-side half (RL with verifiable rewards) is on Alignment: SFT, RLHF, DPO Family, RLVR.

Text watermarking is the one technique built on sampling that this page owns. The sampler's random draw is replaced by a choice that a secret key and the preceding tokens decide, so each pick is still drawn from the model's distribution and the text reads the same, but many such picks together carry a statistical signal a key holder can test for. Google DeepMind's SynthID-Text does this with tournament sampling (Dathathri et al., Nature 2024); Claude's watermark, announced 14 August 2026, "is a version of the SynthID-Text approach" and "only changes the source of the randomness used to pick among words" (Anthropic). Its limits follow from the mechanism: few acceptable word choices (code, tightly constrained or factual text) leave little signal, short samples detect poorly, and a complete rewrite removes it; detection is a key holder's API in private preview, not a public detector.