The article explains the 2014 Bahdanau, Cho, and Bengio paper that introduced additive attention to solve the fixed-length vector bottleneck in RNN encoder-decoder translation models. Previously, the encoder compressed an entire source sentence into a single context vector of fixed dimensionality, causing performance to degrade sharply on longer sentences. The proposed mechanism replaces this static vector with a dynamic context vector \(c_i\) computed at each decoding step \(i\). The encoder, a bidirectional RNN, produces annotations \(h_j\) for each source word \(j\). An alignment model scores each annotation against the previous decoder state \(s_{i-1}\) using learned parameters \(W\), \(U\), and \(v\) via \(\text{tanh}(s_{i-1}W + h_jU)v\). A softmax normalizes these scores into weights summing to one, and the context vector is the weighted sum of annotations. This allows the decoder to "attend" to relevant source positions for each target word. The author demonstrates the computation with a minimal PyTorch example using random tensors, showing how three source words yield a context vector. On a toy task, a fixed-vector model achieved roughly 20% word accuracy at 30-word length, while the attention model approached 100%. The model jointly learns alignment and translation without explicit supervision, and the bidirectional encoder ensures each annotation contains contextual neighborhood information. The Transformer later replaced the additive score with scaled dot-product attention but retained the score-softmax-blend structure.

Read original