Open Agent School · Public worked example

Top-k sampling: meaning and example

Welcome! Take one idea with you today.

A generation method that limits the next-token candidates to the k highest-scoring tokens before sampling.

Picture it: With k set to 5, select the next token from the five leading candidates.

What is easy to mix up?

Restricting candidates changes output diversity; it does not verify facts.

Teaching example by Open Agent School. Source: Google - Machine Learning Glossary.