AI Engineer: System design
Design a product on a model
About 45 minutes, start to finish.
Open withBefore I draw anything, can I ask who uses this and what they need from it?
The clock
Stage by stage
Close each stage out loud, so they always know where you are.
- 1Scope the user and the job5 min
So that's who it's for and the job it does. Next, what a good answer looks like.
- 2What good means and how to measure it5 min
That's how we'll know it works. Now let me sketch the path one request takes.
- 3Sketch the request path5 min
That's the whole path, end to end. I'd like to go into retrieval and the prompt next.
- 4Retrieval, tools and prompts10 min
That's what the model sees and what it's allowed to do. Next, how we'd test it.
- 5Evals and failure cases8 min
That's the test plan and the ways it fails. Now cost, speed and safety.
- 6Cost, latency, fallbacks and injection8 min
Those are the numbers and the guards. Let me sum up.
- 7Wrap up4 min
To sum up, here's what I'd build first and the biggest risk.
How people lose this round
I'd start with the biggest model and a vector database.
Tools before the user and the job. Nothing after it has a reason the interviewer can check.We'll know it works when users are happy with it.
That's a hope with no measure. Name a test set and the two or three numbers you'd track before you build.The system prompt tells it to ignore instructions in documents, so injection is handled.
A prompt is a request the model may not follow. Limit what the model can do, and treat every outside text as untrusted.I'd put the user's question at the top of the prompt.
The question changes on every request, so nothing after it can be reused. Fixed instructions go first, where the server can cache them.If the model is down, we show an error.
Plan the fallback out loud: a second model, the source links, or a hand-off to a person.
A worked answer
The notes in the margin mark where the candidate asked, put a number on it, took a hint or caught a slip.
- Interviewer
Design an assistant that answers customers' questions from our help centre.
- You
Before I draw anything: who's asking, and what happens today when they can't find an answer?
Clarifies the user and the job first. - Interviewer
Customers of a software product. There are about 2,000 help articles. Today they open a ticket, and an agent replies within a day. We get around 20,000 questions a day.
- You
Then the job is to answer from our articles in seconds, and hand off to an agent when the articles don't cover it. A good answer is correct, cites the article it came from, and admits when it doesn't know. I'd measure three things: correct and cited answers on a test set, how often it hands off when it should, and tickets per question once it's live.
Defines good before drawing any boxes. - Interviewer
Fine. Walk me through one request.
- You
The question comes in. We search the articles with keyword and vector search together, rerank, and keep the top five chunks. The prompt puts the fixed instructions first, then the chunks, then the question. The model answers with citations, or says it can't and offers an agent. Every step is logged, so we can replay failures.
- Interviewer
Why keyword search as well?
- You
Customers paste error codes and product names. Vector search blurs exact strings, and keyword search catches them.
- Interviewer
What does one request cost?
- You
Say 500 tokens of instructions, five chunks of 400, and the question: call it 3,000 tokens in and 250 out. At an assumed $1 per million input tokens and $4 per million output, that's three tenths of a cent plus one tenth, so $0.04 a request. Sorry, $0.004. At 20,000 a day, that's about $80 a day.
Prices are assumptions. Catches a decimal slip. - Interviewer
How would you test it before launch?
- You
A few hundred past tickets that an agent answered from an article, plus questions the articles don't cover, so it has chances to say no. A person grades a sample. A model grader does the rest, checked against those human grades, because model graders tend to favour longer answers. And I'd read the failures myself before changing anything.
- Interviewer
What if the main model is slow or down?
- You
A timeout, then a second model with the same prompt. If both fail, we show the top article links and offer an agent. Never a blank screen.
- Interviewer
The articles are yours. What about the customer's message?
- You
That's untrusted text, and it can say "ignore your instructions". So the assistant gets no tools that act. It can't refund or change an account. It can only answer and hand off. The worst case is a bad answer, and the citation rule and a check on the output limit that.
Takes the hint on injection. - Interviewer
Good. Wrap up.
- You
First build: search, answers with citations, and the test set, before any caching or routing. The biggest risk is a confident answer on something the articles don't cover, so the hand-off gets tested hardest. Next, a cache for repeated questions, once the logs show how often they repeat.