TL;DR

Ranking is about the order—not the isolated score.

The short guide to RankNet, LambdaRank, and ListNet.

The core idea

A ranking model turns a query and a group of candidates into an ordered list.

That pattern powers search, recommendations, ecommerce, job matching, and RAG reranking.

Three approaches

The training unit changes the ranking behaviour.

One documentPointwise

Predict a relevance score independently for each document.

Two documents · same queryPairwise

Learn that document i should rank above document j.

One query groupListwise

Learn from the ordering of the complete candidate list.

RankNet

RankNet learns preferences between pairs.

σ

P(i > j) = σ(score_i − score_j)

1
ScoreReturn raw scores for both documents.
2
CompareUse the score difference as the pairwise logit.
3
TrainApply BCEWithLogitsLoss to the preference label.
LambdaRank

LambdaRank makes the update metric-aware.

It keeps pairwise learning, then weights each correction by the predicted change in NDCG. A swap near rank 1 matters more than the same swap near rank 20.

ListNet

ListNet learns from the whole query group.

RankNetSampled pairs

Learns that one document should beat another.

ListNetComplete list

Turns scores and relevance labels into distributions over the documents.

Choose your metric

Evaluate the ranking behaviour people actually experience.

Graded relevanceNDCG@k

Use when relevance is graded and top positions matter.

One correct answerMRR

Use when users usually need the first relevant result.

Multiple relevant resultsMAP

Use when several relevant documents per query matter.

Final takeaway

RankNet learns which pair wins. LambdaRank learns which correction matters. ListNet learns from the list.

Start with NDCG@k when graded relevance and top positions define success.