Grokking the AI System Design Interview

0% completed

Introduction: Classic ML Design Questions

  1. The Questions Repeat
  1. They All Share One Shape
  1. What You Should Already Know
  1. The Lessons
  1. Two Words You Will See Everywhere
  1. Before You Start

1. The Questions Repeat

ML system design interviews feel unpredictable. They are not.

Under all the product names and company logos, the same small set of designs keeps coming back. Recommendations. Feed ranking. Search ranking. Ad click prediction. Fraud detection. These are the classics. Interviewers know them, expect you to know them, and reach for them first.

Learn these few well and you can handle most of what you will be asked, including the rarer questions like "design job matching" or "design duplicate detection." Those are just the classics wearing a different costume.

This module teaches them, one lesson at a time.

2. They All Share One Shape

Here is the part that makes this module easy: these are not a pile of unrelated systems. They are all the same idea, with the dials set differently.

That idea is a funnel. You start with millions of items and you need to show the user a handful. You cannot score millions of items in a few milliseconds, so you narrow the field in stages:

  1. Retrieve. A cheap, fast stage grabs a few hundred promising items out of millions.
  2. Rank. A slower, smarter stage scores those few hundred and sorts them.
  3. Apply the rules. A final layer adjusts the top handful for business reasons: freshness, variety, "don't show two ads in a row."

Every lesson in this module is this funnel with the dials turned to a different setting. Once you see the shape, each new design becomes one simple question: what is different here?

And each one changes one thing:

  • Recommendations is the plain funnel. Start here.
  • Feed ranking adds many goals at once. A good post is one you will like, comment on, and not report. Juggling those is the whole game.
  • Search ranking adds a query, and a trap: people click whatever sits at the top, even when it is not the best result. Your own click logs lie to you.
  • Ad click prediction adds money. The predicted number is not just for sorting; it sets the price in an auction. So it has to be an honest probability, not just "higher than the others."
  • Fraud detection adds an opponent. The fraudster studies your model and changes tactics to beat it. And missing one fraud costs far more than a false alarm.
  • Harmful content detection adds scale and high stakes. You are filtering the whole platform, and a wrong call in either direction either silences a real user or lets abuse through.

If some of those twists (position bias, calibration, an adaptive adversary) are new words right now, do not worry. Each lesson defines its twist in plain language before using it.

3. What You Should Already Know

This module builds on Module 2. We assume you already have the plumbing from there: a feature store, online inference, and a monitoring stack. Here we wrap real product designs around that plumbing.

Every design lesson also walks the seven-step framework in the same order. The first seven sections of each lesson are the seven steps, so the path you study is the path you will walk in the interview.

Each lesson then ends with an interview kit: a 30-second spoken answer with the follow-ups you are likely to get, the common mistakes that sink weak answers, and two variation questions that re-skin the design for a nearby product.

4. The Lessons

The question the lesson answersLesson
How do you pick 10 items for a user out of a catalog of 50 million?Design a Recommendation System
What changes when the items are your friends' posts and there are five kinds of "good"?Design Feed Ranking
How does a search query change the funnel, and why do clicks lie?Design Search Ranking
What happens when every prediction sets a price in an auction?Design Ad Click Prediction
How do you design against an opponent who adapts to your model?Design Fraud Detection
How do you catch harmful content at web scale without silencing real users?Design Harmful Content Detection
Can you run the whole funnel on a fresh problem?Capstone: People You May Know

5. Two Words You Will See Everywhere

Two terms show up in every lesson. Learn them now and the rest reads easily.

  1. Candidate generation (also called retrieval) is the first stage of the funnel. It cheaply pulls a few hundred items that might be a good fit out of the whole catalog, usually with a precomputed index or by finding items whose embeddings sit close together. (An embedding is just a list of numbers that captures what an item is about; similar items get similar numbers.) Its job is recall: of all the items the user would have wanted, how many made it through this stage? If the right item is not pulled here, nothing later can save it. Ranking can only sort what retrieval hands it.
  2. Ranking is the second stage. It scores those few hundred items with a richer model and sorts them by predicted value, whatever value means for the product: a click, a watch, a new connection, a purchase. Its job is precision at the top: of the few items you show first, how many are actually good? The user sees only that top handful, so this is where the model earns its keep.

6. Before You Start

Pick a product you use that has a feed or recommendations. Then answer three quick questions:

  1. Roughly how many items are in its catalog, and how many do you actually see in one session? That ratio tells you how hard the funnel is working.
  2. Name three things the app probably logged about you today that could help it rank tomorrow's session.
  3. Find one item it showed you that you did not care about. Was that a retrieval miss (nothing better existed to pull) or a ranking miss (something better was pulled, but shown below it)? Telling those two apart is this whole module in one question.
Mark as Completed

On This Page

  1. The Questions Repeat
  1. They All Share One Shape
  1. What You Should Already Know
  1. The Lessons
  1. Two Words You Will See Everywhere
  1. Before You Start