attention
AI, ML & GenAI interview questions tagged attention, across every topic.
15 questions · 5 unlocked for you
Concepts behind "attention"
The curriculum that explains the ideas these questions test.
Foundational
From RNNs to Transformers: RNN, LSTM, Seq2SeqRecurrent networks walk through a sequence one position at a time via a hidden state, an approach that is principled but slow and weak on long-range dependencies because gradients shrink across many steps. Gates in LSTMs and GRUs carry information further, and seq2seq encoder-decoder models with attention broke the single-vector bottleneck, the idea transformers later pushed all the way. AI, ML, and GenAI engineer interviews probe this because it explains where attention came from and why the field traded recurrence for parallelism.🧠 Foundations of LLMs & GenAI
Foundational
The Context WindowThe context window is the largest number of tokens a model can attend to at once, prompt plus generation. It is capped by attention's quadratic cost, the KV cache's linear memory growth, and the length the model trained on. A bigger window is neither free nor uniformly useful (models lose information in the middle), which is why retrieval often beats cramming everything into context. AI, ML, and GenAI engineer interviews probe it because it drives cost, latency, and the RAG-vs-long-context decision.🧠 Foundations of LLMs & GenAI
Core
The Transformer ArchitectureThe transformer is the architecture behind modern LLMs: stacked blocks that each mix information across tokens with self-attention and then transform each token with a feed-forward network, wrapped in residual connections and normalization. Grasping the two sub-layers (attention mixes across tokens, the feed-forward processes each one) explains where parameters live, why Mixture-of-Experts scales the feed-forward, and why decoder-only models dominate. AI, ML, and GenAI engineer interviews probe it because it is the mental scaffold for everything else, attention cost, KV cache, MoE, and serving.🧠 Foundations of LLMs & GenAISign in
Core
Attention and Self-AttentionAttention casts each token as a query, key, and value, scores every query against every key, softmaxes those scores into weights, and returns the weighted sum of values, so each token draws information from the others. Self-attention does this within one sequence. The all-pairs scoring is why cost grows with the square of sequence length, which then explains context limits, long-prompt expense, and the KV cache. AI, ML, and GenAI engineer interviews probe it because it ties architecture to cost and latency in one mental model.🧠 Foundations of LLMs & GenAISign in
Core
Causal Masking and Teacher ForcingA causal mask adds a triangular block of large negative values to the attention scores before the softmax, so every position gets exactly zero attention weight on the future. That one trick lets you push a whole sequence through in a single forward pass and compute a loss at every position at once, which is teacher forcing, and it is the reason transformer training parallelizes while RNN training could not. AI, ML, and GenAI engineer interviews probe it because it explains the deepest asymmetry in LLMs: training is parallel over positions and generation is irreducibly serial, which is exactly why the KV cache exists.🧠 Foundations of LLMs & GenAISign in
Core
FlashAttention and IO-Aware KernelsNaive attention is slow not because of the matmuls but because it writes the full N-by-N attention matrix out to GPU high-bandwidth memory and reads it back, making it memory-bandwidth bound. FlashAttention merges the entire attention computation into one kernel that tiles the inputs in fast on-chip SRAM and never materializes the full matrix, relying on an online-softmax trick to remain exact. AI, ML, and GenAI engineer interviews probe it because it is what made long-context training and serving affordable and a clean test of GPU memory-hierarchy reasoning.🖥️ ML Infrastructure & ServingSign in
