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.

EasyTechnical
35 practiced

Discuss the roles of residual connections and layer normalization in Transformer blocks. Explain how residuals aid optimization, what problems layer norm addresses, and briefly contrast pre-norm vs post-norm placement and their effects on stability for deep stacks.

HardSystem Design
31 practiced

Design an attention pattern and algorithm for a 1,000,000 token context that combines local windows, global tokens, and compressed memories to achieve sub-quadratic complexity. Provide the structure, per-token complexity, memory requirements, update rules for compressed memory, and a short analysis of representational trade-offs.

MediumTechnical
37 practiced

You're adapting a pretrained Transformer encoder for document classification, and input lengths range from a couple of sentences to several thousand tokens. How would you turn the per-token representations into a single vector for the classifier, and what would push you toward one pooling strategy over another as the length variance grows and the input gets noisier?

EasyTechnical
29 practiced

You need to fine-tune a pre-trained Transformer on a small labeled dataset (~1k examples). Describe practical strategies to avoid overfitting: layer freezing, adapters/LoRA, learning rates, augmentation, early stopping, and evaluation strategies. Which would you try first and why?

MediumTechnical
41 practiced

Compare locality-sensitive hashing (LSH) attention (e.g., Reformer) with sparse attention patterns and windowed-local attention. Discuss how each reduces memory and compute, their complexities for long sequences, weaknesses (collisions, missing long-range connections), and hardware friendliness.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.