LLM interview questions and answers
Questions on how language models work inside and how they're trained and served: attention, tokenization, GPT architecture, fine-tuning, RLHF, quantization and inference.
1. Explain attention to a marketing colleague without math.
Picture every word in a text asking, 'which other words here help me understand what I mean?' It looks at all of them, gives more weight to the relevant ones and blends in their information, so 'dry' next to 'waterproof jacket' ends up meaning something about rain gear. Every word does this at the same time, and it can reach anywhere in the text, which is how a model keeps track of what refers to what, like an instruction at the top of a long brief.
2. Explain why training on 'just predict the next token' can produce a model that knows facts and writes coherently.
To predict the next token of real text well, a model has to know everything that makes text predictable: how words are spelled, how sentences are built, what the topic is, how a style continues, and facts, because 'The capital of France is' is only easy to finish if you know the answer. Training rewards anything that lowers the loss, so with enough data and parameters the model ends up encoding all of that. The objective is simple; what it takes to do it well is not.
3. Explain why 'the dog bit the man' and 'the man bit the dog' would look identical to a transformer without positional encodings.
Attention compares token vectors with each other, and nothing in that computation says where a token is: if you shuffle the inputs, you just get the same outputs shuffled. Both sentences contain exactly the same words, so 'dog' and 'man' would end up with the same contextual vectors in each, and the model couldn't tell who bit whom. Adding position embeddings, or rotating queries and keys by position as RoPE does, makes each vector depend on where its token sits.
4. A stakeholder says: 'Let's fine-tune a model on our 300-page product manual so it knows our products.' What would you recommend instead, and why?
I'd build retrieval over the manual first: split it into sections, find the relevant ones for each question, and have the model answer from them with references. That gives accurate answers that update the moment the manual changes, with sources we can check. Fine-tuning on the manual would teach the model to sound like it knows our products, but it learns facts unreliably, makes confident mistakes, and would need retraining after every manual update. If we later want answers in a particular format or tone, a small fine-tune on top can help, but only after an evaluation shows retrieval and prompting aren't enough.
5. A client asks why translating the same product catalog into another language increased their LLM costs. Explain using tokenization.
LLMs are billed per token, and tokens come from a tokenizer trained mostly on certain kinds of text, often English-heavy. Words in languages that were less common in that data don't get their own tokens, so they're split into more and smaller pieces, sometimes down to individual bytes. The same catalog therefore turns into more tokens, which costs more and fills the context window faster. I'd measure token counts per language with the provider's token counter and compare models, since tokenizers differ.
6. Explain what would happen if you trained a GPT-style model without the causal mask, then used it to generate text.
In training, every position would be able to see the very token it's supposed to predict, so the model would learn to copy it from one step ahead, and the training loss would look fantastic. At generation time there's nothing ahead to copy, because the future hasn't been written yet, so the model would fall apart. The causal mask makes training match generation: each prediction uses only what comes before it.
7. Explain, step by step, what happens inside a GPT between receiving the prompt 'Our new rain jacket is' and producing the next token.
First the prompt is split into tokens and each token ID is turned into a vector from the embedding table, with position information added. Those vectors go through the stack of blocks: in each one, attention lets every token pull in information from the tokens before it, and the MLP processes each token's vector, all wrapped in residual connections and layer norms. After the last block, the final norm and output layer turn the vector at the last position, which has now absorbed the whole prompt, into a score for every token in the vocabulary. A softmax and the sampling settings pick one, say ' light', which is appended, and the whole process runs again for the next token.
8. Explain multi-head attention with an analogy, then say where the analogy breaks down.
It's like having several analysts read the same document, each looking for a different kind of connection: one tracks what came just before, another which product is being discussed, another what 'it' refers to. Their notes are then pooled into one summary (concatenation plus the output projection). Where it breaks down: nobody assigns the heads their jobs, they emerge from training and are often messy or overlapping, and each 'analyst' is just a small slice of the same vector with its own projections, not a separate mind.
9. Explain what goes wrong if you remove the √d_k scaling from a model with large attention heads.
Without scaling, the scores are dot products of long vectors, so their size grows with the head dimension: with 128-dimensional heads they're easily ±20. A softmax over numbers that far apart puts almost all the weight on a single token, and in that saturated regime its gradients are close to zero, so the attention weights stop learning. Dividing by √d_k keeps the scores around unit size, so the softmax stays soft and trainable.
10. Explain how attention resembles the retrieval step in RAG, and one way it differs.
Both start with a query, compare it against keys, and return content from the best matches, just like searching a vector index for relevant documents. The differences: attention doesn't pick the top few, it blends all the values weighted by how well they matched; the query, key and value vectors are learned projections tuned by training rather than fixed embeddings; and it happens inside the model, for every token in every layer, over the text already in context rather than an external database.
11. Describe the roles of attention and the MLP in a transformer block, using the 'communicate, then compute' idea.
In each block, attention is the 'communicate' step: every token looks back at earlier tokens and pulls in information from the relevant ones. The MLP is the 'compute' step: each token, on its own, runs what it has gathered through a two-layer network, which holds most of the block's parameters and much of what the model has memorized. Both results are added back onto the token's running vector, and stacking dozens of blocks repeats that gather-then-process cycle.
12. A colleague wants 'more creative' ad copy from an open model and plans to set temperature to 2.0. Explain the risk and a better approach.
At temperature 2 the distribution is so flat that unlikely tokens, typos, odd words, off-brand claims, get picked often, and the copy can derail mid-sentence. I'd keep temperature around 0.8–1.0 with top-p around 0.9 to cut the junk tail, and get creativity from the prompt instead: ask for distinct angles, give examples and constraints. Then generate several candidates and pick the best with a quick review or an LLM judge.
13. Your team's chatbot gets slower and more expensive as conversations get longer. Explain why, and suggest two ways to reduce the cost.
Every turn sends the whole conversation back to the model, so each request has more input tokens to prefill: more billed input and a longer wait for the first token. The KV cache for that conversation also keeps growing, using more GPU memory and making each new token attend over more history. To cut cost, cache the stable start of the prompt, such as the system prompt and earlier turns, so the provider reuses its KV cache and bills those tokens at the cached rate; and trim or summarize older turns instead of sending them in full forever.
14. A colleague says: 'The new model has a 1-million-token window, so we can drop our retrieval system and paste in everything.' Respond.
A million-token window is great for tasks that need whole documents at once, and it can simplify our pipeline when the material fits. But we'd pay for every one of those tokens on every request and wait longer for each answer, unless the same prefix repeats and can be cached. Models also don't use huge contexts perfectly: facts in the middle get missed more often and combining many scattered facts is harder than finding one. And our full knowledge base is larger than a million tokens anyway. I'd test both on our real questions, and likely keep retrieval but give it a bigger budget, retrieving more passages into the long context.
15. A colleague says: 'The system prompt is a set of rules the model is forced to obey.' Correct them, using what you know about chat templates.
The system prompt is just text placed at the start of the conversation in a marked turn; the model reads it the same way it reads everything else. It carries weight because post-training taught the model to prioritize system instructions, so it usually works, but nothing forces compliance: a long conversation, conflicting instructions or injected text can still override it. So we should test the rules that matter, and enforce the critical ones in our own code instead of trusting the prompt as a guarantee.
16. Your team fine-tuned a model on 2,000 support chats. It now answers in your format perfectly, but sometimes states return policies that are wrong. Explain why, and what you'd do.
Fine-tuning taught the model what our answers look like, the format and tone, but not a reliable memory of every policy detail: it learned from 2,000 examples to sound like a support agent, and where it doesn't know a policy it produces something plausible in the same style. The fix is to give it the real policy at answer time by retrieving the relevant policy text into the prompt, and to train or instruct it to answer from that text. Then we'd test on held-out policy questions and check answers against the documents.
17. Explain RLHF to a product manager in a few sentences: its three stages, and one risk they should know about.
First the model is taught by example, trained on good conversations people wrote. Then people compare pairs of its answers, and a second model, the reward model, learns to predict which one they'd prefer. Finally the chatbot practices: it writes answers, the reward model scores them, and the chatbot is adjusted toward higher scores, with a penalty that stops it from straying too far from how it started. The main risk is that the reward model is only an imitation of human judgment, so pushed too hard the chatbot learns to please the scorer rather than people, for example by becoming wordy or flattering.
18. Your team has 2,000 pairs of 'better' and 'worse' support replies. Explain how DPO would use them, and one thing that could go wrong.
We'd take our current support model as the starting point and keep a frozen copy as the reference. For each pair, we compute how likely both models find the better and the worse reply, and train the model to raise the better reply's likelihood and lower the worse one's, relative to the reference, with β limiting how far it moves. It trains like ordinary fine-tuning, with no reward model and no generation during training. The risk is that it learns whatever most easily separates the pairs, such as longer replies or a stock phrase, rather than real helpfulness, and pushed too hard it can get worse at other things. So we'd evaluate on held-out tickets across every criterion and tune β and training length.
19. An agency wants a fine-tuned writing model for each of its 40 clients. Explain how LoRA makes this practical compared with full fine-tuning.
With full fine-tuning, each client would get a complete copy of the model, 16 GB apiece for an 8-billion-parameter model, trained on large GPUs and served separately: forty models to host. With LoRA, everyone shares one frozen base model, and each client gets a small adapter trained on their examples, measured in megabytes and quick to train on a single GPU. At serving time we run one base model and attach the right client's adapter to each request. For narrow jobs like matching a voice, adapters usually come close to full fine-tuning, and we'd still check each client's quality on their own examples.
20. Your team wants to run an open 8B model in 4-bit on staff laptops to summarize sales calls. What would you check before rolling it out?
First, fit: the 4-bit weights are about 5 GB, which leaves room on a 16 GB laptop, but long call transcripts need KV cache too, so I'd test the longest calls we expect and measure tokens per second on the actual laptops. Second, quality: I'd run the same 50 real calls through the 4-bit model and through a 16-bit or hosted reference, and compare the summaries, especially names, numbers and action items, since quantization can damage specific skills while overall quality looks fine. Finally I'd confirm the model's license allows our use and that the local setup keeps call data on the laptop, which is a privacy plus.
21. Your team prototyped product descriptions with a frontier model and loves the quality, but generating 2 million a year is too expensive. Describe a distillation plan and its risks.
First I'd confirm the provider's terms allow using its outputs to train our own model for this purpose. Then I'd have the big model write a few thousand descriptions for a representative set of products, have editors approve or fix them, and fine-tune a small model on the approved examples, feeding it the product data each time so facts come from our catalog, not from memory. Before switching, we'd compare the small model's output with the big model's on products held out from training. The risks are that the student copies the teacher's mistakes, can't beat it, may handle unusual products badly, and needs regular re-checking as the catalog changes.
22. Your team self-hosts an open model for an internal assistant. Users complain it's slow at 9am but fine later. Explain what's probably happening and two fixes.
At 9am everyone arrives at once. Requests queue up, and the server packs them into bigger batches, so each user's tokens stream more slowly and the first token takes longer; if the KV cache memory runs out, new requests simply wait. I'd first make sure we use a serving engine with continuous batching and paged KV caches, such as vLLM, and then add a second replica that scales up for the morning peak. Quantizing the model would also free memory for more conversations and speed up each token.
23. Explain speculative decoding to a product manager, including why it doesn't change answers.
A small, fast model writes a few words ahead, and the big model checks all of them at once, which takes about as long as writing a single word. The big model keeps the words it agrees with, and at the first one it disagrees with, it substitutes its own choice. Because every word that ends up in the answer is one the big model approved or chose itself (and there's a mathematically exact version for when it samples), the answers are the same as without the trick, just two to three times faster on typical text.
24. Your CEO forwards a launch post: 'New model X beats model Y by 2 points on benchmark Z, switch everything to X.' What would you reply?
A 2-point lead might be noise: on a test of a few hundred questions, each score is uncertain by several points, so I'd want the question count, confidence intervals and whether both models were run the same way by someone independent. Even if the gap is real, benchmark Z may not resemble our work; it could be saturated or partly memorized. So before switching, I'd run both models on our own test set of real tasks, comparing quality, cost and speed, and switch only if X wins clearly there.
25. An agency reports: 'Our fine-tuned model scores 98% on our evaluation.' What questions would you ask before believing it?
I'd ask what the 98% was measured on: examples kept out of training and out of every decision like choosing the checkpoint, and split so they're genuinely new, such as products the model never saw. I'd ask how the score is computed and whether the judge was checked against human ratings. I'd ask for the baseline, because 98% means little if a well-prompted model already gets 95%. And I'd want to read a sample of outputs and see whether anything else, like tone or accuracy, got worse.
26. A colleague assumes that an MoE model with a 'marketing expert' inside will be better at marketing tasks if prompted to 'use your marketing expert'. Explain what's actually going on.
The 'experts' are just MLP blocks inside each layer, and a learned router picks a couple of them for every token at every layer based on the token's internal representation. Nobody assigns them topics, and when researchers looked at Mixtral's routing they found it followed things like syntax and token type more than subject areas. You can't call on an expert by asking for it; the prompt only changes which tokens flow through the model. MoE is about getting a big model's capacity at a smaller model's cost per token, so prompt for the marketing task itself.
27. Your team wants to classify 5 million customer emails into 12 topics every week. Compare using a small fine-tuned encoder with prompting a large decoder model.
A small fine-tuned encoder needs a few thousand labeled emails up front, but then classifies millions cheaply and quickly, with consistent results, and can run on modest hardware; changing the topics means relabeling and retraining. Prompting a large model needs no training data and adapts instantly to new topics, but at five million emails a week it's far slower and more expensive. A good path is to use the LLM to bootstrap labels and prototype, then train a small encoder on those labels for production, checking both against a hand-labeled sample.
28. Your CEO reads that 'AI keeps getting better because of scaling laws' and asks whether that means progress is guaranteed. Give a balanced answer.
Scaling laws are an observed pattern, not a law of nature: over many orders of magnitude, more parameters, data and compute have lowered loss along a predictable curve, and labs use that to plan big training runs. But each 10× buys a smaller gain while costing ten times more, high-quality data is limited, and a lower loss doesn't translate neatly into any particular skill. Progress also comes from other sources, like better data, better training after pretraining, and letting models think longer. So steady improvement is a reasonable expectation, but not a guarantee, and not in every capability at the same pace.