Inferensys

Glossary

Normalized Discounted Cumulative Gain (NDCG)

A rank-aware evaluation metric that measures retrieval quality by discounting the gain of a relevant document logarithmically based on its position, normalized against an ideal ranking.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
RANK-AWARE EVALUATION METRIC

What is Normalized Discounted Cumulative Gain (NDCG)?

Normalized Discounted Cumulative Gain (NDCG) is a rank-aware evaluation metric that measures retrieval quality by discounting the gain of a relevant document logarithmically based on its position, normalized against an ideal ranking.

Normalized Discounted Cumulative Gain (NDCG) is a family of metrics that evaluates a ranked list by comparing the actual order of results against an ideal ordering where all relevant documents appear first. Unlike precision-based metrics, NDCG accounts for multi-graded relevance judgments—assigning higher gain scores to highly relevant documents than to marginally relevant ones—and applies a logarithmic discount to penalize relevant items that appear lower in the ranking.

The metric is computed by first calculating the Discounted Cumulative Gain (DCG) at rank position p, then dividing by the Ideal DCG (IDCG)—the DCG of the perfect ranking—to produce a normalized score between 0 and 1. This normalization enables meaningful comparisons across queries with varying numbers of relevant documents, making NDCG the standard evaluation measure for Learning to Rank systems, hybrid search fusion pipelines, and any retrieval architecture where rank position directly impacts user satisfaction.

Rank-Aware Evaluation

Key Characteristics of NDCG

Normalized Discounted Cumulative Gain (NDCG) is the gold standard for evaluating ranking quality in search and recommendation systems. It measures not just whether relevant items were retrieved, but whether they were placed at the top of the list where users are most likely to engage with them.

01

Position-Discounted Gain

NDCG applies a logarithmic discount to the relevance gain of each document based on its rank position. A highly relevant document at position 1 contributes full value, while the same document at position 10 contributes substantially less. This mirrors real user behavior—searchers rarely scroll past the first page.

  • Discount formula: gain / log₂(rank + 1)
  • Position 1: discount factor of 1.0 (no penalty)
  • Position 5: discount factor of ~0.39
  • Position 10: discount factor of ~0.29
  • Models the positional attention decay observed in eye-tracking studies
log₂(rank+1)
Discount Function
02

Ideal DCG Normalization

The 'N' in NDCG stands for normalization against an ideal ranking. The system's actual DCG score is divided by the Ideal DCG (IDCG)—the score achieved by a perfect ranking where all documents are sorted in descending order of relevance. This produces a value between 0.0 and 1.0, making scores comparable across queries with different numbers of relevant documents.

  • NDCG = DCG / IDCG
  • A score of 1.0 indicates a perfect ranking
  • Normalization enables cross-query averaging
  • Prevents queries with many relevant documents from dominating aggregate metrics
03

Graded Relevance Judgments

Unlike binary metrics (relevant/not relevant), NDCG supports multi-level relevance grades. Documents can be labeled on a scale—such as 0 (irrelevant), 1 (tangentially relevant), 2 (relevant), 3 (highly relevant), or 4 (perfectly relevant). This granularity rewards systems that prioritize the most authoritative or comprehensive results.

  • Binary relevance: 0 or 1 (simplified NDCG)
  • Graded relevance: 0–4 scale common in benchmark datasets
  • Higher grades receive exponentially more gain weight
  • Used extensively in MS MARCO and TREC evaluation campaigns
  • Captures the nuance that some relevant documents are better than others
04

NDCG@K: Cutoff Evaluation

NDCG is almost always computed at a specific cutoff depth K, written as NDCG@K. Common values are NDCG@5, NDCG@10, and NDCG@20. This focuses evaluation on the top results that users actually see, rather than the entire ranked list. NDCG@10 is the most widely reported metric in academic information retrieval literature.

  • NDCG@10: Evaluates the first page of results
  • NDCG@5: Stricter metric for mobile or voice search interfaces
  • NDCG@100: Used for recall-oriented evaluation
  • Choosing K should align with your application's user interface constraints
05

Cumulative Gain Aggregation

The 'C' in DCG stands for cumulative—the metric sums the discounted gain across all positions up to rank K. This means a system is rewarded for every relevant document it retrieves, not just the first one. Unlike Mean Reciprocal Rank (MRR), which only cares about the first relevant result, NDCG captures the full quality of the ranked list.

  • DCG@K = Σ(gainᵢ / log₂(i + 1)) for i = 1 to K
  • Rewards systems that surface multiple relevant items
  • Contrasts with MRR, which only evaluates the first hit
  • Better suited for exploratory search where users examine multiple results
06

Exponential Gain Scaling

To strongly reward highly relevant documents, NDCG often applies exponential gain scaling: gain = 2^relevance - 1. A document with relevance grade 4 receives a gain of 15, while grade 1 receives only 1. This creates a strong incentive for ranking systems to place the most authoritative documents at the very top.

  • Linear gain: gain = relevance (less common)
  • Exponential gain: gain = 2^relevance - 1 (standard)
  • Grade 0 → gain 0, Grade 1 → gain 1, Grade 3 → gain 7, Grade 4 → gain 15
  • Places heavy penalty on mis-ranking highly relevant documents
  • Aligns with business metrics where top positions drive most engagement
EVALUATION METRIC COMPARISON

NDCG vs. Other Ranking Metrics

A comparison of Normalized Discounted Cumulative Gain against other common retrieval and ranking evaluation metrics, highlighting their sensitivity to rank position, graded relevance, and normalization properties.

FeatureNDCGMRRPrecision@KMAP

Rank Position Sensitivity

Logarithmic discount

Reciprocal discount

Binary (avg precision)

Graded Relevance Support

Normalized Score Range

[0, 1]

[0, 1]

[0, 1]

[0, 1]

Multiple Relevant Docs

Ideal Ranking Baseline

Query Difficulty Agnostic

Primary Use Case

Graded relevance with position importance

First relevant document rank

Top-K set quality

Binary relevance with rank

METRICS & EVALUATION

Frequently Asked Questions

Clear answers to common questions about Normalized Discounted Cumulative Gain (NDCG), the rank-aware metric that evaluates retrieval and recommendation quality by penalizing relevant documents that appear lower in a result list.

Normalized Discounted Cumulative Gain (NDCG) is a rank-aware evaluation metric that measures the quality of a ranked list of results by comparing it against an ideal ordering. It works by assigning a gain (relevance score) to each document, applying a logarithmic discount based on its position to penalize relevant items appearing lower in the list, summing these discounted gains cumulatively, and then normalizing the result by dividing by the ideal DCG (IDCG) of a perfectly ranked list. This normalization produces a score between 0.0 and 1.0, where 1.0 represents a perfect ranking. Unlike precision-based metrics, NDCG explicitly rewards systems that place highly relevant documents at the top of the results.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.