Example

Example of Greedy Search Sequence Generation

Consider a sequence generation model with an output dictionary consisting of the tokens "A", "B", "C", and "". A greedy search strategy selects the token with the highest conditional probability at each time step. Suppose that at step 1, the token with the highest probability is "A" (probability 0.5). At step 2, conditioned on generating "A", the most probable token is "B" (probability 0.4). At step 3, conditioned on "A" and "B", the most probable token is "C" (probability 0.4). Finally, at step 4, the model selects "" (probability 0.6). The greedy search algorithm therefore predicts the sequence "A", "B", "C", and "". The conditional probability of this entire output sequence is the product of the individual probabilities: 0.5 \times 0.4 \times 0.4 \times 0.6 = 0.048.

Image 0

0

1

Updated 2026-06-26

Tags

D2L

Dive into Deep Learning @ D2L