{
  "id": "top-k-sampling",
  "code": "PTL-0108",
  "term": "Top-k Sampling",
  "aliases": [
    "top-k"
  ],
  "category": "foundations",
  "definition": "Top-k sampling is a decoding method that, at each step, restricts sampling to the k most probable next tokens and renormalizes their probabilities.",
  "description": "It removes the long tail of unlikely tokens that can derail generation, while keeping some variety. Because k is fixed, it can be too restrictive when many tokens are plausible and too permissive when only one is, which motivated top-p (nucleus) sampling. Many APIs expose top-k alongside temperature and top-p.",
  "example": null,
  "broader": [],
  "narrower": [],
  "related": [
    "temperature",
    "top-p-sampling",
    "greedy-decoding"
  ],
  "introduced": 2018,
  "added": "2026-10-10",
  "sources": [
    {
      "title": "Hierarchical Neural Story Generation",
      "authors": "Fan et al.",
      "year": 2018,
      "url": "https://arxiv.org/abs/1805.04833"
    },
    {
      "title": "The Curious Case of Neural Text Degeneration",
      "authors": "Holtzman et al.",
      "year": 2019,
      "url": "https://arxiv.org/abs/1904.09751"
    }
  ],
  "url": "https://protologue.com/t/top-k-sampling/",
  "citation": "Protologue. (2026). Top-k Sampling. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.4.0, PTL-0108). https://protologue.com/t/top-k-sampling/"
}