Normalized Discounted Cumulative Gain (NDCG) is a listwise ranking evaluation metric that quantifies ranking quality by comparing a system's ranked output to an ideal ordering. It operates on graded relevance judgments, where documents are assigned multi-level relevance scores rather than binary labels. The metric computes Cumulative Gain (CG) by summing relevance scores across positions, then applies a logarithmic discount to penalize relevant documents appearing lower in the ranking. This discounted cumulative gain is normalized by dividing by the Ideal DCG (IDCG)—the maximum possible DCG achievable by perfectly ordering documents—producing a score between 0 and 1.
Glossary
Normalized Discounted Cumulative Gain (NDCG)

What is Normalized Discounted Cumulative Gain (NDCG)?
Normalized Discounted Cumulative Gain (NDCG) is a listwise ranking evaluation metric that measures the quality of a ranked list by discounting relevance gains logarithmically by position and normalizing the score against an ideal ranking.
NDCG is the standard evaluation metric for learning-to-rank (LTR) systems, including algorithms like LambdaMART which directly optimize for NDCG using gradient-based methods. The metric's logarithmic discount function reflects user behavior models where searchers are exponentially less likely to examine lower-ranked results. Variants include NDCG@k, which truncates evaluation at rank position k to emphasize top-ranked precision, making it particularly relevant for modern retrieval-augmented generation pipelines where only the highest-scoring documents are passed to the generation phase.
Key Characteristics of NDCG
Normalized Discounted Cumulative Gain (NDCG) is a listwise metric that evaluates ranking quality by accounting for both the relevance of documents and their positions in the ranked list. It applies a logarithmic discount to penalize relevant documents appearing lower in the ranking and normalizes the score against an ideal ordering.
Position-Aware Discounting
NDCG applies a logarithmic discount to relevance gains based on rank position. The gain for a document at position p is divided by log₂(p+1). This models user behavior where searchers are exponentially less likely to examine documents deeper in the list. A highly relevant document at rank 1 contributes full value, while the same document at rank 10 contributes roughly 30% of its original gain. This discounting mechanism makes NDCG more realistic than precision-based metrics that treat all positions equally.
Graded Relevance Judgments
Unlike binary relevance metrics, NDCG supports multi-level graded relevance scores. Relevance judgments can be assigned on an ordinal scale—such as 0 (irrelevant), 1 (tangentially relevant), 2 (relevant), 3 (highly relevant), and 4 (perfectly relevant). This granularity allows evaluators to distinguish between marginally useful documents and authoritative sources. The cumulative gain at each rank position sums these graded scores, enabling nuanced evaluation that rewards search systems for surfacing the most authoritative content at the top.
Ideal DCG Normalization
The 'N' in NDCG comes from dividing the achieved Discounted Cumulative Gain (DCG) by the Ideal DCG (IDCG)—the DCG of a perfect ranking where documents are sorted in descending order of relevance. This normalization produces a score between 0 and 1, making NDCG comparable across queries with different numbers of relevant documents. A score of 1.0 indicates the system returned the optimal ordering. Without normalization, DCG scores would be query-length dependent and impossible to average across a test set.
Cutoff-Based Variants
NDCG is commonly reported at specific rank cutoffs, denoted as NDCG@k where k represents the truncation depth. Common variants include:
- NDCG@5: Evaluates the top 5 results, emphasizing above-the-fold performance
- NDCG@10: Standard cutoff for web search evaluation, representing the first page of results
- NDCG@20: Used when recall-oriented evaluation is needed Choosing the appropriate k depends on the use case—question-answering systems may prioritize NDCG@1, while exploratory search interfaces benefit from higher cutoffs.
Exponential Gain Formulation
To emphasize highly relevant documents, NDCG often uses an exponential gain function: gain = 2^rel - 1, where rel is the graded relevance score. This formulation creates a non-linear reward structure where a document with relevance 4 contributes gain of 15, while relevance 2 contributes only 3. The exponential scaling ensures that search systems are strongly incentivized to place the most authoritative documents at the top, rather than being satisfied with moderately relevant results in prominent positions.
Comparison with MRR and MAP
NDCG differs from other ranking metrics in key ways:
- MRR (Mean Reciprocal Rank): Only considers the position of the first relevant document, ignoring subsequent results and graded relevance
- MAP (Mean Average Precision): Uses binary relevance and weights precision equally across positions without logarithmic discounting
- NDCG: Combines graded relevance, position discounting, and ideal normalization, making it the preferred metric when relevance judgments exist on a multi-level scale and ranking order matters throughout the entire list
NDCG vs. Other Ranking Metrics
A comparative analysis of NDCG against other common evaluation metrics used to measure ranking quality in information retrieval and recommendation systems.
| Feature | NDCG | MRR | Precision@K | MAP |
|---|---|---|---|---|
Metric Type | Listwise (graded) | Pointwise (binary) | Pointwise (binary) | Listwise (binary) |
Handles Graded Relevance | ||||
Position-Aware | ||||
Normalized Across Queries | ||||
Sensitive to Total Relevant Docs | ||||
Penalizes Low-Ranked Relevant Docs | ||||
Ideal for Multi-Level Judgments | ||||
Computational Complexity | O(n log n) | O(n) | O(n) | O(n log n) |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about Normalized Discounted Cumulative Gain, the gold-standard metric for evaluating ranking quality in search and recommendation systems.
Normalized Discounted Cumulative Gain (NDCG) is a listwise ranking evaluation metric that measures the quality of a ranked list by comparing it against an ideal ordering. It works by first computing the Discounted Cumulative Gain (DCG), which sums the graded relevance scores of documents in a result list, applying a logarithmic discount factor that penalizes relevant documents appearing lower in the ranking. This DCG value is then normalized by dividing it by the Ideal DCG (IDCG)—the DCG of the perfectly ordered list for that query. The resulting NDCG score ranges from 0.0 to 1.0, where 1.0 represents a perfect ranking. Unlike precision-based metrics, NDCG captures the nuanced reality that some documents are more relevant than others and that users strongly prefer highly relevant results at the top of the list.
Related Terms
Master the ecosystem of metrics and models that surround NDCG to build a complete relevance evaluation framework.
Graded Relevance Judgments
NDCG requires multi-level relevance scores, not just binary relevant/not-relevant. Graded relevance assigns ordinal values (e.g., 0-4) to query-document pairs:
- 0: Irrelevant
- 1: Marginally relevant
- 2: Relevant
- 3: Highly relevant
- 4: Perfectly authoritative This granularity allows NDCG to reward systems that place highly relevant documents above merely relevant ones, providing a more nuanced evaluation than precision-based metrics.
Discounted Cumulative Gain (DCG)
The foundational component of NDCG before normalization. DCG sums the relevance scores of documents in a ranked list, applying a logarithmic discount to penalize relevant documents appearing lower:
- Position 1: rel₁
- Position p: relₚ / log₂(p+1) The discount function models user behavior—searchers are exponentially less likely to examine documents deeper in the ranking. DCG captures both relevance magnitude and position quality.
Ideal DCG (IDCG)
The theoretical maximum DCG achievable by sorting all documents in descending order of true relevance. IDCG serves as the normalization factor:
- NDCG = DCG / IDCG
- Produces a score in [0, 1] range
- 1.0 represents a perfect ranking By dividing by IDCG, NDCG becomes query-independent, enabling fair comparison across queries with different numbers of relevant documents. Without this normalization, queries with many relevant documents would dominate aggregate scores.
Mean Reciprocal Rank (MRR)
A complementary metric focused on the first relevant document rather than the entire ranking. MRR averages the reciprocal of the rank position of the earliest relevant result:
- MRR = (1/|Q|) × Σ 1/rankᵢ
- Perfect for navigational queries where users need exactly one answer
- Insensitive to additional relevant documents below the first Use MRR alongside NDCG when evaluating systems where top-position precision is the primary success criterion, such as featured snippets or direct answers.
LambdaMART
A gradient boosted tree algorithm that directly optimizes NDCG using LambdaRank gradients. Key characteristics:
- Listwise approach: Considers the entire ranked list during training
- Lambda gradients: Encodes the cost of swapping document pairs weighted by NDCG delta
- Ensemble of trees: Builds additive regression trees with gradient boosting LambdaMART dominated learning-to-rank competitions for years and remains a production baseline. It explicitly targets the metric you care about rather than a proxy loss function.
Position Bias Correction
Click data used for training rankers suffers from position bias—users click top results regardless of relevance. NDCG evaluation with biased judgments produces misleading scores. Correction techniques:
- Propensity weighting: Inverse propensity scoring using randomization experiments
- Click models: Estimating true relevance by modeling examination probability
- Result randomization: Periodically shuffle results to collect unbiased feedback Without bias correction, NDCG measured on implicit feedback will overestimate systems that simply match user click patterns rather than true relevance.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us