Topic 2 of 6 · 6 min read
System design interviews for LLM applications
Goal: Sketch an LLM application design that names the retrieval choice, eval plan, guardrails and cost estimate, and defend one trade-off.
In an LLM system design round, design the same way as for any system, then say out loud where the model can be wrong and how you would find out. Interviewers expect the usual parts (clients, storage, queues, scale) plus the parts that are new: context, evals, guardrails, latency and cost.
Check yourself · 1 of 3
An LLM design question starts. What do you do first?
Why it matters
Anyone can draw "user, LLM, database". The signal is whether you know that the model is the least reliable component, and that the design has to contain its mistakes.
How to do it
- Clarify the task. Who uses it, what a good answer looks like, how many requests a day, how wrong an answer can be. A support bot and a medical triage tool need different designs.
- Choose how knowledge gets in. If the data is large, changes often or needs citations, use retrieval (search first, then pass the best passages to the model). If the data is small and stable, long context may be simpler. Say why, and name the cost of the other choice.
- Choose workflow or agent. A fixed sequence of steps is cheaper, faster and easier to test. Use an agent that picks its own tools only when the steps truly cannot be known in advance.
- Plan the evals. A set of real questions with expected answers, run on every change, plus a sample of live traffic reviewed by humans. Name what you measure: correctness, citation accuracy, refusal rate.
- Add guardrails. Input checks, output checks, permission limits on tools, and a human approval step for actions that cannot be undone. Mention prompt injection when the model reads outside text.
- Estimate latency and cost. Tokens per request times price, then what you cache, what you route to a smaller model, and what you stream.
Before and after
Weak answer: "I would put the documents in a vector database and ask the model."
Stronger answer: "Support articles change weekly and answers need links, so retrieval. I would chunk by section, retrieve the top passages, and require the model to cite them. A fixed workflow: classify, retrieve, answer, check that every cited link exists. I would keep 200 real tickets as an eval set and run it on each prompt change. Refunds go to a human. The failure I worry about most is a confident answer from a stale article, so I would show the article date."
What goes wrong
- Naming tools instead of reasons. "Use a vector DB" without why does not show design.
- No eval plan. Without one, you cannot say if a change helped.
- An agent for everything. It adds cost and variance where a fixed workflow would do.
- Silence about failure. Interviewers listen for the failure modes you raise yourself.
Examples
Estimating cost out loud
Say: 20,000 requests a day, about 3,000 input tokens and 400 output tokens each. Multiply by your model's price per million tokens, then show two levers: cache the system prompt and route simple questions to a smaller model.
Naming a failure mode
A retrieval bot returns an old refund policy because the new one ranked lower. Your fix: store a date on every chunk, prefer the newest, and show it to the user.
Key points
- Clarify users, volume and the cost of a wrong answer before drawing anything.
- Choose retrieval or long context by data size, change rate and need for citations, and state the trade-off.
- Prefer a fixed workflow; use an agent only when the steps cannot be known ahead.
- An eval plan names the test set, the metrics and when it runs.
- Guardrails include tool permissions, approval for irreversible actions and defence against injected text.
- Say the likely failure modes yourself; that is part of what is scored.
Common mistakes
- Jumping to a vector database without asking whether retrieval is needed.
- Designing an agent when a three-step workflow would do.
- Leaving evals to the end or skipping them.
- Giving no cost or latency estimate, or giving one with no inputs behind it.
Check yourself · 2 of 3
Product docs change every week and answers must link to the source. Which knowledge approach fits best?
Check yourself · 3 of 3
The steps for a refund-status bot are always: look up the order, read the policy, answer. Which design is best?
Practice items, not counted towards your mastery.
Start here
- Machine Learning Interviews book (Chip Huyen) (opens in a new tab)BookFree
Describes how ML and AI interview loops are structured and how to prepare for each round.
- The System Design Primer (opens in a new tab)ToolFree
Core system design vocabulary (caching, queues, load, trade-offs) that LLM design rounds still build on.
- Building a generative AI platform (Chip Huyen) (opens in a new tab)ArticleFree
Walks through the components of an LLM application: context, guardrails, routing, caching and observability.
More for this topic
- Your AI product needs evals (Hamel Husain) (opens in a new tab)ArticleFree
A practical view of eval suites for LLM products, useful for the eval plan in a design round.
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Separates fixed workflows from agents and says when each is worth its cost and latency.
- OWASP Top 10 for Large Language Model Applications (opens in a new tab)StandardFree
Names the main LLM application risks, such as prompt injection and excessive agency, for guardrail discussions.