Course contentsShow
← System Design
Lesson 1756 of 1,91942. Real-World System: Search and TypeaheadFree lesson

Machine Learning for Ranking (Learning to Rank)

Using supervised ML models trained on click data to optimize ranking beyond hand-tuned formulas.

Machine Learning for Ranking (Learning to Rank)

You'll learn: How supervised ML models replace hand-tuned ranking formulas by learning optimal ranking from historical user behavior.

Beyond Manual Scoring

While BM25 and TF-IDF provide solid baseline relevance scores, real-world search quality improves dramatically when you learn what users actually click and engage with. Learning to Rank (LTR) uses supervised machine learning to train models on historical click data, optimizing for the ranking order that maximizes user satisfaction rather than adhering to fixed mathematical formulas.

How It Works

The key insight: treat ranking as a supervised learning problem. You collect training data from past searches:

  • Query: user's search terms
  • Documents: candidate results shown
  • Features: hundreds of signals per query-document pair (BM25 score, page authority, freshness, click-through rate, dwell time, etc.)
  • Label: ground truth relevance (explicit ratings or implicit signals like clicks, engagement)

Models learn to predict relevance scores by combining these features in ways that correlate with actual user behavior. Popular approaches include pointwise (predicting absolute relevance), pairwise (learning relative order between document pairs), and listwise (optimizing the entire result list).

Why This Matters

Hand-tuned formulas require expert guesswork about feature weights. ML models discover patterns in data: perhaps for product searches, recency matters more; for academic queries, citation count dominates. The model adapts automatically as user behavior evolves, and you can A/B test model versions against each other using live traffic.

Training happens offline on batch data, but inference runs online for every query—the model scores each candidate document in milliseconds.

Key Takeaway:
Learning to Rank replaces manual scoring heuristics with ML models trained on user interaction data, enabling search systems to discover optimal ranking strategies that actually reflect user preferences.