Inferensys

Glossary

Normalized Discounted Cumulative Gain (NDCG)

Normalized Discounted Cumulative Gain (NDCG) is an evaluation metric that measures the ranking quality of search results by giving higher weight to relevant documents appearing at the top of the list, normalized against an ideal ranking.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
RANKING QUALITY METRIC

What is Normalized Discounted Cumulative Gain (NDCG)?

Normalized Discounted Cumulative Gain (NDCG) is an evaluation metric that measures the ranking quality of search results by giving higher weight to relevant documents appearing at the top of the list, normalized for ideal ranking.

Normalized Discounted Cumulative Gain (NDCG) is an evaluation metric that measures the ranking quality of search results by giving higher weight to relevant documents appearing at the top of the list, normalized for ideal ranking. It extends the simpler Cumulative Gain (CG) metric by introducing a position-based discount factor, acknowledging that a highly relevant document at rank 1 is far more valuable than one at rank 10. The 'normalized' component divides the achieved Discounted Cumulative Gain (DCG) by the Ideal DCG (IDCG)—the DCG of a perfect ranking—producing a score between 0 and 1 that allows for meaningful comparison across different queries and result sets.

The metric relies on graded relevance judgments, where each document is assigned a relevance score (e.g., 0 for irrelevant, 3 for perfectly relevant), rather than a simple binary relevant/not-relevant label. The discount is typically applied logarithmically, reducing the contribution of documents as the rank position increases. NDCG is a cornerstone metric in information retrieval, widely used to evaluate the performance of learning-to-rank models, recommendation systems, and semantic search pipelines where the order of returned results is critical to user satisfaction and task success.

Ranking Quality Evaluation

Core Characteristics of NDCG

Normalized Discounted Cumulative Gain (NDCG) is the industry-standard metric for evaluating ranking quality in information retrieval systems. It measures how well a system orders results by prioritizing relevant documents at the top positions while penalizing relevant items buried deep in the list.

01

Position-Discounted Gain

NDCG applies a logarithmic discount function to reduce the contribution of relevant documents as their rank position increases. A highly relevant document at position 1 contributes its full gain, while the same document at position 10 contributes roughly 1/log₂(11) ≈ 30% of its value. This mirrors real user behavior—searchers rarely browse beyond the first page of results. The discount is calculated as 1 / log₂(rank + 1), creating a steep decay curve that heavily rewards top-ranked precision.

02

Graded Relevance Judgments

Unlike binary metrics that treat relevance as a simple yes/no, NDCG supports multi-level relevance scales. Documents can be scored on a graded scale such as:

  • 0: Not relevant
  • 1: Marginally relevant
  • 2: Relevant
  • 3: Highly relevant
  • 4: Perfectly relevant This granularity allows the metric to distinguish between a system that returns 'good enough' results versus one that surfaces the definitive, authoritative answer for a query.
03

Ideal DCG Normalization

The 'Normalized' component divides the system's DCG by the Ideal DCG (IDCG)—the score achieved by a perfect ranking where all documents are sorted in descending order of relevance. This normalization produces a value between 0.0 and 1.0, making NDCG comparable across queries with different numbers of relevant documents. A score of 1.0 indicates the system returned results in the optimal order. Without normalization, comparing DCG across queries of varying difficulty would be meaningless.

04

Cutoff-Based Evaluation

NDCG is typically reported at specific rank cutoffs, written as NDCG@k where k represents the number of top results evaluated. Common values include:

  • NDCG@5: Measures the quality of results visible without scrolling on mobile
  • NDCG@10: Evaluates the first page of results
  • NDCG@100: Assesses deep ranking quality for recall-oriented tasks This cutoff specificity allows engineers to optimize for different use cases—a voice assistant might prioritize NDCG@1, while a legal discovery system cares about NDCG@100.
05

Cumulative Gain Foundation

The metric builds on Cumulative Gain (CG), which is simply the sum of relevance scores across all retrieved documents. Discounted Cumulative Gain (DCG) extends this by applying the position discount, calculated as: DCG = Σ (2^relevance - 1) / log₂(rank + 1). The exponential gain function 2^relevance - 1 ensures that highly relevant documents contribute disproportionately more value—a document with relevance 4 contributes 15 times the gain of a document with relevance 1, emphasizing the premium on surfacing the best content first.

06

Handling Missing Judgments

In large-scale evaluation, human annotators cannot judge every document for every query. NDCG implementations must handle unjudged documents carefully. Common strategies include:

  • Treating unjudged as irrelevant (0): Conservative approach that may unfairly penalize systems
  • Ignoring unjudged documents: Removes them from the calculation entirely
  • Inferred relevance: Using click-through data or model predictions as proxy judgments The choice of strategy significantly impacts reported scores and must be documented in any rigorous evaluation framework.
METRIC COMPARISON

NDCG vs. Other Ranking Metrics

A comparative analysis of Normalized Discounted Cumulative Gain against other common information retrieval evaluation metrics, highlighting their distinct mechanisms, sensitivity to position, and handling of graded relevance.

FeatureNDCGPrecision@kMAPMRR

Handles Graded Relevance

Position-Aware Discounting

Normalized Across Queries

Primary Use Case

Multi-level relevance judgments

Binary relevance in top-k

Ranked retrieval with binary labels

First relevant result position

Sensitivity to Top Positions

High (logarithmic discount)

None (uniform weight in set)

Moderate (average precision)

Very High (reciprocal rank)

Ideal Ranking Baseline

Typical Range

0.0 to 1.0

0.0 to 1.0

0.0 to 1.0

0.0 to 1.0

RANKING METRICS

Frequently Asked Questions

Clear, technical answers to the most common questions about Normalized Discounted Cumulative Gain (NDCG), the standard metric for evaluating ranking quality in information retrieval and recommendation systems.

Normalized Discounted Cumulative Gain (NDCG) is an evaluation metric that measures the quality of a ranked list of results by comparing the actual order against an ideal ordering. It works by assigning a relevance score to each document, applying a logarithmic discount to penalize relevant documents appearing lower in the list, and then normalizing the result against the Ideal DCG (IDCG)—the score achieved by a perfect ranking. The formula is NDCG@k = DCG@k / IDCG@k, where k represents the cutoff position. This normalization ensures scores fall between 0.0 and 1.0, making NDCG comparable across different queries with varying numbers of relevant results. Unlike precision-based metrics, NDCG captures graded relevance (e.g., "perfect," "good," "fair") rather than binary judgments, making it the preferred metric for modern search engines and recommendation systems where relevance exists on a spectrum.

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.