Main Point
A defined transformer block combines attention, learned feedforward transformations and separate residual/normalization operations. Trace the actual order and input to each path to explain what the block computes.
Key Points
- Multiple heads use different learned projections; their outputs are combined.
- A head number does not establish a named human skill.
- In the original post-normalized encoder, attention has its own residual addition and normalization before feedforward.
- The feedforward sublayer has a separate residual addition and normalization.
- Nonlinearity makes the learned composition more expressive than a single linear transformation.
- Repeated blocks transform the sequence through multiple stages; architecture details matter for serving.
1. Follow a defined architecture
Use the encoder in Vaswani and colleagues’ 2017 Transformer paper as the historical worked architecture. Its input is a sequence of vectors with input and positional information. At a position, call its incoming vector x. Attention processes the sequence while a separate path preserves x for the subsequent addition.
Later pre-normalized architectures arrange normalization differently. An architectural claim needs the diagram and specification for the particular model being discussed.
2. Combine multiple heads
The original design uses 8 attention heads. Each has learned query, key and value projections and computes its own allowed-position value mixture. The head outputs are concatenated: their coordinates are placed together. A learned output projection then combines that larger representation into the attention sublayer’s output.
This is a defined combination of computed vectors. It does not select 1 winning head. Different projections can make different relationships available, but the name “arithmetic expert” needs behavioral evidence rather than a suggestive diagram label.
3. Add the attention residual, then normalize
The 1st residual connection carries x around attention. Add corresponding coordinates of x and the attention output. For the supplied addition-only illustration:
`x=(2,1)`
`attention output=(0.5,−0.5)`
`sum=(2.5,0.5)`
These are classroom values, not a recorded attention head output. The sum is not yet the normalized state. Layer normalization then uses a position’s coordinate mean and variance, a numerical stabilizer and learned scale/offset parameters to adjust the representation. Call the resulting state y.
`y=LayerNorm(x+Attention(x))`
This notation summarizes the defined sublayer order; training details such as dropout are outside this simplified inference-oriented trace. We have not supplied normalization parameters or computed y numerically.
4. Transform each position through feedforward
The same learned feedforward network applies separately to each position’s y. In the original block it has a linear transformation, ReLU and another linear transformation. ReLU passes positive values through and replaces negative values with 0. A supplied intermediate pair `(−1,2)` therefore becomes `(0,2)` at this operation.
The learned matrices and biases are model parameters; the intermediate values are input-dependent activations. Attention mixes information across allowed positions. This feedforward stage transforms information within each position. Without an intervening nonlinearity, the pair could collapse into 1 transformation with weights and a bias.
5. Add the feedforward residual, then normalize
Carry y around the feedforward network. Add its output to y and apply the 2nd layer normalization:
`z=LayerNorm(y+FFN(y))`
The 2nd path begins at y, not at the block’s earlier input x. The complete simplified sequence is:
`x → attention → add x → normalize to y → feedforward → add y → normalize to z`
Keep both additions and both normalization sites visible. The connection is part of the computation rather than a decorative arrow.
6. Repeat blocks and inspect configuration
The original encoder stacks 6 blocks of this architectural form. Repeating the form does not require their learned parameters to be identical. The final sequence has undergone repeated mixing and transformation; later output projections and vocabulary scores have their own functions.
For serving, head arrangements and key/value dimensions affect cache storage. Feedforward matrix shapes affect computational work and hardware use. Inspect the actual configuration before estimating those quantities from a model name. This lesson supplies no measured memory requirement or deployment result.
7. Closing
You can now explain what enters each sublayer, what its residual path carries and which state leaves. That lets you detect a missing operation without assigning invented human jobs to heads. Next, compare model families by their permitted information paths and training tasks.
8. Learning Checks
Attempt the questions before opening their explanations. The worksheet has blank space for your own trace.
M14-L07-Q01
Trace the original post-normalized encoder block from x. Where do its 2 residual paths begin? Does feedforward occur before or after the 1st normalization?
Your explanation: ____________________
Show explanation after your attempt
The 1st residual path starts at x. Add the attention output to x, then normalize to obtain y. The feedforward network transforms y, and the 2nd residual path also starts at y. Add that network’s output to y, then normalize again. Feedforward follows the 1st addition and normalization. There are 2 distinct residual paths around 2 sublayers in this original post-normalized design.
M14-L07-P01
A proposed diagram shows attention, then feedforward, then 1 final addition of the original input and 1 normalization. A colleague calls the omitted connections drawing shortcuts and labels head 3 the arithmetic expert. Diagnose the diagram and identify evidence needed for that head label.
Your explanation: ____________________
Show explanation after your attempt
The diagram omits the attention sublayer’s own addition and normalization, so it does not preserve the original computation. It also uses x where the feedforward residual should use y, the state after the 1st normalization. Restore y=LayerNorm(x+Attention(x)), followed by z=LayerNorm(y+FFN(y)). Head 3’s number establishes no arithmetic role. A defined behavioral test and evidence about that head’s contribution are needed before using that functional label.
Sources
- Vaswani, Ashish, and colleagues. *Attention Is All You Need*. Original preprint 12 June 2017; v7, 2 August 2023. Primary paper, sections 3.1–3.3 and Figure 1; version history. Retrieved 30 October 2026. The worked block is the historical original post-normalized encoder. The addition and ReLU numbers are supplied classroom illustrations, not measured model activations.