← All models

MODEL EXPLORER / LANGUAGE MILESTONES

Choose source context for the next decoder step

How does a recurrent decoder decide which source positions to consult?

Curated by TensorVizBahdanau additive attention · 4-step tour
Static architecture
How does a recurrent decoder decide which source positions to consult?
Opening the interactive graph…
Architecture snapshot · No Python requiredDownload graph ↓

RECORDED NUMERICAL EXAMPLE

Ask the source a different question at each step.

Recorded additive alignment for a fixed source sequence under three decoder states. In translation, the evolving decoder state makes this context change at every generated token. This lesson captures one such step.

The same five synthetic source IDs produce fixed bidirectional annotations. Only the previous decoder state changes here. The learned additive score determines the weighting used by this step. These untrained alignments do not map translated words or demonstrate translation quality.

Source annotations · five positions × eight features

Min -0.3219 · Max 0.6347

Recorded cell values
Row / col01234567
0-0.1275-0.010180.2421-0.006486-0.17510.0069590.10050.08204
1-0.080450.19930.29120.36430.14290.287-0.21020.2492
20.018380.36670.31440.59970.27240.4881-0.11820.1885
3-0.32190.28170.43260.60040.23030.63470.11540.02379
4-0.16950.360.43250.57840.12420.1659-0.069910.07757
Alignment · one decoder step × five source positions

Min 0.1867 · Max 0.2096

Recorded cell values
Row / col01234
00.18670.1990.20960.20750.1972

Each heatmap uses its own scale. Mint is positive, rust is negative, and the lightest color is zero. Table values are rounded to four significant digits.

Previous decoder state
0
0
0
0
0
0
0
0
Weighted context
-0.1362
0.244
0.3441
0.4356
0.1251
0.3251
-0.03766
0.1247

Bars share one scale within this example. Values are rounded to four significant digits.

Alignment weight sum
1
Most weighted source position · zero-based
2
Verified by the local recipe
  • Alignment weights are positive and sum to one over source positions
  • The context equals an independent weighted sum of bidirectional annotations
  • A changed final source token can affect the first annotation through the backward GRU
  • Changing decoder state changes alignment; zero scores give the mean source annotation

Download the source and run.py to reproduce these checks. Choosing an example here replays recorded values.

ABOUT THIS EXAMPLE

Trace bidirectional annotations into additive alignment, then change the previous decoder state and inspect its weighted source context.

Component · 2014

Bahdanau additive attention

Five source tokens with width-four embeddings; bidirectional GRU annotations of width eight; additive alignment and one width-eight GRUCell decoder update. A simple linear vocabulary head replaces the original output architecture.

Source, capture & limitations +

Untrained attention subsystem and a single decoder step, not a complete translation system. It omits the paper's exact decoder/maxout output formulation, variable-length padding and training recipe. Publication began as a 2014 preprint and appeared at ICLR 2015.

Original TensorViz teaching example. PyTorch provides the underlying operators.

No separate redistribution license has been declared for these project examples.

Content revision
6f6805ea39bc1506
Source SHA-256
5fadad4ddf6e107b09d66c42307c4804cae1bbd5346ef8e4c927b6db0034a44c
Captured
2026-09-17 · Python 3.13.13 / Torch 2.7.1

One reduced additive-attention decoder step with a bidirectional GRU encoder. Alignment normalization, context-sum, bidirectional influence and decoder-state sensitivity checks.

Read the model manifest ↗