Self-attention in depth: cost, variants and making it cheap
HardConcept30 minMLEPro outline
The question
Walk me through self-attention in a transformer. What is its compute and memory cost in sequence length?
For a model that must run on a phone, which attention variants or tricks would you consider, and what do they trade away?
What the interviewer is looking for
- Explains Q, K, V and the attention formula with shapes
- Knows cost is quadratic in sequence length for scores, linear for the KV cache
- Knows multi-query and grouped-query attention reduce KV memory
- Mentions windowed attention, quantization and fused kernels
- Explains trade-offs in quality and complexity
Your answer
Saved in this browser only. Nobody else sees it.
Why this question
Written by BlogLLM in the style of a publicly reported Apple (Machine Learning / AIML) question type: ML depth: bias-variance, regularization, loss choices, transformers and self-attention, fine-tuning vs retrieval, evaluation tied to product goals.
Reported in: spacecomplexity.ai
Practice question written by BlogLLM based on publicly reported interview formats. Not an official Apple (Machine Learning / AIML) question.