Inferensys

Glossary

Normalized Discounted Cumulative Gain (NDCG)

Normalized Discounted Cumulative Gain (NDCG) is a standard metric for evaluating ranking systems that accounts for the graded relevance of items and their positions in the ranked list, giving higher weight to relevant items placed near the top.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
RERANKING EVALUATION METRIC

What is Normalized Discounted Cumulative Gain (NDCG)?

A standard metric for evaluating ranking systems that accounts for the graded relevance of items and their positions in the ranked list, giving higher weight to relevant items placed near the top.

Normalized Discounted Cumulative Gain (NDCG) is a listwise evaluation metric for ranking systems that measures the quality of an ordered list based on the graded relevance of each item and a logarithmic discount for lower positions. It is the standard metric for tasks where relevance is not binary, such as information retrieval and recommendation systems. The core principle is that highly relevant items contribute more to the score, but their contribution diminishes logarithmically the further down the ranked list they appear, reflecting real user behavior.

The calculation involves first computing the Discounted Cumulative Gain (DCG), which sums the relevance scores of items while applying a position-based discount. This raw DCG is then normalized by the Ideal DCG (IDCG), the maximum possible DCG achievable with a perfect ranking. The resulting NDCG score ranges from 0.0 to 1.0, where 1.0 represents an ideal ranking. This normalization allows for fair comparison across different queries and datasets with varying numbers of relevant items.

EVALUATION METRIC

Key Characteristics of NDCG

Normalized Discounted Cumulative Gain (NDCG) is the standard metric for evaluating ranking systems where relevance is graded, not binary. It accounts for both the degree of relevance and the position of each item in the ranked list.

01

Graded Relevance

Unlike metrics such as Mean Average Precision (MAP) that treat relevance as binary (relevant/not relevant), NDCG operates on graded relevance scores. Each item in the ranked list is assigned a relevance label (e.g., 0=irrelevant, 1=somewhat relevant, 2=highly relevant, 3=perfectly relevant). This allows NDCG to measure the quality of a ranking more finely by rewarding systems that place highly relevant items at the top, not just any relevant item.

02

Positional Discounting

NDCG incorporates a logarithmic discount factor that reduces the gain (relevance score) of an item based on its rank position. The core formula is: gain / log2(rank + 1). This reflects the user experience principle that items lower in a list are less likely to be seen or clicked. A highly relevant document at position 1 contributes its full gain, while the same document at position 10 contributes only a fraction. This forces the metric to prioritize precision at the top of the list.

03

Cumulative Gain & Ideal Ordering

Discounted Cumulative Gain (DCG) is the sum of the discounted gains up to a given rank p. However, DCG values are not comparable across different queries, as some queries have more relevant items than others. NDCG solves this by normalizing the DCG by the Ideal DCG (IDCG). The IDCG is the maximum possible DCG achievable when all items are sorted in perfect descending order of relevance. NDCG@k = DCG@k / IDCG@k. This yields a score between 0.0 and 1.0, where 1.0 represents a perfect ranking.

04

Primary Use Case: Reranking Evaluation

NDCG is the de facto standard for evaluating reranking models in multi-stage retrieval pipelines (e.g., cross-encoder rerankers). It is the primary metric reported on benchmarks like MS MARCO and BEIR. When a fast retriever (e.g., BM25, bi-encoder) fetches an initial candidate set, the reranker's job is to reorder it. NDCG@10 or NDCG@100 precisely measures how well the reranker places the most relevant passages at the top of this refined list, directly impacting the quality of downstream tasks like Retrieval-Augmented Generation (RAG).

05

Comparison to MRR and MAP

NDCG differs fundamentally from other ranking metrics:

  • Mean Reciprocal Rank (MRR): Only considers the rank of the first relevant item. It is useful for tasks like question answering where a single correct answer exists, but fails for queries with multiple relevant documents.
  • Mean Average Precision (MAP): Averages precision at each rank where a relevant item is found, but treats relevance as binary. It cannot distinguish between placing a 'perfect' document vs. a 'good' document at the top. NDCG's strength is its sensitivity to graded relevance and entire list ordering.
06

Practical Calculation & Interpretation

To calculate NDCG for a system:

  1. For each query, produce a ranked list and assign graded relevance scores to each item (from human judgments or a test set).
  2. Calculate DCG@k: Sum (relevance_score_i) / log2(rank_i + 1) for i = 1 to k.
  3. Calculate IDCG@k: Sort items by true relevance descending, and compute DCG on this ideal list.
  4. Compute NDCG@k = DCG@k / IDCG@k.
  5. Average NDCG scores across all queries in the evaluation set. A score of 0.7+ is typically considered strong, but this is highly domain-dependent. The metric is most informative when comparing the relative performance of different ranking models (e.g., bi-encoder vs. cross-encoder) on the same test set.
RERANKING EVALUATION COMPARISON

NDCG vs. Other Ranking Metrics

A technical comparison of Normalized Discounted Cumulative Gain (NDCG) against other standard metrics for evaluating ranking and reranking systems, focusing on their properties, use cases, and limitations.

MetricNormalized Discounted Cumulative Gain (NDCG)Mean Reciprocal Rank (MRR)Precision@KMean Average Precision (MAP)

Core Definition

Measures ranking quality using graded relevance scores, applying a logarithmic position discount.

Averages the reciprocal rank of the first relevant item for each query.

Measures the proportion of relevant items in the top K retrieved positions.

Averages the precision values at each rank where a relevant document is retrieved, across all queries.

Handles Graded Relevance

Accounts for Rank Position

Evaluation Scope

Listwise (full ranked list)

Rank of first hit

Fixed cutoff (K)

Listwise (interpolated)

Typical Use Case

Evaluating rerankers & Learning-to-Rank (LTR) systems where relevance is not binary.

Question Answering, fact retrieval where only one correct answer exists.

Web search, ensuring top results are relevant.

Classic information retrieval benchmarking, especially with binary relevance.

Primary Weakness

Requires defining an ideal DCG (IDCG) for normalization, which can be ambiguous.

Ignores any relevant items beyond the first one.

Does not consider the order of items within the top K.

Assumes binary relevance; poorly handles graded relevance scales.

Common Value Range

0.0 to 1.0

0.0 to 1.0

0.0 to 1.0

0.0 to 1.0

Computational Sensitivity

High sensitivity to top-ranked items due to discount factor.

Extreme sensitivity to the rank of a single item.

Sensitive only to presence/absence within cutoff K.

Sensitive to the entire ranking of all relevant items.

APPLICATIONS

Where is NDCG Used?

Normalized Discounted Cumulative Gain (NDCG) is the industry-standard metric for evaluating ranking systems where relevance is graded, not binary. It is critical for quantifying improvements in search, recommendation, and retrieval pipelines.

01

Information Retrieval & Search Engines

NDCG is the primary metric for evaluating the effectiveness of web search, enterprise search, and document retrieval systems. It measures how well a search engine orders results by their graded relevance (e.g., highly relevant, somewhat relevant, not relevant).

  • Core Benchmark: Used to rank systems on academic benchmarks like MS MARCO and BEIR.
  • A/B Testing: Compares new retrieval algorithms (e.g., dense vs. sparse retrieval, cross-encoder rerankers) against baselines in production.
  • Query Understanding: Evaluates the impact of query expansion, spelling correction, and semantic parsing on result quality.
02

Recommender Systems

In platforms like Netflix, Amazon, and Spotify, NDCG evaluates the quality of ranked recommendation lists. It assesses whether highly engaging items (movies, products, songs) are placed at the top of a user's feed.

  • Personalization: Measures the performance of collaborative filtering and content-based filtering models.
  • Multi-Objective Ranking: Evaluates lists that balance relevance with diversity, novelty, or business constraints.
  • Session-Based Recommendations: Used in scenarios where the goal is to rank items for a single user session or interaction.
03

Learning to Rank (LTR) Model Development

NDCG is the central optimization target and evaluation metric for Learning to Rank models. These machine learning models are trained specifically to produce optimal rankings.

  • Loss Functions: LambdaRank and ListNet directly optimize for NDCG during training.
  • Model Comparison: Used to compare pointwise, pairwise, and listwise LTR approaches.
  • Hyperparameter Tuning: Guides the tuning of model architectures and training parameters to maximize ranking quality.
04

RAG & Cross-Encoder Reranking Evaluation

In Retrieval-Augmented Generation (RAG) pipelines, NDCG evaluates the retrieval stage's ability to surface the most relevant context passages for a large language model. It is critical for assessing reranking models.

  • Reranker Performance: Quantifies the improvement a cross-encoder reranker provides over a first-stage retriever (e.g., BM25 or a bi-encoder).
  • Pipeline Optimization: Helps determine the optimal reranking depth (k) by trading off NDCG gain against increased latency.
  • Hallucination Reduction: Higher NDCG scores correlate with more factual generator outputs by ensuring top-ranked context is highly relevant.
05

E-Commerce & Product Search

E-commerce platforms use NDCG to evaluate product search result pages, where relevance is graded based on user behavior signals like clicks, purchases, and dwell time.

  • Merchandising: Tests the impact of promotional placements or sponsored products on overall list utility.
  • Attribute Filtering: Evaluates how well faceted search (filtering by size, brand, price) maintains ranking quality.
  • Visual Search: Measures the performance of image-based retrieval systems in returning semantically similar products.
06

Academic Research & Benchmarking

NDCG is the standard reporting metric in information retrieval, machine learning, and natural language processing research publications. It provides a consistent, interpretable measure for comparing novel algorithms.

  • Paper Baselines: New retrieval architectures (e.g., ColBERT, SPLADE) are validated by reporting NDCG@5, NDCG@10 on standard datasets.
  • Zero-Shot Generalization: Benchmarks like BEIR use NDCG to evaluate how well models perform on unseen tasks and domains.
  • Reproducibility: Serves as a key result for replicating and verifying published research findings.
RERANKING METRICS

Frequently Asked Questions

Essential questions and answers about Normalized Discounted Cumulative Gain (NDCG), the standard metric for evaluating ranking systems in information retrieval and RAG pipelines.

Normalized Discounted Cumulative Gain (NDCG) is a standard evaluation metric for ranking systems that measures the quality of a ranked list by accounting for both the graded relevance of each item and its position in the list, with higher weight given to relevant items placed near the top.

It works by first calculating Discounted Cumulative Gain (DCG), which sums the relevance scores of all items in the list, applying a logarithmic discount factor that reduces the contribution of items lower in the ranking. The formula is: DCG@k = Σ (relevance_i / log2(i + 1)) for positions i=1 to k. NDCG then normalizes this score by dividing by the Ideal DCG (IDCG), which is the maximum possible DCG achievable with a perfect ranking of the same items. This yields a score between 0 and 1, where 1 represents a perfect ranking.

NDCG is the industry standard because it directly aligns with user experience: users care most about finding highly relevant results on the first page. It is the primary metric used in academic benchmarks like MS MARCO and BEIR for evaluating retrievers and rerankers.

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.