Normalized Discounted Cumulative Gain (NDCG) is a measure of ranking quality that evaluates a ranked list of results by summing the graded relevance of each document, logarithmically discounted by its position, and then normalizing this score against the maximum possible DCG for that query. Unlike binary metrics, NDCG handles multi-level relevance judgments, making it the standard for evaluating search engines and recommendation systems where some documents are more useful than others.
Glossary
Normalized Discounted Cumulative Gain (NDCG)

What is Normalized Discounted Cumulative Gain (NDCG)?
A metric that measures the ranking quality of search results by giving higher weight to relevant documents appearing earlier in the list, normalized against an ideal ranking.
The calculation involves three core components: Cumulative Gain (CG), the raw sum of relevance scores; Discounted Cumulative Gain (DCG), which penalizes relevant documents that appear lower in the ranking via a logarithmic discount; and the final normalization step, where the achieved DCG is divided by the Ideal DCG (IDCG)—the DCG of a perfectly ordered list. This normalization yields a score between 0 and 1, enabling meaningful comparison across queries with varying numbers of relevant results.
Key Characteristics of NDCG
Normalized Discounted Cumulative Gain (NDCG) is the gold-standard metric for evaluating ranking quality in search and recommendation systems. It measures how well a system orders results by prioritizing highly relevant items at the top while penalizing relevant items buried deep in the list.
Position-Aware Discounting
NDCG applies a logarithmic discount function to penalize relevant documents that appear lower in the ranked list. The discount for position p is typically 1 / log₂(p + 1), meaning a highly relevant document at rank 1 contributes fully, while the same document at rank 10 contributes only about 29% of its original value. This mirrors real user behavior—searchers rarely scroll past the first page of results. The cumulative gain is the sum of these discounted relevance scores across all positions, ensuring the metric rewards systems that front-load the most valuable content.
Ideal Ranking Normalization
The 'Normalized' in NDCG divides the system's DCG score by the Ideal DCG (IDCG)—the DCG achieved by a perfect ranking where all documents are sorted in descending order of relevance. This normalization serves two critical purposes:
- Cross-query comparability: Scores fall between 0.0 and 1.0 regardless of result set size
- Fair evaluation: Queries with many highly relevant documents don't artificially inflate scores An NDCG of 1.0 indicates the system produced the theoretically optimal ordering for that query.
Multi-Graded Relevance Judgments
Unlike binary metrics such as Precision@K, NDCG supports graded relevance labels that capture varying degrees of usefulness. Common grading schemes include:
- 0: Not relevant
- 1: Marginally relevant (tangential topic)
- 2: Relevant (answers the query partially)
- 3: Highly relevant (definitive answer)
- 4: Perfectly relevant (navigational intent, exact match) This granularity allows NDCG to distinguish between a system that returns ten 'marginally relevant' documents versus one that returns three 'highly relevant' ones—a distinction binary metrics completely miss.
Cutoff-Based Evaluation (NDCG@K)
NDCG is commonly computed at specific cutoff points—NDCG@5, NDCG@10, NDCG@20—to evaluate ranking quality within the viewport users actually see. NDCG@10, for instance, only considers the top 10 results, making it the de facto standard for web search evaluation. This cutoff approach acknowledges that users rarely paginate deeply, so ranking quality beyond position 20 has diminishing practical importance. Different applications use different cutoffs: e-commerce product search might optimize for NDCG@5, while academic literature search might use NDCG@20 or higher.
Gain Functions and Exponential Weighting
The 'Gain' component can use either linear gain (gain = relevance_label) or exponential gain (gain = 2^relevance_label - 1). Exponential gain dramatically amplifies the value of highly relevant documents. Under exponential gain, a document with relevance 4 contributes 15 points, while relevance 1 contributes only 1 point—a 15:1 ratio versus 4:1 under linear gain. This is critical for navigational queries where only the single most relevant result matters. The choice of gain function should align with the application's tolerance for partially relevant results.
Relationship to Other Ranking Metrics
NDCG sits within a family of ranking evaluation metrics, each with distinct properties:
- Mean Reciprocal Rank (MRR): Only cares about the position of the first relevant document; ignores all others
- Mean Average Precision (MAP): Uses binary relevance and averages precision at each relevant document's position
- NDCG: Combines graded relevance with position discounting and normalization NDCG is generally preferred over MAP when relevance judgments are graded rather than binary, making it the standard for modern search systems where nuanced relevance distinctions matter.
NDCG vs. Other Ranking Metrics
A comparative analysis of NDCG against other common offline evaluation metrics for ranked retrieval, highlighting their sensitivity to graded relevance and rank position.
| Feature | NDCG | MRR | Precision@K | MAP |
|---|---|---|---|---|
Handles Graded Relevance | ||||
Penalizes Low-Rank Relevant Docs | ||||
Normalized for Query Difficulty | ||||
Sensitive to Total Number of Relevant Docs | ||||
Primary Use Case | Graded relevance ranking | First relevant result | Top-K set quality | Binary relevance ranking |
Score Range | 0.0 to 1.0 | 0.0 to 1.0 | 0.0 to 1.0 | 0.0 to 1.0 |
Computational Complexity | O(n log n) | O(n) | O(k) | O(n log n) |
Ideal For | E-commerce, informational search | Known-item search, Q&A | Recommendation carousels | Ad-hoc retrieval benchmarks |
Frequently Asked Questions
Clear, technical answers to the most common questions about Normalized Discounted Cumulative Gain (NDCG) and its role in evaluating search and recommendation systems.
Normalized Discounted Cumulative Gain (NDCG) is a metric that measures the quality of a ranked list of results by comparing the gain from the system's ranking against the gain from an ideal ranking. It works by first calculating the Cumulative Gain (CG) , which is the sum of relevance scores for all documents in the result set. It then applies a discount function (typically a logarithmic decay) to penalize relevant documents that appear lower in the ranking, producing Discounted Cumulative Gain (DCG) . Finally, this DCG is normalized by dividing it by the Ideal DCG (IDCG) —the DCG of a perfectly ranked list—yielding a score between 0 and 1. This normalization allows for meaningful comparisons across different queries and result sets of varying lengths, making NDCG the standard metric for evaluating graded relevance in search engines and recommender systems.
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.
Related Terms
Understanding NDCG requires familiarity with the broader ecosystem of retrieval evaluation metrics and ranking concepts. These related terms form the foundation of modern search quality measurement.
Mean Reciprocal Rank (MRR)
A metric that evaluates retrieval systems by measuring the rank position of the first relevant document. MRR calculates the average of the reciprocal ranks across a set of queries.
- Formula: MRR = (1/|Q|) * Σ (1/rank_i)
- Focuses exclusively on the first relevant result
- Ignores all subsequent relevant documents in the list
- Best suited for navigational queries where the user needs exactly one correct answer
- Example: If the first relevant doc is at position 3, the reciprocal rank is 1/3 ≈ 0.33
Cumulative Gain (CG)
The foundational precursor to DCG that sums the relevance scores of all documents in a ranked list without any positional discounting. CG treats all positions equally.
- Calculated as the simple sum of graded relevance labels (e.g., 0-3 scale)
- No positional weighting means a relevant doc at rank 10 counts the same as rank 1
- Useful as a baseline before applying discount and normalization
- Limitation: Fails to capture the critical insight that users prefer top-ranked results
Discounted Cumulative Gain (DCG)
The direct predecessor to NDCG that applies a logarithmic discount to relevance scores based on position. Documents appearing later in the ranked list contribute progressively less to the total score.
- Formula: DCG = Σ (rel_i / log₂(i+1))
- The logarithmic discount models user behavior where attention decays with scroll depth
- A highly relevant document at rank 1 contributes its full score
- The same document at rank 10 contributes roughly one-third of its value
- DCG is not normalized, making it impossible to compare across queries with different numbers of relevant documents
Ideal DCG (IDCG)
The theoretical maximum DCG achievable by sorting all documents in perfect relevance order. IDCG serves as the normalization factor that transforms DCG into NDCG.
- Calculated by ranking all known relevant documents from highest to lowest relevance grade
- Represents the upper bound of ranking quality for a given query
- NDCG = DCG / IDCG, producing a score between 0 and 1
- A score of 1.0 indicates the system achieved the perfect ranking
- Critical for cross-query comparison because it accounts for varying numbers of relevant documents per query
Precision@K
A cutoff-based metric that measures the proportion of relevant documents within the top K results. Unlike NDCG, Precision@K uses binary relevance judgments and ignores ranking order within the top K.
- Formula: P@K = (number of relevant docs in top K) / K
- Binary relevance means documents are either relevant or not, with no graded distinctions
- All positions within the top K are treated equally
- Commonly used alongside Recall@K for a complete picture
- Limitation: Cannot distinguish between a perfect ranking and one where relevant docs are at the bottom of the top K
Average Precision (AP)
A metric that combines precision and recall by averaging precision values at each position where a relevant document is found. AP rewards systems that place relevant documents higher in the ranking.
- Calculated as the mean of precision scores at each relevant document's rank
- Penalizes systems that bury relevant documents deep in the results
- Unlike NDCG, AP typically uses binary relevance rather than graded judgments
- Mean Average Precision (MAP) averages AP across all queries
- Particularly popular in information retrieval research and TREC evaluations

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