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.

Advanced 3 min read · Updated

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

Query / userRetrievalBM25 · ANN · ~1,000Light ranker~1,000 → 200Heavy rankerLTR model · 200 → 50Re-rankdedupe · diversityFeature store
Ranking is the precise stage of a funnel. Retrieval narrows millions of documents to hundreds; a learned ranker orders them with rich features; a final layer applies business rules.

Pointwise, pairwise and listwise

ApproachLearnsLoss examplesPros and cons
PointwiseA score per item independently (click probability, relevance grade)Log loss, MSESimple, calibrated probabilities usable elsewhere; ignores the relative order the user sees
PairwiseWhich of two items for the same query should rank higherRankNet, hinge loss on pairsDirectly targets order; number of pairs grows fast
ListwiseThe best ordering of the whole listLambdaRank / LambdaMART, softmax cross-entropy over the listOptimises 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

GroupSearch examplesRecommendation examples
Query-document matchBM25 score, title match, embedding similarityUser-item embedding similarity
Document qualityAuthority, freshness, spam score, past CTRItem popularity, completion rate, creator quality
UserLanguage, location, past queriesLong-term interests, recent activity
ContextDevice, time, query lengthSurface, time of day, session depth
Interaction historyUser clicked this domain beforeUser 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.

pos 11.00pos 20.63pos 30.50pos 50.39pos 100.29pos 200.23
The NDCG position discount 1 / log2(position + 1). A relevant result at position 1 counts fully; at position 10 it counts less than a third as much, which is why ranking errors at the top matter most.

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

Web and site search

LambdaMART or deep rankers over text-match, quality and behaviour features, evaluated with rater-graded NDCG and interleaving.

E-commerce

Ranking products by predicted purchase probability with relevance, price and availability features.

Feeds

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