Week 3 beam search termination criteria

There are 2 stages in beam search:

  1. Candidate generation
  2. Selecting the most likely candidate.

During candidate generation phase, it’s alright to get sentences of varying lengths. Your model might predict <EOS> quite early on some paths.
A candidate path doesn’t impact other candidate paths.

For the 2nd step, to ensure that we don’t prefer shorter sentences over longer sentences, length normalization is done.

As far as termination conditions go, a path is stopped when one of the 2 conditions is met:

  1. Model outputs <EOS>
  2. The maximum timesteps for which you want to generate candidates for is exhausted.

Here’s a lecture you want to watch: