Introduction

No background required. Like its companion books, this one assumes you know nothing about programming, AI, or recommendation systems. Every concept, line of code, and symbol is explained, and every code example is followed by the exact output it produces. New to Python? Read the 5-minute primer first. At the same time, the later chapters go deep enough — the math and the production architecture — to be useful to seasoned engineers.

What is a recommendation system?

A recommendation system predicts what a person will want next and shows it to them. The "Recommended for you" row on Netflix, "Customers also bought" on Amazon, your personalized feed, "Up next" on YouTube, suggested songs, suggested connections — all of it is recommendation systems deciding, out of millions of items, the handful to put in front of you.

Done well, it's one of the highest-leverage pieces of software a company can build: it drives a large share of engagement and revenue at the biggest platforms on earth.

What this book covers

We build the whole discipline from the ground up:

  • The design principles — how to think about the problem, the data, and what "good" even means (how we measure a recommender).
  • Every major algorithm, implemented from scratch and explained under the hood — not just names and one-liners, but the actual math and code: popularity/trending baselines, content-based filtering, neighborhood collaborative filtering, matrix factorization, and learning-to-rank.
  • The hard real-world problems — especially cold start (what do you recommend to a brand-new user with no history?) and serving at scale.
  • The production architecture — the two-stage "candidate generation + ranking" design that essentially every large system uses, and how it connects to the nearest-neighbor search from the HNSW and IVF-PQ books.

A concrete example to anchor on

Here's a complete, real recommender — the kind this book teaches you to build and reason about — described in plain English:

  1. Turn every article into an embedding (a vector capturing its meaning).
  2. For a given user, take the articles they've read, and average their embeddings — but weight recent reads more than old ones (a time decay), because interests drift. That weighted average is the user's taste vector.
  3. Run a nearest-neighbor (kNN) search over all the other article embeddings (in OpenSearch, FAISS, Milvus, …) to find the articles closest to that taste vector. Those are the recommendations.
  4. If the user is brand new with no reading history, you can't build a taste vector — so fall back to trending items until you learn something about them.

That single example touches content embeddings, time decay, kNN serving, and cold start. We'll build exactly this (Chapters 5 and 10) — and then go well beyond it.

What you'll build

How to read this book

Read it front to back the first time — each chapter builds on the last (data → metrics → baselines → algorithms → architecture). If you're experienced, you can jump to a specific algorithm chapter; each is self-contained with its own code and output.

Let's start with the vocabulary and the smallest bit of Python you'll need. 👉