Skip to content
Projets

TensorTonic/llm-interview-questions

Voir sur GitHub

À propos

LLM and transformer interview questions with explanations and practice problems for each one

Apprentissage et éducation

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
+1
in 15 days
+3
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

LLM and Transformer Interview Questions

LLM and Transformer Interview Questions

Questions Stages License

This is a list of the transformer and large language model questions that come up most often in ML engineer and research interviews. It has 39 questions across four stages, from tokens and attention to serving, evaluation and system design.

Every question links to an explanation that covers the answer and to practice problems where you implement the idea in Python and check it against tests. Having built attention or a KV cache yourself is the most reliable way to answer follow-up questions about them.

The roadmap

Table of Contents

Who this is for

This list is for anyone preparing for an interview where transformers or LLMs are likely to come up.

  • If you are preparing for an ML engineer role, focus on stages 1 and 3, since attention, the KV cache and serving questions are the most common.
  • If you are interviewing for research or post-training roles, spend extra time on stage 2, where training dynamics and alignment methods are covered.
  • If you already work with LLMs, use the tables as a self-test and read the explanations only for the questions you cannot answer out loud.

You need basic Python and some familiarity with neural networks. The questions build on each other, so earlier stages make later answers easier.

How to use this roadmap

Read each question and try to answer it out loud in two minutes before opening the explanation. Interviewers usually follow up with a trade-off or a number, so check that your answer covers why the idea exists and what it costs.

After reading, solve one of the practice problems for that question. When you have finished a stage, the interview assessments let you test yourself under time pressure, including the LLM Internals, Training and Decoding Primitives and Post-Training and Alignment sets.

Stage 1: Transformer Foundations

Almost every LLM interview starts with how a transformer turns text into predictions. These questions cover tokens, positions, attention and the block that repeats through the whole model. Expect to explain each one from scratch and to say how modern models changed the original design.

Question Read Practice
What is tokenization, and how is a BPE tokenizer trained and applied? Tokenization in the Transformer Train a BPE Tokenizer From Scratch, Apply Ranked BPE Merges
Why do transformers need positional information, and how does RoPE encode it? RoPE: Rotary Position Embedding Explained RoPE: Rotary Query and Key Embeddings, Sinusoidal Positional Encoding
How does self-attention work, and why are the scores scaled by the square root of the key dimension? Attention in LLMs: Queries, Keys and Values Explained Named-Dimension Batched Attention Scores, Numerically Stable Softmax
What is the causal mask, and where in attention is it applied? Attention in LLMs: Queries, Keys and Values Explained Causal Masking for Attention
Why use multiple attention heads, and what do MQA and GQA change? Multi-head attention in the Transformer Causal Grouped-Query Attention
Walk through a decoder block. Where do the residual connections and normalization go? Encoder block in the Transformer Transformer Decoder Block
Why do transformers use LayerNorm instead of BatchNorm, and what does RMSNorm remove? Layer Normalization in the Transformer RMSNorm Forward Pass
What does the feed-forward layer do, and why does a SwiGLU block use a smaller hidden size? Feed-forward network in the Transformer Parameter-Matched SwiGLU Block
What is the difference between encoder-only, decoder-only and encoder-decoder models, and why did decoder-only win for LLMs? GPT Pretraining: How Next-Token Prediction Works
What is a Mixture of Experts model, and what goes wrong when you train one? Mixture of Experts (MoE) in LLMs Explained Top-k MoE Router with Load Statistics

Stage 2: Training and Alignment

Once the architecture is clear, interviewers move on to how the model is trained and how a base model becomes an assistant. These questions cover the pretraining objective, optimization, memory and scale, and the fine-tuning and preference methods used after pretraining.

Question Read Practice
What is the pretraining objective of a GPT-style model, and what does perplexity measure? GPT Pretraining: How Next-Token Prediction Works Cross-Entropy Loss, Perplexity Computation
What is the difference between Adam and AdamW, and why does it matter for LLMs? Which Optimizer to Use in Deep Learning AdamW (Decoupled Weight Decay)
Why do LLMs use learning-rate warmup, and what schedule follows it? Warmup + Linear Decay LR Schedule, Generate a Warmup-Stable-Decay Schedule
Your training loss suddenly spikes or turns into NaN. What do you check first? Training Loss Not Decreasing? Causes and Fixes Gradient Clipping (Global Norm)
What is mixed-precision training, and why is bf16 usually preferred over fp16? Mixed Precision Training: FP16 vs BF16 Mixed-Precision Training Memory Accountant
What do scaling laws say about how to split compute between model size and data? GPT Pretraining: How Next-Token Prediction Works Recover an IsoFLOP Compute-Optimal Frontier
How do data parallelism and ZeRO reduce the memory needed per GPU? Gradient Accumulation in LLM Training Account for ZeRO Memory by Stage, Synchronize Data-Parallel Gradients
How does LoRA work, and what does QLoRA add on top of it? LoRA in LLMs: Beginner's Guide to Fine-Tuning, QLoRA Explained: 4-Bit LLM Fine-Tuning
Walk through RLHF. How does DPO reach a similar goal without a separate reward model? RLHF Explained: Reward Models and PPO, DPO: Direct Preference Optimization Explained DPO Loss
What is GRPO, and why does it not need a value network? GRPO: Group Relative Policy Optimization Normalize GRPO Group Advantages

Stage 3: Inference and Serving

Serving questions are now common even for roles that do not focus on infrastructure, because cost and latency decide whether a model ships. These questions cover how tokens are generated, why decoding is slow, and the techniques that make it faster and cheaper.

Question Read Practice
How do temperature, top-k and top-p change the way the next token is sampled? Temperature, Top-k, and Top-p Sampling
What is the KV cache, and why does it speed up generation? KV Cache in LLMs: How It Makes Inference Fast Decode Attention with a KV Cache
How do you estimate the KV cache size for a given model and context length? KV Cache in LLMs: How It Makes Inference Fast Plan KV-Cache Capacity, Calculate KV Cache Memory for MHA, MQA, GQA, and MLA
How do prefill and decode differ, and why is decode limited by memory bandwidth? What Is Inference Engineering? How to Learn It Analyze Prefill and Decode with the Roofline Model
What is FlashAttention, and is its output exact? FlashAttention Explained: Tiling and Memory Blockwise Online Softmax
What is quantization, and does INT4 give a four times speedup over FP16? LLM Quantization Explained: INT8, INT4, GPTQ and AWQ Symmetric INT8 Quantization, Group-Wise INT4 Quantization
What problem does PagedAttention solve? PagedAttention Explained: KV Cache Blocks PagedAttention Block Allocation
What is the difference between static and continuous batching? LLM serving and RAG Simulate Continuous Decode Batching
How does speculative decoding work, and why does it give the same distribution as the target model? Speculative Decoding in LLMs Explained Perform Exact Speculative Sampling
Which metrics would you track for an LLM serving system? Latency, throughput, and cost Compute TTFT, TPOT, ITL, and Token Throughput

Stage 4: Evaluation, RAG and System Design

Later rounds ask whether you can judge a model and build a product around it. These questions cover evaluation, retrieval-augmented generation, the live coding round and open-ended design prompts.

Question Read Practice
How do you evaluate an LLM when there is no single correct answer? Evaluating generated answers Fit Elo Ratings from Pairwise Votes
How would you measure agreement between human or LLM judges? Machine Learning Evaluation Metrics Cohen's Kappa
What is benchmark contamination, and how would you detect it? Build Deterministic MinHash Signatures
What is RAG, and what happens between the user's question and the model's answer? Retrieval-Augmented Generation (RAG) Explained Text Chunking for RAG
What is the difference between dense and sparse retrieval, and when would you combine them? Retrieval-Augmented Generation (RAG) Explained BM25 Ranking
How do you evaluate a RAG system, and how do you tell a retrieval failure from a generation failure? LLM serving and RAG Precision and Recall at K
In a coding round, how would you implement multi-head attention from scratch? ML Coding Interview Questions: 20 to Implement Multi-Head Attention (MHA)
How would you design a support chatbot that answers from company documentation? ML System Design Interview Framework
How would you serve a large open model to thousands of concurrent users within a latency target? LLM serving and RAG Optimize Throughput and Cost Under a Latency SLO

What's next

To go deeper than single questions, the Build LLM from Scratch study plan walks through a full language model piece by piece, and the Inference Engineering plan covers serving in the same way. The LLM Internals pages have visual explanations of most topics above, and the Transformer research track rebuilds the original paper step by step.

If you want to build the model yourself instead of studying it one question at a time, the How to Build an LLM from Scratch guide walks through the stages in order, from tokens and embeddings to generation, and lists the mistakes people make when joining the pieces.

For a written walkthrough of how to prepare, the LLM Interview Questions guide explains how to answer the questions interviewers ask most often about large language models.

If you are interviewing for a research engineer role, the Research Engineer Interview Preparation guide explains how to prepare for those interviews, and the NLP Interview Questions guide covers the language processing questions that are often asked alongside the LLM ones.

If you are interviewing for an AI engineer role, the AI Engineer Interview Questions guide covers the questions asked about building applications on top of language models.

License

MIT

Explorer des projets similaires

Chargement…