InterviewStack.io LogoInterviewStack.io

Transformers and Attention Questions

The transformer architecture that underlies modern language and multimodal models. Covers self-attention and multi-head attention, positional encoding, encoder/decoder structures, and why transformers scale better than recurrent alternatives. Focuses on the architectural intuition behind contemporary foundation models.

MediumTechnical
36 practiced

Design positional encoding schemes for 2D image patches used in ViT. Compare flattened 1D positional embeddings, separable 2D embeddings (row and column), and learned 2D sin/cos embeddings. Discuss implications for translation invariance, ability to generalize to larger images, and parameter overhead.

HardSystem Design
60 practiced

Architect a training pipeline to train a 100B-parameter Transformer across multi-node GPU clusters. Cover data ingestion (sharding, streaming, deduplication), parallelism strategy (tensor + pipeline + data), optimizer state management (ZeRO), checkpointing, failure recovery, and cost/performance trade-offs. Explain choices to minimize wall-clock time while preserving numerical stability.

MediumTechnical
30 practiced

Provide a quantitative explanation for why the dot-product of random Q and K vectors grows with dimension and why dividing by sqrt(d_k) stabilizes gradients and softmax outputs. Include a short derivation assuming components of Q and K are independent with zero mean and variance 1/d_k.

HardTechnical
36 practiced

Provide a technical explanation for why multi-head attention often outperforms single-head attention with the same total dimensionality. Discuss representation subspaces, the ability to capture multiple relations in parallel, and propose empirical experiments you would run to validate the hypothesis.

HardSystem Design
37 practiced

Propose a design to shard a quantized 70B-parameter Transformer model across heterogeneous devices (multiple GPUs and CPU nodes) to serve high-throughput, low-latency requests. Address scheduling of requests, memory placement of shards, communication minimization, token-level latency optimization, and failover strategies.

Unlock Full Question Bank

Get access to all Transformers and Attention interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.