What does 'position-wise' actually mean for the transformer FFN sublayer?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Position-wise means the same FFN weight set is applied independently to every token in the sequence.
Imagine a transformer block as a two-stage assembly line. The first stage, attention, is a group meeting where every word talks to every other word and gathers context. The second stage, the FFN, is a private booth where each word goes in alone, gets reshaped according to a fixed recipe, and comes back out. Crucially, the recipe is the same for every word; nothing about the booth changes between word 1 and word 100. Also, two words in two adjacent booths never see each other. The booth is private and per-word. The booth's only job is to transform a single word; the group meeting was where the cross-talk happened.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: precise meaning of position-wise, the (B, T, D) reshape test, why attention and FFN have different roles, the O(n) vs O(n^2) asymptotic split, mechanistic implication for FFN-as-memory, MoE as the natural extension.
| Property | Attention sublayer | FFN sublayer (position-wise) |
|---|---|---|
| Cross-token mixing | Yes, reads and writes across positions | No, operates per position |
| Cost in seq_len | O(n^2 * d_model) | O(n * d_model * d_ff) |
| Weight sharing across positions | Yes (Q, K, V, O matrices shared) | Yes (W_up, W_down shared) |
| Permutation behavior | Permutation-equivariant given positional encoding | Permutation-equivariant |
| Per-token output depends on | All tokens in the sequence | Only that token |
| Role in mechanistic story | Routing / cross-token information transfer | Per-token knowledge retrieval and transformation |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Thinking 'position-wise' means the weights vary by position. It means the opposite: the weights are SHARED across positions and the operation is applied INDEPENDENTLY at each position.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.