AI & LLMs

Greedy Decoding

Always pick the single highest-probability next token — deterministic, but can be repetitive.

Greedy decoding generates text by always choosing the most probable next token at each step. It is deterministic and fast but myopic — a locally best token can lead to a globally worse sentence.

Worked example: greedy picks the top token every step; beam search keeps several candidate sequences to hedge, while sampling with temperature or top-p adds controlled randomness for more varied text. Gotcha: greedy often produces bland or repetitive output and can get stuck in loops, which is why chat models usually sample — but for tasks needing one correct answer (extraction, code) low-temperature or greedy is preferred.