mlprep
Hard12 min·1 round·Sequence Modeling

Explain attention mechanisms beyond transformers — types and trade-offs

Written by the mlprep team · Updated

Interviewer Mode
Interviewer

You mentioned transformers use self-attention. Walk me through the different types of attention — self vs cross attention, multi-head, and the scaling problem. What does "attention is O(n²)" actually mean in practice?

Ready to compare your reasoning?

The key takeaway unlocks after you reveal an expert answer.

Follow-up Questions to Test Yourself

Interviewers often pivot here once you cover the core concept.

  • How does Flash Attention achieve the same result as standard attention while using O(n) memory instead of O(n²)?
  • What is rotary position encoding (RoPE) and why did it replace learned or sinusoidal position encodings?
  • When would you use an encoder-only model (BERT) vs a decoder-only model (GPT) vs an encoder-decoder (T5)?

How confident do you feel explaining this?

Track your understanding or flag it to revisit before your next loop.

Related Questions