LLM & Transformer Fundamentals·Question 32 of 109Intermediate

Explain min-p sampling and repetition/frequency penalties. When do standard sampling settings fail?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Min-p keeps only tokens whose probability is at least min_p × p_max (the top token's probability), then renormalizes and samples. The threshold scales with model confidence: if the top token has p = 0.9, min_p = 0.1 keeps only tokens above 0.09 - essentially just the head; if the top token has p = 0.1 (genuine uncertainty), tokens above 0.01 survive - wide, appropriate diversity. Contrast with top-p, whose cumulative-mass criterion degrades at high temperature: flattened distributions push the nucleus deep into the junk tail. Min-p stays anchored to the best token, which is why it enables stable sampling at temperatures like 1.5-3 where top-p output falls apart - popular in creative-writing and open-model communities, supported in vLLM and llama.cpp.

Full worked answer

Min-p keeps only tokens whose probability is at least min_p × p_max (the top token's probability), then renormalizes and samples. The threshold scales with model confidence: if the top token has p = 0.9, min_p = 0.1 keeps only tokens above 0.09 - essentially just the head; if the top token has p = 0.1 (genuine uncertainty), tokens above 0.01 survive - wide, appropriate diversity. Contrast with top-p, whose cumulative-mass criterion degrades at high temperature: flattened distributions push the nucleus deep into the junk tail. Min-p stays anchored to the best token, which is why it enables stable sampling at temperatures like 1.5-3 where top-p output falls apart - popular in creative-writing and open-model communities, supported in vLLM and llama.cpp.

Repetition-family penalties exist because autoregressive models have a self-reinforcing loop: repeated text raises the probability of repeating further, and greedy/low-temperature decoding can lock into cycles. Three standard variants: repetition penalty (divide/multiply logits of previously seen tokens by a factor like 1.1-1.3), frequency penalty (subtract an amount proportional to the token's count so far - punishes heavy reuse progressively), and presence penalty (flat subtraction for any token that has appeared at all - pushes topic novelty). OpenAI-style APIs expose the latter two.

When standard settings fail - the part that shows production experience:

  • Structured output/code with penalties on: JSON needs to repeat ", {, ,, field names; code needs repeated identifiers and indentation tokens. Repetition penalties corrupt exactly these - a classic cause of malformed JSON. Turn them off (or near-off) for structured generation; use constrained decoding instead.
  • High temperature + top-p: incoherence via tail sampling - switch to min-p or lower T.
  • T = 0 for long free-form generation: repetition loops - the thing penalties were invented for.
  • Aggressive presence penalty in long conversations: the model starts avoiding necessary domain terms it already used.
  • Also: penalties apply to token IDs, not words - they can't see that "dog" and " dog" are the same word, another tokenization leak.

What a good answer covers

  • Min-p keeps only tokens whose probability is at least min_p × p_max (the top token's probability), then…
  • The threshold scales with model confidence
  • Contrast with top-p, whose cumulative-mass criterion degrades at high temperature
  • Min-p stays anchored to the best token, which is why it enables stable sampling at temperatures like…
  • Repetition-family penalties exist because autoregressive models have a self-reinforcing loop

Key terms: Min-p · Repetition-family penalties · repetition penalty · frequency penalty · presence penalty · When standard settings fail · Structured output/code with penalties on · High temperature + top-p

Interviewer follow-ups to expect

  1. Why does top-p specifically break down at high temperature?

  2. How would you generate guaranteed-valid JSON - sampling settings or constrained decoding?

  3. Why do repetition penalties operate on tokens rather than words, and what artifacts does that cause?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep