Example

Example of a Suboptimal Greedy Search Outcome

A greedy search sequence is not always optimal because early sub-optimal token choices can lead to higher subsequent probabilities. Suppose a greedy search yields the sequence "A", "B", "C", "" with a total probability of 0.048. Alternatively, if the model instead selects the token with the second highest conditional probability at step 2 (e.g., token "C" with probability 0.3), the context for step 3 changes from "A", "B" to "A", "C". This change alters the conditional probabilities for subsequent tokens. Choosing "B" at step 3 and "" at step 4 might yield new probabilities, such as 0.6 and 0.6, respectively. The overall probability of this new sequence "A", "C", "B", "" would be 0.5 \times 0.3 \times 0.6 \times 0.6 = 0.054, which is greater than the greedy search's result of 0.048, proving the greedy approach missed the most likely sequence.

Image 0

0

1

Updated 2026-05-14

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L