CrackML by @ml.with.umang
Interview questions / GenAI & LLM
GenAI & LLM interview question

QKV in Multi-Head Attention

Explain why attention uses learned Q, K, and V projections and why multiple heads help.

mediumconceptEvidence 34/1001 source reportTikTok

The 60-second answer

Learned Q and K project tokens into a matching space; V projects the content that is aggregated after matching. Scores come from QKᵀ/√d_k, masks alter allowed interactions, and softmax converts scores into mixing weights over V.

Build the answer in this order

1
Define the mechanism

Learned Q and K project tokens into a matching space; V projects the content that is aggregated after matching.

2
Explain the architecture

Scores come from QKᵀ/√d_k, masks alter allowed interactions, and softmax converts scores into mixing weights over V.

3
Compare trade-offs

Multiple heads use separate projections so different relational patterns can be modeled in parallel before concatenation/output projection.

4
Close with serving + evaluation

Track shapes carefully and explain that heads split representational width; they do not each see an independent copy of full hidden dimension by default.

A useful interview mental model

This is the shape of a strong answer—not a script to memorize.

01Definition
02Mechanism
03Trade-offs
04Failure modes
05When to use

Senior-level signal

  • Senior answers discuss grouped-query/multi-query attention as serving optimizations that reduce KV-cache memory.
  • Connect head dimension and scaling to numerical stability and hardware layout.

What the interviewer is really testing

Understanding beyond prompting: architecture, retrieval, evaluation, inference, safety, latency, cost, and failure recovery.

Likely follow-up questions

What assumption makes this approach work?
When would you choose the strongest alternative instead?
What production or data failure mode changes your answer?

Common weak-answer patterns

  • Reciting a definition without mechanism or assumptions.
  • Claiming one technique is always better without a data regime.
  • Stopping before failure modes, validation, or deployment implications.