Skip to content
BIASED

Learning to rank

Block 1 of 8~3 min

An order, not a label

The topic Anomaly detection ended with a score for every point and an analyst who reads the list from the top. Only the order of the scores mattered there: a detector is useful if the true anomalies come first, and nobody reads the thousandth line. That was already a ranking problem, solved without labels. This topic adds labels. A search engine, a product catalogue and a news feed all return an ordered list, and people judge the list by its top. The answer is an order, not a label.

Ranking data are grouped. A query qq comes with nn candidate documents, usually a few hundred that a cheap first stage picked out of millions. Document ii has a feature vector xi∈Rdx_i \in \mathbb R^d that describes the pair (query, document). An assessor who read both gives it a graded relevance label yi∈{0,1,2,3,4}y_i \in \{0, 1, 2, 3, 4\}, from irrelevant to perfect. Binary relevance, yi∈{0,1}y_i \in \{0, 1\}, is the special case. A model gives each document a score si=f(xi)s_i = f(x_i), and the ranking sorts the documents by decreasing score. We write y(j)y_{(j)} for the label of the document in position jj.

The features come in three kinds:

  • Query features depend only on the query: its length, its frequency in the logs. They are the same for every document of the query.
  • Document features depend only on the document: its length, its freshness, its link-based importance such as PageRank, the stationary distribution of a random surfer from the topic Markov chains.
  • Query–document features measure the match: a text-matching score such as BM25, the cosine between embeddings, the share of query words in the title.

Orders are compared only within a query. Whether a page about the jaguar the animal should come before one about Jaguar the car depends on what was asked. So adding a constant to all scores of one query changes nothing, and scores mean something only up to a shift per query.

Two practical rules follow. Validation splits by query, never by row: this is the group split of the topic Validation and overfitting, and documents of one query on both sides would be the train–test contamination of Data, features and leakage. And a learned ranker is usually the second stage of a cascade. A fast retriever narrows millions of documents to hundreds, and the ranker orders those.

Answers are saved on the server and tied to this browser until you sign in.