Learning to Rank: Pointwise, Pairwise and Listwise Ranking Models
Learning to rank for search and recommendations: pointwise, pairwise and listwise losses, LambdaMART, ranking features, NDCG and serving a multi-stage ranker.
Learning to rank (LTR) trains a model to order a list of candidates, such as search results, feed posts or products, so the most relevant come first. It sits after candidate retrieval in every search and recommendation system. The key choices are the training approach (pointwise, pairwise or listwise), the labels, the features, and the metric, usually NDCG.
Where ranking sits
Pointwise, pairwise and listwise
| Approach | Learns | Loss examples | Pros and cons |
|---|---|---|---|
| Pointwise | A score per item independently (click probability, relevance grade) | Log loss, MSE | Simple, calibrated probabilities usable elsewhere; ignores the relative order the user sees |
| Pairwise | Which of two items for the same query should rank higher | RankNet, hinge loss on pairs | Directly targets order; number of pairs grows fast |
| Listwise | The best ordering of the whole list | LambdaRank / LambdaMART, softmax cross-entropy over the list | Optimises ranking metrics like NDCG most closely; more complex |
In practice: pointwise is the usual first model and is required when scores feed something that needs probabilities (an ad auction, a multi-objective blend). LambdaMART, gradient-boosted trees with a listwise objective, is a long-standing strong choice for search ranking with dense features. Deep rankers often use pointwise multi-task heads with a listwise term.
Pairwise idea (RankNet): for documents i, j of the same query,
P(i ranked above j) = sigmoid(s_i − s_j)
loss = −[ y_ij · log P + (1 − y_ij) · log(1 − P) ]
LambdaRank: scale each pair's gradient by |Δ NDCG| from swapping i and j,
so mistakes near the top of the list cost far more than near the bottom.Labels for ranking
- Human relevance grades: raters score query-document pairs (for example 0 to 4). High quality, expensive, needed for evaluation sets.
- Implicit feedback: clicks, dwell time, purchases, skips. Plentiful but biased by position; see feedback loops.
- Graded implicit labels: combine signals into levels, such as 0 = shown, 1 = clicked, 2 = dwelled 30 s, 3 = purchased.
- Negatives: shown-but-skipped items are better negatives than random ones, but correct for position.
Ranking features
| Group | Search examples | Recommendation examples |
|---|---|---|
| Query-document match | BM25 score, title match, embedding similarity | User-item embedding similarity |
| Document quality | Authority, freshness, spam score, past CTR | Item popularity, completion rate, creator quality |
| User | Language, location, past queries | Long-term interests, recent activity |
| Context | Device, time, query length | Surface, time of day, session depth |
| Interaction history | User clicked this domain before | User follows this creator |
Evaluating rankers
Ranking metrics reward getting the top positions right. NDCG@k discounts gains logarithmically by position and normalises by the ideal ordering; MRR looks at the first relevant result; recall@k matters for retrieval stages. See ML evaluation.
Offline wins must be confirmed online. Interleaving (mixing results from two rankers in one list and seeing which side gets clicked) detects differences with far less traffic than an A/B test, and is common in search.
Serving a ranker
- Score candidates in a batch, one model call per request rather than per item.
- Fetch user features once and item features in bulk; cache hot item features.
- Give each stage a latency budget (for example retrieval 20 ms, light ranker 15 ms, heavy ranker 40 ms) and a fallback ordering if the heavy ranker times out.
- Log the features and scores used, for debugging and for training the next model.
Where it’s used
LambdaMART or deep rankers over text-match, quality and behaviour features, evaluated with rater-graded NDCG and interleaving.
Ranking products by predicted purchase probability with relevance, price and availability features.
Pointwise multi-task rankers whose predicted probabilities are blended into one score.
In an interview
- Place the ranker after retrieval and give candidate counts per stage.
- Choose pointwise, pairwise or listwise and justify it (probabilities needed? metric to optimise?).
- Describe labels, including how you handle position bias in clicks.
- Evaluate with NDCG@k offline and an A/B test or interleaving online.
Frequently asked questions
What is the difference between pointwise, pairwise and listwise ranking?
Pointwise models score each item independently, pairwise models learn which of two items should rank higher, and listwise models optimise the ordering of the whole list, matching ranking metrics like NDCG most closely.
What is NDCG?
Normalized discounted cumulative gain, a ranking metric that rewards relevant results more the higher they appear, discounting by the logarithm of the position and normalising by the ideal ordering.
Further reading
- From RankNet to LambdaRank to LambdaMART: An OverviewChris Burges, Microsoft Research
- Unbiased Learning-to-Rank with Biased FeedbackJoachims et al., WSDM 2017