Grokking the AI System Design Interview
Vote

0% completed

​

Introduction: ML Systems Foundations

The Five Pieces of a Predictive ML System

What One Prediction Actually Does

One Divide Explains Most Problems

Words Used in Every Lesson

The Lessons

Where This Module Sits in the Course

Before You Start

The Five Pieces of a Predictive ML System

An interviewer says: "Design the system that predicts delivery time for a food order."

You may not know the data or traffic yet. Begin with a high-level design and identify the assumptions you need to confirm.

The following five parts provide a useful starting point.

Many predictive ML systems can be explained using five parts. A model is a function whose behavior is learned from data. Predictive means it produces estimates, scores, or categories.

Recommendations, fraud detection, and delivery estimates often need these parts, but their data, architecture, and operational requirements differ.

1. A training pipeline. A workflow that prepares data, trains a model, and evaluates it. It may run on a schedule or after a specific trigger.

2. A feature layer. The code and storage that turn raw data into model inputs.

3. An inference path. The steps that produce one prediction. Inference means running the model to get a prediction.

4. A serving platform. The machines and routing that answer live requests.

5. A monitoring loop. The measurement that notices when the system is getting worse.

The five pieces every predictive ML system is built from.
The five pieces every predictive ML system is built from.

Use these five parts to organize your design, then adapt them to the requirements.

This module teaches them one at a time. It stays product-agnostic, meaning it is not tied to one product.

There are no full designs here yet. Module 3 assembles these parts into real designs. Module 1 gave you the overall picture. This module gives you the individual parts.

What One Prediction Actually Does

A list of parts is hard to remember. The same system, written out as steps, is easier.

Here is an example delivery estimate, followed by a possible model-update process.

  1. The customer opens the checkout screen. The app calls your prediction service.
  2. The service collects features. Some are read from storage. Some are computed from the request itself.
  3. The features are arranged in the exact order the model expects.
  4. The model runs and returns a number, such as 34 minutes.
  5. Business rules adjust that number, and the estimate goes back to the customer.
  6. The service writes a log line. It records the features, the prediction, and the order id.
  7. About 40 minutes later the food arrives. The real delivery time is now known.
  8. That night the training pipeline joins the logged features to the real delivery times.
  9. A new model is trained, tested, and shipped if it beats the current one.

The request path must meet a defined response-time target. Outcomes and model updates arrive later, often hours or days after the request.

That difference is the most important idea in this module.

One Divide Explains Most Problems

The recurring theme is one divide: offline against online.

Training often runs in background jobs over historical data. It has its own completion deadlines and compute requirements.

Online serving handles live requests within a response-time limit. Batch inference instead produces predictions in background jobs.

Training and serving need compatible feature definitions and model inputs, even though they process data differently.

Show two important connections in the interview: model artifacts move toward serving, and prediction records and outcomes support evaluation and training. Production systems also share schemas, configuration, and other metadata.

The model file moves from training to serving. Training produces it. Serving loads it and runs it.

Logs move from serving back to training. Serving records what it predicted. The real outcome is added later. Training reads all of it next time.

The offline plane, the online plane, and the two things that cross between them.
The offline plane, the online plane, and the two things that cross between them.

Four problems come from this divide. Later lessons return to each one.

Skew. The feature computed during training does not match the feature computed during serving. The model then sees inputs it never learned from.

Staleness. A feature is correct but old. The restaurant got busy ten minutes ago, and the model still reads an hourly average.

Drift. Data patterns or relationships change. Quality may decline even when the service remains available, so monitor both data and outcomes.

Cost. Training costs depend on job size and frequency. Serving costs depend on request volume, hardware, and utilization. Estimate both separately.

Use this distinction to explain data consistency, freshness, reliability, and cost.

Words Used in Every Lesson

The following four terms appear throughout the module.

Feature. A feature is an input signal the model uses, computed from raw data.

"Number of orders this restaurant received in the last 30 minutes" is a feature. The raw order events behind it are not.

Feature preparation can require substantial engineering work. Test it carefully because errors can affect both training and serving.

Label. A label is the target outcome used in supervised training, such as actual delivery time or a click. Some labels are imperfect: a chargeback, for example, does not always prove fraud.

Training example. One row that pairs features with a label.

Supervised training pairs features with labels. At prediction time, the outcome may not be known yet. Label availability and delay therefore affect the training pipeline.

Latency budget. The time allowed for the prediction path. Set it from the product requirements; do not assume every predictive system has the same limit.

The Lessons

Question the lesson answersLesson
Why are training and serving separate systems, and what talks across the gap?Training vs Serving
Where do labels and training data actually come from, and who pays for them?Where Training Data Comes From
What are features, and why do they need their own infrastructure?Features and Feature Stores
Should predictions be precomputed or computed on demand?Batch vs Online Inference
How do ids become vectors, and why does retrieval run in milliseconds?Embeddings and Two-Tower Retrieval
How does a model actually run in production, and how do new versions ship?Model Serving Basics
Which offline metric fits which problem, and when must scores be probabilities?Offline Evaluation: Choosing the Metric
How does the system notice it is getting worse, and what does it do about it?Monitoring, Drift, and Retraining
How do you prove a new model is actually better, and launch it safely?Online Experiments and A/B Testing
Can I assemble all five pieces for a real product?Capstone: An ML Platform for ETA Prediction

Where This Module Sits in the Course

Where this module sits in the course.
Where this module sits in the course.

Module 1 gave you the framework and the three question families.

This module gives you the five pieces, using small predictive models.

Module 3 uses them to answer the classic ML design questions.

Modules 4 to 7 change what sits inside the pieces. LLM serving puts a large language model where the small model was. RAG adds a retrieval step before the model. GenAI products and agentic systems add generation, tool calls, and safety checks.

The same concerns remain useful, but components are not interchangeable. A vector index supports retrieval; a feature store manages model inputs. Improvements may involve training, retrieval, or instructions, while monitoring continues to track quality and cost.

Module 8 runs full case studies under interview time pressure. Module 9 is a short review before your interview day.

You will reuse these concepts in later designs.

Before You Start

Keep the food-delivery problem from the Module 1 capstone in mind. Sketch rough answers to three questions.

  1. Name five signals you would want when predicting how long a delivery will take, at the moment the customer opens the checkout screen.
  2. Which of those five change second by second, and which change slowly or never?
  3. When does the real delivery time become known? How would it get back to the model?

Reading Progress

0%


Vote for new content

On This Page

The Five Pieces of a Predictive ML System

What One Prediction Actually Does

One Divide Explains Most Problems

Words Used in Every Lesson

The Lessons

Where This Module Sits in the Course

Before You Start