Generative AI and LLM roles

LLM Interview Questions and Answers: Large Language Model Prep for Freshers and Experienced

Satvik ParamkushamUpdated October 5, 202628 questions19 min read

Quick answer

LLM interviews test how large language models work inside: transformer architecture, tokenization, training stages (pretraining, fine-tuning, RLHF), decoding, serving and evaluation. Freshers get concept questions; experienced candidates get questions on LoRA, quantization, KV cache and debugging. Prepare by revising the architecture, fine-tuning one small model and practising scenario answers out loud.

Table of Contents

LLM interview questions go one level deeper than general GenAI rounds. Interviewers no longer stop at "what is ChatGPT?". They ask why a model needs a KV cache, what changes when you quantize to 4-bit, or why your fine-tuned model got worse at maths.

This page has 28 LLM interview questions with model answers, from basic architecture to serving and scenario rounds. It assumes you already know the basics covered in our generative AI interview questions, so it skips the one-line definitions and goes into the mechanics.

A quick note, because people search for both: this page is about large language models in AI, not the LLM (Master of Laws) degree.

I have seen strong freshers lose marks by answering "how does an LLM work?" with buzzwords. Each answer below fits in about a minute: direct answer, mechanism, trade-off. Use the Save as PDF button above for an offline copy.

What do LLM interviews test?

LLM interviews test whether you understand what happens inside the model and whether you can make it cheaper, faster and more reliable in production.

Most loops, whether at a funded Bengaluru startup or an AI team inside a large IT services company, cover these areas:

AreaTypical questionsWho gets it most
ArchitectureDecoder-only transformers, attention, positional encoding, tokenizationFreshers and every first round
TrainingPretraining, SFT, RLHF, DPO, LoRA and QLoRAML engineer and research-leaning roles
Inference and servingDecoding strategies, KV cache, quantization, batchingExperienced and platform roles
EvaluationPerplexity, benchmarks, LLM-as-judge, custom test setsEveryone building products
ScenariosDebug a fine-tune, cut latency, support Indian languagesFinal technical rounds

Engineering roles usually add a Python round, such as calling a model API or writing a small evaluation loop.

How to prepare for an LLM interview in 2 weeks

The best preparation mixes architecture revision, one hands-on fine-tune and spoken practice.

  1. Days 1 to 3: architecture. Revise the transformer model and the attention mechanism. Draw a decoder block from memory: attention, feed-forward, residual connections, layer norm.
  2. Days 4 to 5: tokens and decoding. Read about tokens, then play with temperature and top-p on any model playground and note what changes.
  3. Days 6 to 9: fine-tune something small. Use LoRA on a small open model with a free cloud GPU notebook. Track memory use and before and after scores. This one exercise answers half the experienced-level questions.
  4. Days 10 to 11: serving and evaluation. Learn KV cache, quantization and batching, and build a 30-question test set for your fine-tuned model.
  5. Days 12 to 14: speak. Answer every question on this page out loud in about 60 seconds, then run the mock prompts below or use our AI interview practice guide.

Basic LLM interview questions for freshers

First-round questions. Interviewers want clear mechanics, not marketing words.

1. How does an LLM generate text?

Easy

An LLM generates text one token at a time by predicting a probability distribution over its vocabulary for the next token, picking one, appending it to the input and repeating, a process called autoregressive generation. The model has no plan for the full sentence in advance; each step depends only on the tokens so far. Generation stops at an end-of-sequence token or a length limit. For the bigger picture, see what an LLM is.

Interviewer tip: Saying "autoregressive" and explaining it in one line earns quick credibility.

2. What is a decoder-only transformer, and why do most LLMs use it?

Medium

A decoder-only transformer is a stack of transformer blocks with causal (masked) self-attention, so each token can only attend to earlier tokens. Encoder-only models like BERT see the whole input both ways and suit classification, while encoder-decoder models like T5 suit translation. Most chat LLMs use decoder-only because one simple next-token objective scales well on huge text corpora and handles every task as text generation. The trade-off: no bidirectional view of the input.

3. How does self-attention work? Explain query, key and value.

Medium

Self-attention lets each token build its representation by mixing information from other tokens, weighted by relevance. Each token is projected into a query (what I am looking for), a key (what I contain) and a value (what I pass on). Scores come from the dot product of a query with every key, scaled and passed through softmax, and the output is the weighted sum of values. Multi-head attention runs several of these in parallel to capture different relationships. More in attention mechanism in LLMs.

Interviewer tip: Expect the follow-up: why divide by the square root of the key dimension? It keeps softmax from saturating.

4. Why do LLMs need positional encoding?

Medium

Attention on its own treats the input as a set, so without position information "dog bites man" and "man bites dog" look the same. Positional encoding adds word-order information. The original transformer used fixed sinusoidal encodings, some models learn position embeddings, and many recent open models such as the Llama family use rotary position embeddings (RoPE), which encode relative position inside the attention calculation. RoPE also makes it easier to extend context length later.

5. What is tokenization, and how does byte pair encoding (BPE) work?

Easy

Tokenization splits text into the units a model reads, usually subwords. BPE starts from characters or bytes and repeatedly merges the most frequent adjacent pair into a new token until the vocabulary reaches a target size. Common words become single tokens while rare words split into pieces, so the model never meets a truly unknown word. The catch: tokenizers trained mostly on English often split Hindi or Tamil into many more tokens, which raises cost and uses up context faster.

6. What does 7B or 70B mean in a model name?

Easy

It is the number of parameters, the learned weights of the network: 7 billion or 70 billion. Parameter count drives memory needs. In 16-bit precision each parameter takes 2 bytes, so a 7B model needs roughly 14 GB just for weights, before the KV cache and activations. More parameters usually mean better capability but slower, costlier inference.

7. What is the difference between a base model and an instruction-tuned model?

Easy

A base model is the raw result of pretraining: it continues text in the style of its training data, so asking it a question may produce more questions instead of an answer. An instruction-tuned (or chat) model has been further trained on instruction and response examples, often plus preference tuning, so it follows requests and holds a conversation. Base models are useful starting points for your own fine-tuning; instruction models are what you deploy for assistants.

8. Why do LLMs hallucinate, technically?

Medium

LLMs hallucinate because they are trained to produce plausible next tokens, not verified facts, and nothing in plain next-token prediction rewards saying "I don't know". Rare facts are weakly stored in the weights, so the model fills gaps with fluent guesses. Sampling randomness, missing context and training data errors add to it. Grounding with retrieval, abstention instructions and output checks reduce it but never fully remove it. See AI hallucination.

LLM interview questions and answers: training, fine-tuning and decoding

These come up for ML engineer roles and for anyone who lists fine-tuning on their resume.

1. Explain pretraining, supervised fine-tuning (SFT) and RLHF.

Medium

Pretraining teaches a model language and world knowledge by predicting the next token over a very large text corpus; it is the most expensive stage. Supervised fine-tuning then trains on curated prompt and ideal-response pairs so the model learns to follow instructions. RLHF adds human preference: people rank outputs, a reward model learns those rankings, and the LLM is optimised towards higher reward. In the InstructGPT paper, labellers preferred outputs from a 1.3B tuned model over the 175B GPT-3.

2. What is DPO, and how is it different from RLHF?

Hard

DPO (Direct Preference Optimization) trains the model directly on pairs of preferred and rejected responses using a simple classification-style loss, with no separate reward model and no reinforcement learning loop. It still keeps a frozen reference model so the tuned model does not drift too far. Teams like it because it is simpler and more stable to run than PPO-based RLHF. The trade-off is that it learns only from the fixed preference pairs you give it, so data quality matters even more.

3. What is the difference between LoRA and QLoRA?

Medium

LoRA freezes the base model and trains small low-rank matrices added to selected weight layers, so only a tiny fraction of parameters is updated. QLoRA goes further: it loads the frozen base model in 4-bit precision and trains LoRA adapters on top, which cuts GPU memory sharply. The QLoRA paper showed a 65B model fine-tuned on a single 48 GB GPU. The trade-off is slower training steps and a small possible quality loss from quantization. See fine-tuning explained.

4. When should you fine-tune an LLM instead of prompting or using RAG?

Medium

Fine-tune when you need to change how the model behaves, not what it knows: a fixed output format, a domain style, a narrow classification task, or a smaller model that matches a bigger one on one job. Use prompting first because it is cheapest, and RAG when the model needs fresh or private facts. A good sign you need fine-tuning is a prompt that has grown to pages of rules and examples and still fails. For knowledge-heavy work, see our RAG interview questions.

Interviewer tip: Name the data you would need. "I have 2,000 labelled examples" is a better answer than "I would fine-tune".

5. What is catastrophic forgetting, and how do you limit it?

Medium

Catastrophic forgetting is when fine-tuning on a narrow task makes the model worse at things it used to do well, such as general reasoning or another language. It happens because updates for the new data overwrite useful weights. You limit it with parameter-efficient methods like LoRA, lower learning rates and fewer epochs, and by mixing some general instruction data into the training set. Always evaluate on a general benchmark before and after, not only on your task.

6. Explain greedy decoding, top-k and top-p sampling.

Medium

Greedy decoding always picks the single most likely next token, which is deterministic but can get repetitive. Top-k sampling keeps only the k most likely tokens and samples among them. Top-p (nucleus) sampling keeps the smallest set of tokens whose probabilities add up to p, say 0.9, so the candidate pool grows or shrinks with the model's confidence. Temperature reshapes the distribution before any of these. For code and extraction, use low randomness; for creative writing, allow more.

7. What is beam search, and why is it rarely used for chat?

Medium

Beam search keeps the best few partial sequences at each step and finally returns the one with the highest overall probability. It works well for tasks with one correct output, such as translation or speech recognition. For open-ended chat, the highest-probability text tends to be generic and repetitive, and beam search multiplies compute by the beam width. That is why chat systems usually use sampling with temperature and top-p instead.

LLM interview questions for experienced: inference, serving and evaluation

These separate people who have run models in production from people who have only called an API.

1. What is the KV cache, and why does it matter?

Hard

The KV cache stores the key and value vectors of all previous tokens at every layer, so each new token only computes attention for itself instead of reprocessing the whole sequence. Without it, generation would be far slower. The cost is memory: the cache grows with sequence length, number of layers and batch size, and for long contexts it can exceed the model weights. That is why serving tricks like grouped-query attention and paged memory management focus on shrinking or organising the KV cache.

2. What is quantization, and what do you lose?

Hard

Quantization stores model weights (and sometimes activations) in fewer bits, for example 8-bit or 4-bit integers instead of 16-bit floats. A 7B model drops from roughly 14 GB to around 4 GB at 4-bit, so it fits on a single consumer GPU and runs cheaper. You can lose some quality, usually small at 8-bit and more noticeable at aggressive 4-bit or lower, especially on maths, code and less common languages. Always re-run your evaluation set after quantizing.

3. How would you serve an LLM to thousands of concurrent users?

Hard

Use an inference server built for LLMs, such as vLLM or similar open-source options, rather than a plain web server around the model. Key techniques are continuous batching (adding new requests to the batch as others finish), paged KV cache memory, quantization and streaming tokens to users. Add autoscaling and rate limits. Measure time to first token and tokens per second separately, because users feel the first and your GPU bill feels the second.

Interviewer tip: Mention time to first token. Few candidates do, and interviewers notice.

4. What is perplexity, and why is it not enough to evaluate an LLM?

Medium

Perplexity measures how surprised a model is by real text: it is the exponential of the average negative log-likelihood per token, and lower is better. It is useful for comparing pretraining runs on the same tokenizer and data. It is not enough because it says nothing about whether answers are correct, safe, helpful or well formatted, and it cannot be compared across different tokenizers. A model can have low perplexity and still give wrong answers to your users.

5. How do you evaluate an LLM for a specific use case?

Hard

Public benchmarks such as MMLU or coding tests give a rough ranking, but they can be contaminated by training data and rarely match your task. So I build a custom test set of 50 to 200 real examples with expected answers or a grading rubric. Score with exact checks where possible (JSON validity, correct label), LLM-as-judge for open answers, and human review on a sample. Re-run it on every model or prompt change.

6. What is LLM-as-a-judge, and what are its pitfalls?

Hard

LLM-as-a-judge uses a strong model to grade another model's outputs against a rubric, which scales evaluation far beyond what humans can review. Known pitfalls include position bias (preferring the first answer in a pair), verbosity bias (preferring longer answers) and self-preference (favouring outputs from its own model family). Reduce them by swapping answer order, using specific rubrics with examples, asking for a score with a short reason, and checking the judge against human labels before trusting it.

7. Why is long context hard for LLMs?

Hard

Standard self-attention cost grows quadratically with sequence length, and the KV cache grows linearly, so long inputs are slow and memory-hungry. Models also need to be trained or adapted for long positions, often by scaling RoPE. Even when a model accepts very long input, research such as the "Lost in the Middle" paper found accuracy drops when key information sits in the middle of the context. So a long context window does not replace good retrieval.

8. What is speculative decoding?

Hard

Speculative decoding speeds up generation by letting a small, fast draft model propose several tokens, which the large model then verifies in a single forward pass. Accepted tokens are kept, and at the first rejection the large model supplies its own token and drafting starts again. With the standard acceptance rule, the output distribution matches the large model, so quality stays the same. The speed-up depends on how often the draft model guesses right, which is highest for predictable text such as code.

Scenario-based LLM interview questions

Answer with: clarify, diagnose, fix, then measure. Interviewers care about the order more than the tools.

1. Your fine-tuned model scores well on validation data but performs worse in production. What do you check?

Hard

First check for a distribution gap: are real user inputs longer, messier, in Hinglish, or about topics missing from training data? Next, check for leakage between training and validation sets, which inflates scores. Confirm the production prompt template exactly matches the training format, since a changed system prompt or chat template often breaks fine-tuned models. Finally, sample 100 production failures, label them, and add them to both the training and evaluation sets.

Interviewer tip: The chat template mismatch is the answer that shows real experience.

2. Your chatbot feels slow for users on mobile networks. How do you reduce latency?

Medium

Stream tokens so the first words appear quickly, then work on time to first token: shorter system prompts, prompt caching where the provider supports it, and fewer retrieved chunks. Reduce output length with explicit limits. Route simple queries to a smaller model and keep the large one for hard cases. On self-hosted setups, add quantization, continuous batching and a server region close to your users. Measure p95 latency, not the average, because the slowest users complain first.

3. Your product must answer in Hindi, Tamil and English. What LLM problems do you expect?

Hard

Expect higher token counts for Indic scripts with many tokenizers, which raises cost and fills the context window faster. Quality usually drops in lower-resource languages, and users mix scripts, writing Hindi in Roman letters. Evaluation is harder because few public benchmarks match your domain. I would build a small test set per language with native speakers, compare a few models on it, and consider models or tokenizers trained with more Indian-language data.

4. The model keeps inventing policy numbers and dates. How do you fix it?

Medium

Treat it as a grounding problem, not a prompting problem. Feed the actual policy text through retrieval, instruct the model to quote numbers only from the provided context, and add an "I could not find this" fallback. Lower the temperature for factual answers. Then add a post-check that compares every number in the answer with the source text and blocks or flags mismatches.

5. You have one 24 GB GPU and need to fine-tune a 7B model. How do you make it fit?

Hard

Full fine-tuning will not fit, because weights, gradients and optimizer states together need many times the 14 GB the 16-bit weights alone take. Use QLoRA: load the base model in 4-bit, train only LoRA adapters, and turn on gradient checkpointing to trade compute for activation memory. Keep sequence length and batch size small and use gradient accumulation to reach an effective batch size. Merge or keep adapters separate at the end depending on how you serve the model.

Common mistakes in LLM interviews

The most common mistake is describing LLMs at the level of a news article when the interviewer wants mechanics.

  • Vague architecture answers. "It uses attention" is not an answer. Say what attention computes and why it is masked in a decoder.
  • Mixing up training stages. Know clearly what pretraining, SFT, RLHF and DPO each change, and what data each needs.
  • No memory maths. Experienced candidates should estimate GPU memory from parameter count and precision in their head.
  • Benchmark worship. Quoting leaderboard scores without a custom evaluation plan signals you have not shipped anything.

My contrarian tip: do not spend your first week on the maths of the original transformer paper. Spend it running a small model locally and watching what changes when you touch temperature, context length and quantization. You will answer theory questions better because you have seen the behaviour yourself.

Last-week plan before your LLM interview

In the final week, revise rather than learn new topics.

  1. Day 1: Redraw the decoder block and explain attention in two minutes.
  2. Day 2: Write one line each on SFT, RLHF, DPO, LoRA and QLoRA.
  3. Day 3: Revise decoding, KV cache and quantization with one number each.
  4. Day 4: Polish your project story with a before and after metric.
  5. Days 5 to 6: Do two mock interviews with the prompts below.
  6. Day 7: Light revision, then rest.

Your interview prep checklist

  • Draw a decoder-only transformer block and explain causal attention from memory.
  • Explain pretraining, SFT, RLHF and DPO, and what data each stage needs.
  • Estimate GPU memory for a 7B model at 16-bit and 4-bit precision.
  • Explain greedy, top-k, top-p and temperature with one use case each.
  • Fine-tune a small model with LoRA and note one before and after metric.
  • Prepare one scenario answer on latency and one on hallucination.

Practise with AI mock interview prompts

Paste these into ChatGPT, Claude or Gemini to run a mock LLM interview.

Mock LLM interview

Act as a senior ML engineer interviewing me for an LLM engineer role in India. Ask 8 questions one at a time covering architecture, fine-tuning, inference and evaluation, from easy to hard. After each answer, score me out of 10, list what I missed and give a stronger answer. Wait for my reply each time.

Drill inference and serving

Quiz me with 6 short questions on KV cache, quantization, batching and decoding strategies. If I am wrong, correct me in simple words with a numeric example, then give me a 5-line revision note at the end.

Stress-test my fine-tuning project

Here is my LLM fine-tuning project: [describe model, data, method, results]. Ask me the 5 toughest follow-up questions an experienced interviewer would ask, then help me improve my answers.

AI concepts to revise before the interview

Frequently asked questions

What questions are asked in an LLM interview?

LLM interviews usually cover transformer architecture and attention, tokenization, training stages such as SFT and RLHF, fine-tuning with LoRA, decoding settings, KV cache and quantization, and evaluation. Experienced roles add serving, cost and debugging scenarios. Engineering roles often include a Python task.

How should freshers prepare for LLM interview questions?

Focus on mechanics in simple words: next-token prediction, attention, tokenization and the difference between base and instruction-tuned models. Then do one small hands-on project, such as a LoRA fine-tune or a model comparison with a test set. Practise explaining it in 90 seconds with one clear metric.

What is asked in LLM interviews for experienced candidates?

Experienced candidates get deeper questions on fine-tuning trade-offs, DPO versus RLHF, KV cache memory, quantization, serving at scale and evaluation design. Expect scenario rounds where you debug a failing model or cut latency and cost, and expect follow-ups on numbers from your own projects.

Is this page about the LLM law degree?

No. LLM here means large language model, the AI technology behind assistants like ChatGPT. If you are preparing for a Master of Laws (LLM) admission interview, you will need law-specific resources instead.

Can I download these LLM interview questions as a PDF?

Yes. Click the Save as PDF button near the top of this page and choose Save as PDF in your browser's print dialog. You get all 28 questions with model answers for offline revision.

Do I need to know the maths behind transformers for an LLM interview?

You need the intuition and the key formulas, such as scaled dot-product attention and what softmax does, but most roles do not ask for derivations. Research roles go deeper. For engineering roles, being able to estimate memory and explain trade-offs matters more than proofs.

References