📌 The Myopic Problem of Greedy Decoding
By default, if you set Temperature to 0, an LLM uses Greedy Decoding. This means that at every single step, the model looks at its options and picks the absolute most likely next word.

The problem with Greedy Decoding is that it ignores the big picture. Sometimes, picking a slightly sub-optimal word right now (e.g., a 40% probability word instead of a 60% probability word) unlocks a significantly better, more coherent phrasing down the line. Because Greedy Decoding never looks ahead, it misses these optimal paths entirely.
📌 The Solution: Beam Search
Beam Search is a decoding algorithm that solves this problem by exploring multiple paths simultaneously.

Instead of just keeping the single best word, Beam Search keeps track of a fixed number of "beams" (e.g., 3 separate paths). It branches out and predicts the next few words for each beam, calculates the cumulative probability of the entire phrase, and then picks the winner.
- Pros: Results in significantly higher quality, more coherent text. It is especially useful in tasks like Machine Translation where grammatical structure requires looking ahead.
- Cons: It is much more computationally expensive and slower than Greedy Decoding, because the model is effectively generating multiple sentences at once behind the scenes.
Quick Knowledge Check
Test what you just learned about Decoding Algorithms
Question 1 of 1
What is the primary disadvantage of using Greedy Decoding?
Loading results...