Learning path: Prepare for ML Engineer Interviews · Step 4 of 13
The ML System Design Framework: Eight Steps, in Order, on a Spam Filter
One repeatable route through any ML system design question: goal, metric, data, features, model, serving, monitoring and failure. Worked on an email spam filter, with the follow-ups and a three-check rubric.
What you will learn
- Walk any ML system design question through eight steps: goal, metric, data, features, model, serving, monitoring, failure
- Agree the metric out loud before talking about a model
- Test every feature with one question: would I know this at the moment I decide?
- Choose the failure path ahead of time, from the metric
Before you start
- Precision, Recall and F1 Score
- Train-Test Split and Data Leakage
The five-move answer framework gives you a shape for any interview question. This one is only for ML design questions: eight steps, always in the same order. We'll take one simple example through all eight, an email spam filter. It's a thought example; nothing here was measured.
Eight steps, in this order
| Step | The question it answers |
|---|---|
| 1 Goal | What are we trying to achieve? |
| 2 Metric | How will we know it worked? |
| 3 Data | What do we have, and where do the labels come from? |
| 4 Features | What can we actually know at the moment we decide? |
| 5 Model | Start simple. |
| 6 Serving | How fast, and how does the answer get to where it's needed? |
| 7 Monitoring | How do we notice when it's getting worse? |
| 8 Failure | What happens when something breaks? |
Think of a pilot before take-off. A new pilot uses the checklist, and a pilot with twenty years of flying uses the same one. It isn't there to show what she doesn't know; it's there so nothing gets missed under pressure. An interview is pressure. The checklist does the remembering, and you do the thinking.
What it looks like without the steps
The question: design a spam filter for email. The candidate says, straight away, "I'd use a large neural network."
The interviewer asks: what counts as good here? What data would you train it on? What if it blocks an important email? Silence, because none of that has been thought about yet. The model might even be a fine choice, but nobody can tell, because nothing has been decided that the model has to serve.
Steps 1 and 2: goal and metric
Goal: people read their email without the junk, and they never lose one that matters.
Metric: there are two ways to get it wrong, spam that gets through and good email that gets blocked. They're not the same. One spam is a small annoyance; one blocked job offer is a much bigger problem. So, for illustration, we'd treat a blocked email as the costlier mistake.
Now say the metric out loud and agree it with the interviewer before you go on, like a small contract: catch as much spam as we can, while keeping blocked good email under an agreed limit. Everything after this is judged against that line. (Background: Precision, Recall and F1.)
Steps 3 and 4: data and features
Data: people press "report spam", so labels come for free. But they aren't perfect. Most people never report anything, and a good email that got blocked may never be looked at again. Say that out loud.
Features: who sent it, what's in the subject, what links are inside. The test for every feature is one question: would I know this at the moment I decide? What the sender's domain looks like, yes. Whether the person later opened it, no, so that can't be an input. That's the same rule that stops data leakage.
Steps 5 and 6: model and serving
Model: now, and only now. Start with something simple and put a score on it. A bigger model has to beat that score by enough to pay for its extra cost. If you can't say what it adds, you don't need it yet.
Serving: email can wait a moment, so we have more time than a payment would give us. Each message is scored as it arrives. What comes out isn't only yes or no: a clear case goes to the spam folder, an unclear one can go to the inbox with a warning. The metric from step two is still deciding things here.
Steps 7 and 8: monitoring and failure
Monitoring: spammers change their tricks, so a filter gets worse by itself over time. Watch how many people press "report spam", and how many pull good email back out of the spam folder. Those two climbing means something has changed, even before you have fresh labels. More in Monitoring Drift and Retraining.
Failure: what if the model is down? You choose what happens, and you choose ahead of time. Here: let email through and fall back on simple rules, because a little more spam is the cheaper mistake. That choice comes straight from step two, so the end of your answer connects back to the start.
Follow-ups and a rubric
- "Why that metric, and what would make you change it?"
- "Five minutes left. Which step would you go deeper on?" Pick the riskiest one and say why.
- "Tell me about the model." The interviewer may jump ahead. That's fine: answer it, then come back to where you were.
A simple rubric for your own answer (an example; every company scores in its own way):
- Did you cover all eight steps, in order?
- Does each step connect to the one before it?
- Did you say what each choice costs?
Recap
| Idea | What to remember |
|---|---|
| Eight steps | Same order every time, like a pilot's checklist |
| Goal and metric | Come first; agree the metric out loud |
| Model at step five | It has to beat something simple |
| Watch, then fail safe | Finish with what you'd watch and what happens when it breaks |
See the steps used on bigger questions in the walk-throughs for fraud detection, a recommendation feed and ad click prediction.
Try it yourself
Take a ticket router for a support team. Write one line for each of the eight steps, and say it out loud.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
The ML Engineer Interview Loop: Five Rounds, What Each One Looks For, and a Simple Rubric
The rounds you go through for one ML engineer job: recruiter screen, coding, ML depth, ML system design and behavioural. What each round looks for, the follow-up it brings, and a four-check rubric for your own answers.
The Answer Framework for Technical Interviews: Five Moves, Scored Out of 24
Good interview answers share one shape: a 30-second answer, the mechanism, the trade-off, the metric and the failure test. Worked on one question about a batch job starving everyone else, with a 24-point example rubric.
From Symptom to Pattern: How to Answer "Which Pattern Would You Use?" in an Interview
Start from what you can see, not from the pattern you know. A four-step rule (symptom, cost, metric and failure test, ship first), a symptom table, one worked answer for 429s at peak, and the trap of using a prompt as a lock.
ML System Design Interview: Fraud Detection for Card Payments, in Eight Steps with Numbers
A full interview answer to "design a fraud detection system for card payments": a do-nothing model at 98.8% accuracy that catches 0 of 71 frauds, a cost metric, a cut-off that moves cost from 7100 to 6610, a 50 ms budget and a rules fallback.