LLM & Transformer Fundamentals
This is the single most heavily tested topic in AI Engineer interviews: every frontier lab, big-tech AI team, and serious startup will probe whether you actually understand what happens inside the model you're building on, or whether you're just calling an API. Expect these questions at every level - screens use them to filter, onsites use them to calibrate depth, and system-design rounds assume this material as vocabulary.
Card 1 of 17
The decoder-only transformer, top to bottom
Modern LLMs (GPT, Claude, Llama, Gemini, DeepSeek, Qwen) are decoder-only transformers: a token embedding layer, a stack of N decoder blocks, a final norm, and an LM head (linear projection to vocab logits, weight-tied to the embedding matrix in many small models, untied in most large ones). Each block does two things - mix information across positions (attention) and transform information at each position (MLP) - with residual connections around both:
flowchart TD
X["hidden states from previous block (n_tokens × d_model)"] --> N1["RMSNorm"]
N1 --> ATT["masked multi-head self-attention<br/>Q/K/V projections + RoPE, softmax(QKᵀ/√d_k)V, output proj"]
ATT --> A1(("+"))
X -->|"residual"| A1
A1 --> N2["RMSNorm"]
N2 --> MLP["MLP (SwiGLU FFN)<br/>gate and up-project to ~2.7-3.5× d_model, down-project"]
MLP --> A2(("+"))
A1 -->|"residual"| A2
A2 --> OUT["to next block"]
Key design points interviewers probe:
- Pre-norm vs post-norm. The 2017 original applied LayerNorm after the residual add (post-norm); it trains poorly at depth without careful warmup because gradients must pass through every norm. Modern LLMs use pre-norm (norm inside the residual branch, before the sublayer): the residual stream is a clean identity path, gradients flow unimpeded, training is stable at 100+ layers.
- RMSNorm (used in Llama-family and most modern models) drops LayerNorm's mean-centring and bias - just rescale by the root-mean-square. Cheaper, equally effective.
- The residual stream is the model's workspace: attention and MLPs read from it, write updates into it. This framing (from interpretability work) makes many architecture questions easy to reason about.
All 109 LLM & Transformer Fundamentals questions
Basic
- Why did transformers replace RNNs and LSTMs for language modeling?
- Walk me through what happens inside a single transformer decoder block.
- Explain self-attention step by step. What exactly are Q, K, and V?
- Why does scaled dot-product attention divide by √d_k?
- What is causal masking, why is it needed, and how is it implemented?
- Why does the transformer use multiple attention heads instead of one large one?
- Compare encoder-only, decoder-only, and encoder-decoder architectures. What is each used for?
- What's the difference between causal language modeling and masked language modeling as pretraining objectives?
- Why do LLMs use subword tokenization instead of whole words or raw characters?
- Why do LLMs famously miscount the number of r's in "strawberry"?
- What does the temperature parameter actually do? Give the formula.
- Compare greedy decoding, top-k sampling, and top-p (nucleus) sampling.
- What is the KV cache and why does it make generation fast?
- What does the feed-forward network in a transformer block actually do, and why is SwiGLU the default now?
- What is weight tying, and why do some models tie the embedding and output matrices while others do not?
- Explain speculative decoding. Why doesn't it change the model's output distribution?
- What is in-context learning, and how do you decide between it and fine-tuning?
- What does perplexity measure, and why can't you compare it across models with different tokenizers?
Intermediate
- Pre-norm vs post-norm - what's the difference and why did everyone move to pre-norm? And why RMSNorm?
- Walk me through the BPE training algorithm step by step.
- Compare BPE, WordPiece, SentencePiece, and byte-level BPE.
- What are the tradeoffs in choosing vocabulary size?
- Beyond letter counting, what failure modes does tokenization cause? Think arithmetic, multilingual text, and code.
- Attention is O(n²) in sequence length. Where does that actually bite in practice - prefill vs decode?
- Explain FlashAttention's core idea. What does it optimise, and what doesn't it change?
- How do sinusoidal positional encodings work, and how do they compare to learned positional embeddings?
- Explain RoPE. What's the rotation intuition and why did it become the default?
- How does ALiBi encode position, and what's its claim to fame?
- A model was pretrained at 8k context. You need 128k. What are your options? Explain position interpolation and YaRN.
- What are MQA and GQA, and why do they exist?
- Derive the KV cache memory formula and compute it for a concrete model.
- Explain min-p sampling and repetition/frequency penalties. When do standard sampling settings fail?
- What are logprobs, and what are they useful for in production systems?
- Describe the modern LLM training pipeline: pretraining → mid-training → SFT → RL.
- What is an attention sink, why does it exist, and what breaks if you evict it from the KV cache?
- Explain sliding-window attention and hybrid local/global stacks. What do you gain and what do you give up?
- What is Multi-head Latent Attention, and how is it actually different from GQA?
- Why is quantizing activations harder than quantizing weights, and how does that shape architecture choices?
- A vendor advertises 1M context with 100% needle-in-a-haystack. What has that actually proven, and how would you evaluate long context properly?
- What is multi-token prediction as a training objective, and what does it buy you?
- Mamba and state-space models were supposed to replace transformers. What actually happened, and why?
- Reasoning models expose a thinking budget or reasoning effort setting. How do you tune it, and what goes wrong?
- What is the reversal curse, and what does it reveal about how LLMs store knowledge?
- You are migrating to a model whose tokenizer produces about 30% more tokens for the same text. What breaks, and how do you find out before your users do?
- The newest closed frontier models reject or ignore temperature and top_p. How do you get diversity, determinism and reproducible evals without them?
Advanced
- What is "lost in the middle," and why doesn't a long context window equal reliable retrieval?
- Compare Kaplan and Chinchilla scaling laws. What did Chinchilla change?
- Why do modern models train far past Chinchilla-optimal?
- What are "emergent abilities," and what is the mirage critique? Where does that debate land practically?
- Explain Mixture-of-Experts: the router, top-k experts, total vs active parameters. Why does it win?
- What goes wrong when training MoE models, and what's the inference memory caveat?
- What are the root causes of hallucination, and what actually mitigates it?
- What are reasoning models, and how does test-time compute change the picture? When would you use one versus a standard model?
- What is distillation, and how is it used in the LLM ecosystem?
- Beam search is standard in machine translation. Why is it rarely used for open-ended LLM generation?
- Where do the parameters and FLOPs actually live in a transformer? Walk me through the budget.
- Open-weights vs closed-weights models: how do you think about the tradeoff as an engineer in 2026?
- Walk me through training a reasoning model with RLVR. Why GRPO instead of PPO, and what breaks in practice?
- There's a line of work claiming in-context learning is implicit gradient descent. What's the claim, what's the evidence, and does it change what you do?
- What is grokking, and does it have any bearing on how you actually train models?
- When does model merging work, and what's actually going on underneath?
- A stakeholder wants to "just edit the fact into the model's weights" instead of maintaining a RAG pipeline. Talk me through it.
- What's the case for tokenizer-free models, and why hasn't the tokenizer died yet?
- Your team extended a model from 32k to 256k with YaRN plus a short fine-tune. Long-context evals improved, but users say it got worse on ordinary short prompts and it's noticeably more verbose. Debug it.
- What is superposition, and what have sparse autoencoders actually shown about what a model represents?
- How do diffusion language models generate text, and why haven't they displaced autoregressive models?
- Linear attention was written off for years. What do gated delta-rule layers like Gated DeltaNet change, and why are they showing up in hybrid models?
- Mistral Large 4 and the largest Qwen3.8 model ship open weights under custom licences that restrict model-as-a-service use, while their smaller siblings are Apache 2.0. Can you serve them inside your paid API product, and how does that change your open-versus-closed decision?
Quick-fire
- What is a token, and why does tokenization matter in practice?
- What is the context window, and what happens as you fill it?
- What do temperature and top-p control, and how do you set them?
- Why do LLMs hallucinate, and can you eliminate it?
- What is an embedding, and how is it used?
- At a high level, how does a transformer work, and what is self-attention doing?
- What is the difference between a base model, an instruction-tuned model, and a reasoning model?
- What is the difference between an LLM's parametric knowledge and non-parametric knowledge?
- What is a mixture-of-experts (MoE) model and why does it matter for AI Engineers?
- What is the KV cache, and why is it the reason generation gets faster after the first token?
- Why are LLMs bad at arithmetic and character-level tasks, and what do you do about it?
- How do you get a confidence or uncertainty signal out of an LLM?
- What is a training cutoff, and how does it shape product decisions?
- Are two identical calls to an LLM guaranteed to return the same output? Why does this matter?
- How does a multimodal (vision-language) model process an image, and what should you watch for?
- What is distillation, and why might you use a distilled model?
- How do reasoning models differ from standard LLMs, and how does that change how you prompt them?
- When should you use a reasoning model versus a standard model?
- What are the practical downsides of reasoning models in production?
- What is a thinking budget, and how do you tune it?
- What is overthinking or inverse scaling in test-time compute?
- What is interleaved thinking across tool calls?
- Can you trust a reasoning model's visible chain of thought as an explanation?
- What is self-consistency, and how does it relate to reasoning models?
- Discuss the concept of transfer learning in the context of natural language processing. How do pre-trained language models contribute to various NLP tasks?
- Highlight the key differences between models like GPT (Generative Pre-trained Transformer) and BERT (Bidirectional Encoder Representations from Transformers)?
- What problems of RNNs do transformer models solve?
- Why is incorporating relative positional information crucial in transformer models? Discuss scenarios where relative position encoding is particularly beneficial.
- What challenges arise from the fixed and limited attention span in the vanilla Transformer model? How does this limitation affect the model's ability to capture long-term dependencies?
- Why is naively increasing context length not a straightforward solution for handling longer context in transformer models? What computational and memory challenges does it pose?
- How does self-attention work?
- What pre-training mechanisms are used for LLMs, explain a few
- Why is a multi-head attention needed?
- What is RLHF, how is it used?
- What is catastrophic forgetting in the context of LLMs
- In a transformer-based sequence-to-sequence model, what are the primary functions of the encoder and decoder? How does information flow between them during both training and inference?
- Why is positional encoding crucial in transformer models, and what issue does it address in the context of self-attention operations?
- When applying transfer learning to fine-tune a pre-trained transformer for a specific NLP task, what strategies can be employed to ensure effective knowledge transfer, especially when dealing with domain-specific data?
- Discuss the role of cross-attention in transformer-based encoder-decoder models. How does it facilitate the generation of output sequences based on information from the input sequence?
- Compare and contrast the impact of using sparse (e.g., cross-entropy) and dense (e.g., mean squared error) loss functions in training language models.
- How can reinforcement learning be integrated into the training of large language models, and what challenges might arise in selecting suitable loss functions for RL-based approaches?