Recommender systems
Multi-Stage Ranking and Feature Serving
Design pre-ranking, ranking, and final re-ranking stages with compatible objectives, features, latency, and traceability.
By the end you can
- Explain the roles of retrieval, filtering, pre-ranking, ranking, and re-ranking
- Design stage-specific objective, feature, latency, and recall contracts
- Compare independent, distilled, and cascade-aware stage training
- Build oracle-recall and elimination-trace diagnostics
Visual
A staged scoring architecture
Each stage sees fewer candidates than the one before it and spends more on each. Retrieval is judged by what it fails to keep; final re-ranking is judged on the slate as a whole.
YouTube's engineers published this shape in 2016. They split the system along the classic two-stage retrieval dichotomy: a deep candidate generation model first, then a separate deep ranking model. Three years later Yi and colleagues published a sampling-bias correction for two-tower retrieval, applied to a corpus of tens of millions of videos.
The last stage asks a different question, and that question is older than either paper. Maximal marginal relevance was described in 1998, by Carbonell and Goldstein. It re-orders a list that has already been retrieved. Each document scores on a linear combination of query relevance and dissimilarity to the documents already selected. One end of the tuning parameter gives the plain relevance ranking, the other a maximal-diversity ranking. Their criterion: "a document has high marginal relevance if it is both relevant to the query and contains minimal similarity to previously selected documents."
The evidence underneath it was thin. The paper reports a pilot with five undergraduates, who were not told which ordering they were seeing. Of those five, 80% chose MMR when asked to pick a method for a search task. There was also a 70% accuracy score for the MMR-based summariser at the SUMMAC evaluation in May 1998. Five users, and the idea is now in every pipeline.
A per-item score is simply the wrong quantity at the last stage. That argument was made again in 2019, with deployed numbers behind it. Of the ordinary learning-to-rank stage, the Alibaba re-ranking paper says: "However, it may be sub-optimal because the scoring function applies to each item individually and does not explicitly consider the mutual influence between items, as well as the differences of users' preferences or intents."
Their re-ranker is a follow-up module after any ranking algorithm. It takes the existing model's list as its input, then uses self-attention to model relationships between every pair of items in that list. Alibaba tested it online across hundreds of thousands of users and millions of requests. Added on top of a DNN-based learning-to-rank ranker, it raised page views by 0.77%, item page views by 1.75%, CTR by 0.97% and GMV by 0.13% for DLCM. For PRM-BASE the same four numbers were 1.27%, 2.44%, 1.16% and 0.36%. The authors note that the 0.77% alone means about billions of extra items viewed. Each stage has its own labels, its own cost budget, and its own way of losing the right answer.
Retrieval
Maximize broad candidate recall from a large corpus.
Filtering
Enforce eligibility, duplicates, and request-specific constraints.
Pre-ranking
Use cheap features to retain promising candidates.
Full ranking
Apply rich interactions and multi-task outcome estimates.
Final re-ranking
Construct the slate under diversity, policy, and layout constraints.
Example
At Taobao the cheap stage was forbidden the features the expensive stage relied on
Taobao's recommender runs three stages. Candidate generation selects around 10^5 items, then coarse-grained ranking, then fine-grained ranking. In 2020 Alibaba published what goes wrong in the middle of that cascade.
The constraint is the ordinary one. The coarse-grained model "is strictly restricted, in order to grade tens of thousands of candidates in milliseconds". So the user-item interacted features that the later stage relies on are prohibited there. The paper's Figure 2 labels them the privileged features for coarse-grained ranking, and the abstract defines the category: "We define the features that are discriminative but only available during training as the privileged features."
The remedy is not to smuggle those features into the cheap stage. It is to distil them. A teacher that sees the privileged features trains a student that does not. Only the student is served.
- Stage capacity: Each stage reduced candidate count under a latency budget — candidate generation selecting around 10^5 items, then coarse-grained ranking, then fine-grained ranking.
- Objective mismatch: The stages were measured on different definitions of value: the CTR task at coarse-grained ranking, the CVR task at fine-grained ranking.
- Feature asymmetry: The user-item interacted features available to the later stage were prohibited at coarse-grained ranking, whose model “is strictly restricted, in order to grade tens of thousands of candidates in milliseconds”.
- Distillation need: The small stage took guidance from the richer model instead of the forbidden features. Online A/B tests improved the click metric by +5.0% for the CTR task at coarse-grained ranking and the conversion metric by +2.3% for the CVR task at fine-grained ranking.
- Trace gap: A system that stores only final scores cannot say at which boundary a candidate was lost, so neither the asymmetry nor the gain from repairing it shows up in the numbers the team watches.
Multi-stage ranking is a sequence of lossy approximations
Large systems progressively reduce candidates through retrieval, filtering, pre-ranking, ranking, and re-ranking. That shape was formalised in 2011, in a SIGIR paper on cascade ranking. The model "constructs a cascade of increasingly complex ranking functions that progressively prunes and refines the set of candidate documents to minimize retrieval latency and maximize result set quality."
What makes that paper the reference is that it prices the pruning instead of asserting it is cheap. Table 3 gives two columns per stage. One is the percentage of documents filtered from the previous stage. The other is "filter loss", defined in the caption as "% documents incorrectly pruned out of all documents passed from the previous stage". On Clue — the first English segment of ClueWeb09, 50,220,423 documents — stage 1 filtered 97.7% of documents at a filter loss of 0.09%, stage 2 filtered a further 68.3% at 0.18%, and stage 3 filtered 10.7% at 0.0%. On Gov2, 25,205,179 documents under TREC topics 701–850, stage 1 filtered 95.1% at 0.15% and stage 2 filtered 50.0% at 1.6%. Those are the two columns a pipeline owes its reviewers. The second one is never zero for free.
The reward bought with that loss is on the clock. With the effectiveness/efficiency tradeoff parameter γ set to 0.1, the learned cascade ran through stages 0–3. It was 32.7%, 48.7% and 34.7% faster than the monolithic AdaRank baseline on Wt10g, Gov2 and Clue: 0.175s against 0.260s, 2.00s against 3.90s, 4.28s against 6.55s. Effectiveness the authors describe as "similar (and many times slightly better)" than AdaRank. NDCG@20 was marginally higher on Wt10g (35.60 vs 35.49, +0.3%) and on Gov2 (47.44 vs 47.37, +0.1%), and 1.1% lower on Clue (30.60 vs 30.94).
Earlier stages must preserve enough optionality for later stages while meeting strict cost limits. So every stage needs a contract: input set, output budget, objective, available features, latency, recall target, failure fallback. Optimizing stages independently can create a pipeline that is locally strong and globally weak. And a cascade shipped without a filter-loss column is one whose designers have decided not to know.
Whatever an early stage drops is gone: no later model can rank an item it never received.
Analogy
Airport security with successive checkpoints
Travelers pass a document check, then security screening, then gate control, then boarding. Whoever is turned away at the first desk is invisible to every check downstream, however careful those later checks are.
Multi-stage ranking prunes with the same finality. And the cheapest stage — the one holding the least evidence and facing the largest corpus — is the one making the most irreversible calls. In the 2011 cascade that is stage 1, which filtered 97.7% of the Clue collection at a filter loss of 0.09%. The largest cut in the pipeline, made by the least informed function in it.
Early-stage efficiency must be measured against the valuable options it removes.
Steps
Create stage contracts and loss accounting
Candidate budgets and latency are declared at every boundary first. Every candidate dropped along the way is logged last, with its reason, score, threshold, source, and stage.
Step 2, aligning objectives, is the step teams treat as paperwork. Facebook Search published what skipping it costs. In 2020 its engineers reported that changing the retrieval stage left the stages downstream of it mis-fitted. Because "the current ranking stages are designed for existing retrieval scenarios", new results from embedding-based retrieval could be "ranked sub-optimally by the existing rankers". The rule they draw is exactly what step 2 exists to enforce: "The model at each stage should be optimized for the distribution of results returned by the preceding layer."
Two repairs shipped, rather than one memo. The query–result embedding cosine similarity was propagated down the funnel as a ranking feature. And a closed feedback loop sent the results logged after embedding-based retrieval was enabled to human raters. Their labels re-trained the relevance model, so it could filter out the irrelevant results the new retriever had introduced.
Step 3 has a published form in the same work. The retrieval stage is scored on what it fails to keep, as recall@K: run KNN search over the whole index for 10,000 sampled search sessions, then average. Against that measure, switching from text embeddings to unified embeddings gave +18% recall for events search and +16% for groups search. Online hard-negative mining added +8.38% recall for people search, +7% for groups and +5.33% for events. A pipeline that cannot account for what it dropped has no recall story to tell.
1. Set candidate budgets
Define counts and latency at every boundary.
2. Align objectives
Document differences and acceptable approximation loss.
3. Measure oracle recall
Ask whether later-stage winners survive each earlier stage.
4. Version features and teachers
Preserve stage-specific data and model dependencies.
5. Trace every elimination
Log reason, score, threshold, source, and stage.
Example
Stage-design failures
A recall cliff is a loss, and a missing trace is the reason nobody finds it. The serving side of that problem has one systematic published account: Google's TFX team described the platform's data-validation component in 2019. Hundreds of product teams use it to monitor several petabytes of production data per day. The production analysis draws on a sample of more than 700 ML pipelines.
The paper names three kinds of training-serving skew. Their most common cause is "different code paths used for generation of training and serving data", which are required because offline and online generation have widely different latency and throughput characteristics. The skew, in other words, is manufactured by the same latency budget that made the staged pipeline necessary in the first place.
- Recall cliff: A cheap stage removes candidates that later stages would value, and the only way to see it is to ask whether the later stage's winners survived the earlier one.
- Feature skew: A feature takes different values in training and at serving — including “time travel”, where a click count read from a live database at training time already includes clicks that happened after the item was served.
- Score incompatibility: Stage thresholds drift as upstream candidate distributions change.
- Latency retry loop: Timeouts trigger repeated feature fetches and inconsistent fallbacks.
- Missing trace: No record shows where or why an item disappeared. Google's fix is mechanical rather than cultural: the serving infrastructure logs a sample of serving data back into the training pipeline, and the validator key-joins matched batches and compares feature by feature.
Key idea
The first cut is the one that cannot be undone
The first stage that removes an item owns an irreversible decision for every stage that follows. Google's data-validation paper gives that decision a name: "Scoring/Serving Skew occurs when only a subset of the scored examples are actually served."
It also gives a worked example. A hundred videos are scored. Ten are shown. The clicked one and its nine neighbours become labelled examples, and "the ninety videos that were never served may not have associated labels and therefore may never appear in the training data".
So the cut does two things, not one. It hides the dropped candidates from every metric computed afterwards. And it removes them from the data the next model learns on. That is how one stage's approximation becomes the next generation's assumption about the world.
Every metric downstream is computed on the survivors, so a bad first cut can present itself as a healthy dashboard.
Key idea
The stage gate
A new stage is justified only when its latency savings exceed the measurable value lost by irreversible pruning and added failure modes. Alibaba put both halves of that trade on one page in 2020, in the COLD paper on its display advertising pipeline. There the pre-ranker receives a candidate set of order ten thousand and passes several hundred to the ranker, under a latency limit of 10–20 milliseconds.
The easy half is Table 3. The vector-product two-tower pre-ranker serves 60,000+ QPS at 2 ms, COLD 6,700 QPS at 9.3 ms, and the full DIEN ranking model 629 QPS at 16.9 ms. The half nobody volunteers has a metric here too: "Besides, we introduce a new metric of top-k recall, to measure the alignment degree between the pre-ranking model and subsequent ranking model." Measured against the ranker's own top-m list, the 2 ms two-tower pre-ranker retains 88% of the ranking model's winners (GAUC 0.6232). COLD retains 96% (GAUC 0.6391). DIEN is the 100% reference.
Read the two tables together and the cheapest stage is visibly the dearest in candidates. Two milliseconds buys 88%. Nine buys 96%. Alibaba took the trade: online A/B testing of COLD against the vector-product model returned +6.1% CTR and +6.5% RPM on normal days, and +9.1% CTR and +10.8% RPM during the Double 11 event.
Latency savings are the easy number to produce. The pruning cost is the one nobody volunteers. The 88% and the 96% are that second number, and a stage proposal carrying only the first is not yet a proposal.
Key takeaways
- Multi-stage systems succeed when each approximation protects the choices reserved for the next stage. The 2011 cascade was 32.7%, 48.7% and 34.7% faster than the monolithic AdaRank baseline on Wt10g, Gov2 and Clue, at effectiveness its authors call “similar (and many times slightly better)”.
- Large systems progressively reduce candidates through retrieval, filtering, pre-ranking, ranking, and re-ranking. Taobao's cascade generates around 10^5 candidates before two ranking stages, and Alibaba's display advertising pre-ranker takes a set of order ten thousand down to several hundred within 10–20 milliseconds.
- The first stage that removes an item owns an irreversible decision for every stage that follows: on Clue's 50,220,423 documents, stage 1 filtered 97.7% at a filter loss of 0.09%, and no later stage ever saw what that 0.09% contained.
- Retrieval is judged by what it fails to keep, which is why Facebook Search measures recall@K by running KNN search over the whole index for 10,000 sampled search sessions — the measure that showed unified embeddings gaining +18% recall for events search and +16% for groups search.
- Recall cliff remains a practical risk, and top-k recall against the downstream ranker is how it acquires a number: Alibaba's 2 ms two-tower pre-ranker retained 88% of the ranking model's winners against COLD's 96% at 9.3 ms.
- Logging the reason, score, threshold, source, and stage behind every discarded candidate is what makes a bad cut diagnosable once the slate has already shipped. Otherwise “the ninety videos that were never served may not have associated labels and therefore may never appear in the training data”, and the cut disappears from the evidence as well as from the dashboard.