Transformers interview question

Deep LearningTransformersAttentioneasy

As an ablation, you delete every self-attention sublayer from a trained BERT-style encoder but keep the token and position embeddings, the feed-forward (FFN) sublayers, the residual connections and the LayerNorms. Which statement about the resulting network is correct?

  1. AEach output now depends only on its own token and position, since the FFN and LayerNorm apply the same function to each position separately; only attention moves information across tokens.
  2. BTokens still exchange information through the FFN, because it is a dense layer applied to the whole sequence matrix at once, so context only spreads more slowly than it does with attention.
  3. CTokens still exchange information through LayerNorm, because it normalizes each feature across all positions in the sequence, so every output still reflects the other tokens' statistics.
  4. DTokens still exchange information through the residual connections, which add each position's vector to its neighbours' outputs, so the model keeps a local, convolution-like view of context.
Show the answer and explanation

Correct answer: A, Each output now depends only on its own token and position, since the FFN and LayerNorm apply the same function to each position separately; only attention moves information across tokens.

Explanation Transformers

A Transformer block has two sublayers with distinct jobs:

ComponentMixes across positions?What it does
Self-attentionyeseach token takes a weighted average of the value vectors of all tokens in the sequence: the only cross-token step
Position-wise FFNnothe same two-layer MLP applied to each token vector independently
LayerNormnonormalizes each token vector over its own d features
Residual connectionnoadds a sublayer's output to the same position's input

The residual-stream view describes this neatly: every position carries a vector through the network. Attention layers read from other positions' streams and write into the current one, while FFN layers read and write only the current position's stream, transforming its features (often interpreted as key-value memories).

After deleting attention, the network is a per-token MLP: the output at position i is a function of token i's embedding plus position i's embedding, nothing else. (BERT's segment embedding, had it been kept, would just be one more per-position input.) The model can no longer represent that "not" flips the meaning of "good" in "not good", and the word "bank" gets the same vector in every sentence at a given position.

Why the distractors fail: the FFN's weight matrices act on the d-dimensional feature axis, not on the sequence axis, so it runs per position (hence "position-wise"). LayerNorm, unlike BatchNorm, normalizes over the features of one token. Residual connections add a position's own input to its own output, never to its neighbours'.

Interview tip: a crisp summary is "attention is communication between tokens, the FFN is computation within each token"; then explain how stacking blocks alternates the two.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. A grocery chain trains a CNN to grade bananas on a conveyor belt as unripe, ripe or overripe from camera images. Which augmentation is most likely to hurt the…
  2. In a deep MLP with sigmoid activations, the error signal reaching the first layer's weights has passed through ten sigmoid derivatives. Ignoring the weight…
  3. A teammate multiplies a recommender's training loss by 100 so the dashboard shows larger numbers. For one weight the gradient has been steady at g = 0.004 per…
  4. In neural network training, what is an epoch?
  5. What is the ReLU activation, and why is it a popular default for hidden layers?