Two finished hypotheses have token probabilities H1=(0.4, 0.5) and H2=(0.6, 0.6, 0.6, 0.6). Which one does beam search prefer by raw log-probability? Which by average log-probability, and which by GNMT length normalisation log⁡P/((5+∣Y∣)/6)? What bias does this show?

Sequence models and transformers, Decoding
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you see that the product of probabilities penalises long outputs and how length normalisation changes the ranking.

Key idea

Raw log-probability sums negative terms, so each extra token lowers the score. Dividing by a length penalty lp(∣Y∣) compensates, but the choice of lp can decide the winner.

Steps

  1. log⁡P(H1)=ln⁡(0.4×0.5)=ln⁡0.2=−1.6094. log⁡P(H2)=4ln⁡0.6=−2.0433.
  2. Raw score: −1.6094>−2.0433, so H1 wins. It is shorter, even though each token of H2 (probability 0.6) is more confident than those of H1.
  3. Average log-probability: H1:−1.6094/2=−0.8047; H2:−2.0433/4=−0.5108. Now H2 wins.
  4. GNMT (Google's Neural Machine Translation) penalty with exponent 1: lp(2)=7/6=1.1667 and lp(4)=9/6=1.5. Scores −1.6094/1.1667=−1.3795 and −2.0433/1.5=−1.3622. H2 wins narrowly.
  5. Raw beam search is biased towards short outputs (sometimes producing empty or truncated translations). Full average normalisation can bias towards long, repetitive ones.
  6. So the length penalty is a hyperparameter, tuned on validation data. With the GNMT exponent α<1 the penalty is milder and the result could change; here, the margin of 0.0173 is small.

Common mistakes

How long your answer should be

Half a page; 4 minutes.

Read this

Previous in Sequence models and transformers: Training compute is approximately C≈6ND FLOPs for N parameters and D tokens. The Chinchilla result suggests a compute-optimal ratio of about D≈20N. (a) For C=1023 FLOPs, what N and D are compute-optimal? (b) How many tokens and how much compute does a compute-optimal 7B model need? (c) How much compute does a 70B model trained on 1.4T tokens use?
Next in Sequence models and transformers: A single-layer LSTM has input size 128 and hidden size 256. How many trainable parameters does it have (one bias vector per gate), and how does the count compare with a GRU and a plain RNN of the same sizes? What changes if the LSTM is bidirectional?