Attention interview question

Deep LearningAttentionbasic

What is the core idea of an attention mechanism in a neural network?

  1. AIt drops a random subset of the input tokens during training, so the model learns to rely on the tokens that remain.
  2. BIt compresses the whole input into one fixed-length vector that the output step reads, with no access to single inputs.
  3. CFor each output, it takes a weighted average of the input representations, weighting each input by its relevance.
  4. DIt learns one fixed importance weight per input position and reuses those same weights unchanged for every sequence.
Show the answer and explanation

Correct answer: C, For each output, it takes a weighted average of the input representations, weighting each input by its relevance.

Explanation Attention

Attention lets the model decide, for each output, which inputs to look at. It scores every input representation for relevance to the current query, turns the scores into weights with a softmax (so they are positive and sum to 1), and returns the weighted average of the inputs. The weights are recomputed from the content of every new input.

Why the other ideas are wrong:

  • Compressing the input into one fixed-length vector is the bottleneck of early RNN encoder–decoders; attention was introduced (Bahdanau et al., 2014, for translation) precisely to remove it.
  • Fixed per-position weights ignore content; attention weights depend on the actual tokens, so they change from sentence to sentence.
  • Randomly dropping inputs is a regularization trick in the spirit of dropout, not attention.

Interview tip: say "a learned, content-dependent weighted average" and mention that the weights also give a rough view of what the model focused on.

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. Which statement best defines transfer learning?
  2. Two system outputs are scored against a single reference in the table. Which interpretation of the scores is correct?
  3. A telecom's search-box autocomplete uses a bigram language model with add-one (Laplace) smoothing, P(w prev) = (c(prev, w) + 1) / (c(prev) + V). The table…
  4. The table shows how two tokenizers split the same text. What do the ## and Ġ markers mean?
  5. A retailer wants to cut the mobile-app download size of a product-image classifier (dense top-1 76.1%) by pruning it and shipping the weights in a compressed…