Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

πŸ“— Part 2: Fast Candidate Retrieval

The first gate of the recommender pipeline β€” filtering a thousand candidates out of a billion-item corpus within milliseconds.

πŸ“š 5 sections Β· ⏱️ Estimated 2 weeks Β· 🎯 Target: master the family of retrieval algorithms, from statistical co-occurrence to vector search

Retrieval is the starting point of the "retrieval β€” ranking β€” re-ranking" three-stage funnel. It must quickly narrow a universe of hundreds of millions of items down to a few thousand candidates within millisecond-level latency β€” following the principle of "rather over-include than miss", its goal is coverage, not precision. Even a mediocre retriever can be tolerated, but if it misses the truly relevant items, the downstream ranking and re-ranking stages can do nothing to recover them.

This part unfolds along the technical evolution in five chapters: starting from the classic collaborative filtering, moving to vector retrieval (I2I), which ports sequence modeling ideas into recommendation, then the two-tower model (U2I), which uses deep networks for efficient retrieval, followed by the sequential/temporal information ignored by the previous methods (sequential retrieval), and finally stepping outside the "compress inside the model" paradigm to preserve full historical interests with a streaming index. Together they form the methodological map of the industrial retrieval layer.


What This Part Covers

SectionTopicThe Big Idea
2.1Collaborative FilteringCo-occurrence statistics over user–item interactions: from ItemCF item similarity, through Swing's industrial optimization and UserCF's user perspective, to matrix factorization opening the door to vectorization
2.2Vector Retrieval (I2I)Porting Word2Vec sequence modeling to recommendation: from Item2Vec's direct transfer, to EGES fusing attributes, to Airbnb baking business objectives into the objective
2.3Two-Tower Model (U2I)Users and items encoded separately as vectors, represented by FM, DSSM, and YouTubeDNN, enabling efficient vector search
2.4Sequential RetrievalFocusing on temporal information: MIND represents diverse interests with multiple vectors, SDM separates long- and short-term preferences and fuses them dynamically with gating
2.5Streaming Index RetrievalStepping outside compression inside the model: Trinity preserves full interests with cluster statistics, Streaming VQ keeps the index adapting in real time

What You'll Be Able to Do After This Part

  • 🟒 Distinguish neighborhood-based collaborative filtering (ItemCF / UserCF) from model-based matrix factorization, and articulate their respective strengths against sparsity
  • 🟒 Explain how Swing exploits bipartite-graph structure to filter noise, and how EGES uses item-specific attention to solve cold start
  • 🟑 Derive the simplification of FM's second-order interaction term, and show how it can be reorganized into a two-tower inner product
  • 🟑 Contrast the fundamental difference between two-tower models and sequential retrieval (MIND / SDM) in terms of "user representation": single vector vs. multiple vectors / long-short fusion
  • πŸ”΄ Analyze how Trinity and Streaming VQ use cluster statistics and streaming indexes to solve "interest amnesia" and "index staleness"
  • πŸ”΄ Complete 25+ graded practice problems across the 5 chapters, consolidating the full path from co-occurrence to vector search

Core Concepts

ConceptSectionRelevance
Item/user similarity, co-occurrence matrix2.1The cornerstone of collaborative filtering and a key industrial retrieval channel
Swing score, Surprise2.1Similarity optimizations aimed at industrial robustness and complementary items
Latent vectors, low-rank assumption2.1The turning point from statistics to representation learning
Skip-Gram, sequence modeling2.2Applying the "sentence = behavior sequence" idea to I2I retrieval
Item-specific attention (EGES)2.2The key mechanism for solving cold start with attributes
Two towers, inner-product retrieval, ANN2.3The engineering backbone of efficient U2I retrieval
Multi-interest capsules (MIND), gated fusion (SDM)2.4Sequential retrieval that captures diverse interests and recency
Cluster histograms, VQ index, EMA2.5The statistical and real-time-update foundations of streaming index retrieval

Prerequisites

  • You have finished Part 1 (especially the three-stage funnel in 1.1 and the technology map in 1.2)
  • Basic linear algebra (vector inner products, matrices), probability (softmax, cosine similarity), and general neural network knowledge
  • Familiarity with Python and the basic concept of embeddings

Retrieval-layer methods are relatively lightweight and coverage-oriented, with mostly controllable complexity; but the vectorization approaches (matrix factorization, two-tower, sequential) require you to be comfortable with embeddings and gradient descent.


Tips for This Part

  1. Understand the motivation before the formulas. Each method exists to fix a limitation of its predecessor β€” ItemCF is dominated by popular items, hence Swing; co-occurrence is sparse, hence matrix factorization.
  2. Follow the main thread of "how users/items are represented". From CF's ID co-occurrence, to MF's latent vectors, to the two-tower's independent encoders, to sequential retrieval's multiple vectors, the representations grow ever more refined.
  3. Mind retrieval efficiency. Methods that can precompute item vectors offline (two-tower, I2I) are usually the easiest to scale.
  4. Practice with the visualizations. Every chapter's interactive HTML and SVG pieces are worth clicking through yourself, grounding abstract formulas in the intuition of "how the candidate pool shrinks".

Let's dive in! πŸš€