RecSys · textbook
Trainer Widgets Revision About

Recommender Systems

A textbook for people preparing for an interview who would rather not memorise definitions. Formulas are derived here, numbers are computed, and every technique is examined not only for how it works but for where it breaks.

How this differs from a set of notes
  • Everything is checked. Every number is computed by a script from this same repository or verified against the source it describes. The maths inside the widgets is reproduced independently in Python — agreement to 1e-9.
  • Widgets, not pictures. Twenty-six interactive demonstrations where you move a parameter and watch what happens to the metric. These are not illustrations: there are real computations inside.
  • A living system, read closely. A separate part reads the open-sourced code of a real feed — along the request path, with the actual weights from its configs.

What it is made of

Nineteen chapters along the request path. Each part answers its own question, and inside a part every chapter builds on the one before it. You can read straight through or take a single section — the «what to take away» and «one-screen cheat sheet» boxes exist for exactly that.

Part I · Statement and measurement

Where any system starts: what it actually optimises, where the data comes from and why measuring quality is harder than getting it.

Part II · Candidate generation

How to pull a hundred candidates out of millions in milliseconds without losing the right ones on the way.

Part III · Ranking

A hundred candidates are in hand — now they have to be ordered: what to train the model on, what to feed it, and how to serve several goals at once.

Part IV · Sequences and the slate

User history as an input and the slate as a whole: what to show together, and what to show for the first time.

Part V · Engineering

What everything above stands on: where features come from at request time, and how the system behaves under load.

Part VI · System design

Everything above assembled into one procedure — the one you answer the system-design question with.

What else is in every chapter

Every chapter ends with interview questions and full answers; all of them are collected on the review page. The numbers in the boxes are computed by a script in _tools/, and you can run it yourself.

Reading the open-sourced code of a real feed

The open-sourced «For You» feed at X

X released the source of its main feed: 2028 files in Rust, Python, Scala and Java. Eleven chapters read the system along the request path: real action weights from the code, derivations, diagrams and four widgets on the actual numbers. Every number is verified against the sources automatically. The theory explains why it is done this way; here you see what it looks like when written in earnest.

Глава x00

Обзор

Что именно выложили, чем две дорожки ленты отличаются друг от друга и как устроен репозиторий на 2028 файлов.

две дорожкикарта репозитория
Глава x01

Пайплайн

Путь запроса по стадиям: что происходит между нажатием на вкладку и готовым списком постов.

стадиигидратация запроса
Глава x02

Источники

Откуда берутся кандидаты: несколько независимых источников разной природы и квоты, которыми их смешивают.

ThunderSimClustersквоты
Глава x03

Retrieval

Двухбашенная модель в рабочем виде: как в коде устроены башни и чем там оказываются semantic IDs.

две башниsemantic IDs
Глава x04

Ранжирование

Ранжирующий трансформер и приём, ради которого он так устроен: кандидаты изолированы друг от друга внутри батча.

трансформеризоляция кандидатов
Глава x05

Скоринг

Реальные веса действий из конфигов, поправки к ним и то, как из отдельных вероятностей собирается один скор.

веса действийпоправкиDPP
Глава x06

Фильтры

Двадцать девять фильтров, их порядок — и что этот порядок говорит о стоимости каждого.

29 фильтровпорядок
Глава x07

Видимость

Разметка контента, правила видимости и репутация автора: слой, который решает не «что выше», а «показывать ли вообще».

разметкаправиларепутация
Глава x08

Блендинг

Как в ленту подмешивают рекламу и не-посты и какими долями это управляется.

рекламане-постыдоли
Глава x09

Конфигурация

Параметры, вынесенные в конфиги, и что по ним видно об устройстве экспериментов.

параметрыэксперименты
Глава x10

Чему учит

Что этот код говорит о теории из первой части — и пять мест, где он с ней расходится.

выводы о теориипять расхождений

The X code is distributed under Apache 2.0. Every quoted fragment names its file and commit; the reading around it is ours.

What to use along the way

Metrics trainer

Sixteen problem types with answer checking and a worked solution: precision, recall, MRR, MAP, NDCG, AUC, the confusion matrix, smoothed CTR, IPS, the Bloom filter. Per-type statistics push you towards your weak spots. → open

Review mode

Every interview question in one place: cards, «known / repeat» marks, filtering by chapter, a random question. → open

The full list of interactive demonstrations, with a note on what each one shows, is in the widget catalogue.