Luong Attention › Limitations and Impact

Michael BrenndoerferMay 18, 20254 min read
Language AI HandbookAll chapters
Part 12 of 67Sequence-to-Sequence
Chapter 88Luong Attention › Limitations and Impact
Reading section 8 of 11 · Limitations and Impact · 4 minSection 8 of 11 · 4 min

Book contents

Section 8 of 11 · 4 min read

Luong Attention › Limitations and ImpactOne section · Sections in this chapter8 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Luong attention addressed several limitations of Bahdanau attention while introducing its own trade-offs. Understanding these helps contextualize attention's evolution toward transformers.

Computational Efficiency

The dot product score function is significantly faster than additive attention, especially for long sequences. With hidden dimension dd and sequence length SS, dot product requires O(Sd)O(Sd) operations compared to O(Snd)O(Snd) for additive attention (where nn is the intermediate dimension). This efficiency gain compounds during training when attention is computed millions of times.

However, dot product attention has a subtle numerical issue: when the hidden dimension is large, dot products can become very large in magnitude. This pushes softmax toward extreme values (near 0 or 1), causing gradient saturation. The transformer architecture addresses this with scaled dot-product attention, dividing by d\sqrt{d} to keep values in a reasonable range.

Out[21]:
Visualization
Line plot showing score standard deviation growing with hidden dimension for unscaled versus scaled attention.
Standard deviation of dot product scores as hidden dimension increases, for unit-variance random vectors. Unscaled scores (red) grow as the square root of the dimension, reaching std above 30 at d=1024. Dividing by the square root of d (green) keeps scores near unit variance regardless of dimension.
Grouped bar chart showing attention weight distributions becoming sharper as score magnitude increases.
Effect of score magnitude on softmax output. As the score scale increases from 1 to 50, attention concentrates almost entirely on the highest-scoring position. Large dot products in high-dimensional spaces produce this same sharpening effect, causing gradient saturation during training.

Expressiveness vs Simplicity

General and concat attention are more expressive than dot product, able to learn arbitrary compatibility functions. But this expressiveness comes at a cost: more parameters, slower computation, and potential overfitting on small datasets. Empirically, the simpler dot product often performs comparably or better, suggesting that the encoder and decoder learn representations where raw similarity is a good proxy for alignment.

This finding influenced the design of transformers, which use dot product attention exclusively. The lesson is that with sufficient model capacity and data, simple mechanisms can match or exceed complex ones.

Sequential Bottleneck

Both Bahdanau and Luong attention still rely on RNNs for the encoder and decoder. This creates a sequential bottleneck: each timestep must wait for the previous one, preventing parallelization. Attention helps by providing direct connections to encoder states, but the fundamental limitation remains.

Transformers eliminate this bottleneck entirely by using self-attention instead of recurrence. Each position can attend to all other positions in parallel, enabling massive speedups on modern hardware. Luong's dot product attention, combined with the key-query-value formulation, became the foundation for this revolution.

Legacy and Influence

Luong attention's most lasting contribution is demonstrating that simple, efficient attention mechanisms work well. The dot product score function, attention after the decoder step, and the idea of multiple attention variants all influenced subsequent research. When Vaswani et al. designed the transformer, they chose scaled dot-product attention, directly building on Luong's work.

The distinction between global and local attention also foreshadowed later work on sparse attention patterns. Transformers face quadratic complexity in sequence length, and researchers have explored various ways to restrict attention to local windows or learned patterns. Luong's local attention was an early exploration of this trade-off between expressiveness and efficiency.