Normalized Discounted Cumulative Gain (NDCG) is a ranking metric that evaluates the quality of a search result list by considering both the graded relevance of each item and its position, with higher relevance scores receiving more weight when they appear earlier in the list. It is calculated by first computing the Discounted Cumulative Gain (DCG), which sums relevance scores with a logarithmic discount based on rank, and then normalizing it against the ideal DCG achievable for that query, resulting in a score between 0 and 1.
Glossary
Normalized Discounted Cumulative Gain (NDCG)

What is Normalized Discounted Cumulative Gain (NDCG)?
A core metric for evaluating the quality of ranked lists in information retrieval and recommendation systems.
NDCG is the standard metric for evaluating retrieval-augmented generation (RAG) systems and search engines because it accounts for multi-level relevance (e.g., highly relevant, somewhat relevant, irrelevant) rather than simple binary relevance. A perfect NDCG@K score of 1.0 indicates the top K results are ordered identically to the ideal ranking. It is directly compared to metrics like Recall@K and Mean Reciprocal Rank (MRR) but is preferred when result relevance is graded.
Key Characteristics of NDCG
Normalized Discounted Cumulative Gain (NDCG) is the standard metric for evaluating ranked lists where items have graded relevance (e.g., highly relevant, somewhat relevant, not relevant). It accounts for both the quality of results and their position.
Graded Relevance
Unlike binary metrics (relevant/not relevant), NDCG operates on graded relevance scores. Each item in the result list is assigned a relevance label, typically an integer (e.g., 0=irrelevant, 1=somewhat relevant, 2=highly relevant). This allows the metric to distinguish between a good result and a perfect result.
- Example: In a search for "machine learning tutorials," a foundational blog post might score 1, while an official university course syllabus might score 3.
Positional Discounting
NDCG incorporates the principle that users value relevant items more when they appear higher in the list. It applies a logarithmic discount to the gain (relevance score) of each item based on its rank.
The gain for an item at position i is divided by log2(i + 1). This means the utility of a relevant document drops sharply if it's not on the first page of results, modeling real user attention decay.
Cumulative Gain (CG & DCG)
Cumulative Gain (CG) is the simple sum of relevance scores for the top K results. It ignores position.
Discounted Cumulative Gain (DCG) refines this by summing the positionally discounted gains.
Formula for DCG@K: DCG@K = Σ (relevance_i / log2(i + 1)) for i = 1 to K.
A variant uses an exponential gain for stronger emphasis on highly relevant items: DCG@K = Σ ((2^relevance_i - 1) / log2(i + 1)).
Normalization to Ideal DCG
NDCG is normalized by the Ideal DCG (IDCG). IDCG is the maximum possible DCG achievable for a given set of queries, obtained by ranking all items in perfect descending order of relevance.
Formula: NDCG@K = DCG@K / IDCG@K
This normalization bounds NDCG between 0.0 and 1.0, where 1.0 represents a perfect ranking. It allows for meaningful comparison across different queries and datasets with varying numbers of relevant items.
Evaluation of Ranking Quality
NDCG provides a single, interpretable number that summarizes overall ranking quality. It is the de facto standard for evaluating web search engines, recommendation systems, and RAG retrievers.
- A score of 0.9+ indicates excellent ranking.
- Scores are averaged over a large query set to evaluate system performance.
- It directly measures the user experience of finding high-quality information quickly.
Relation to Other Metrics
NDCG complements other retrieval metrics:
- Precision@K: Measures accuracy in the top K but uses binary relevance.
- Recall@K: Measures coverage of all relevant items.
- Mean Average Precision (MAP): Averages precision at each relevant item's rank, also for binary relevance.
NDCG is preferred when relevance is non-binary. It is more correlated with user satisfaction than precision or recall alone, as it penalizes systems that bury excellent results on page two.
NDCG vs. Other Retrieval Metrics
A comparison of Normalized Discounted Cumulative Gain (NDCG) against other common metrics used to evaluate ranking quality in information retrieval and RAG systems.
| Metric / Feature | NDCG (Normalized Discounted Cumulative Gain) | Precision@K | Recall@K | Mean Reciprocal Rank (MRR) |
|---|---|---|---|---|
Core Definition | Measures ranking quality by summing graded relevance scores, discounted by rank position, normalized against an ideal ranking. | Measures the fraction of retrieved items in the top K that are relevant. | Measures the fraction of all relevant items that are found in the top K results. | Measures the average reciprocal rank of the first relevant item across queries. |
Handles Graded Relevance | ||||
Accounts for Rank Position | ||||
Penalizes Late Relevance | ||||
Upper Bound (Perfect Score) | 1 | Varies by query | Varies by query | 1 |
Typical Use Case | Evaluating web search, recommendation systems, and RAG retrieval where relevance is not binary. | Evaluating the purity of the top results when false positives are costly. | Evaluating the comprehensiveness of retrieval when missing relevant items is costly. | Evaluating systems where the rank of the first correct answer is critical (e.g., question answering). |
Primary Weakness | Requires graded relevance judgments; more complex to compute. | Ignores relevance beyond position K; does not account for rank order within K. | Does not account for rank order; a relevant item at rank K+1 is a complete miss. | Only considers the first relevant item; ignores other relevant results. |
Interpretation | A score of 1.0 indicates a perfect ranking order matching the ideal DCG. Scores are comparable across query sets. | A score of 0.8 at K=10 means 8 of the top 10 results were relevant. | A score of 0.5 at K=10 means half of all relevant documents for that query were in the top 10. | A score of 0.5 means the average rank of the first relevant result is 2 (1/rank = 0.5). |
Practical Applications of NDCG
Normalized Discounted Cumulative Gain (NDCG) is a core metric for evaluating ranked lists in information retrieval and recommendation systems. Its primary applications focus on measuring the quality of search results and personalized suggestions by accounting for both the relevance of items and their position in the list.
Search Engine Result Page (SERP) Evaluation
NDCG is the de facto standard for evaluating the quality of web search results. It quantifies how well a search engine orders documents by their usefulness to the user.
- Graded Relevance: Unlike binary metrics, NDCG uses graded relevance scores (e.g., 0=irrelevant, 1=somewhat relevant, 2=relevant, 3=highly relevant).
- Positional Discounting: It applies a logarithmic discount, heavily penalizing a highly relevant document placed on the second page of results versus the first position.
- Industry Benchmark: Major search providers use NDCG@5, NDCG@10, or NDCG@20 to A/B test ranking algorithm changes and measure improvements in user satisfaction.
Recommender System Optimization
In e-commerce and media streaming, NDCG evaluates the quality of personalized recommendation lists (e.g., "Recommended for You").
- List Quality: It measures if the most engaging or likely-to-purchase items are ranked at the top of a recommendation carousel.
- Business Impact: A higher NDCG correlates directly with key metrics like click-through rate (CTR), conversion rate, and user retention.
- Example: A video platform uses NDCG to test if a new algorithm ranks movies a user is likely to watch for 80% of their duration higher than those they might abandon after 5 minutes.
Retrieval-Augmented Generation (RAG) Pipeline Tuning
Within RAG architectures, NDCG is critical for evaluating the retriever component—the system that fetches context documents for the language model.
- Retriever Benchmarking: Engineers compare different retrieval strategies (e.g., dense vs. sparse vs. hybrid search) by calculating NDCG over a test set of queries and ground-truth relevant document chunks.
- Fine-Tuning Validation: After fine-tuning a dense retriever on domain-specific data, the improvement is measured by the increase in NDCG, indicating the retriever now better understands domain-specific language.
- Precision vs. Recall Trade-off: NDCG@K (e.g., K=5) ensures the top few retrieved passages are maximally relevant, which is crucial for generator accuracy and hallucination reduction.
A/B Testing and Model Deployment
NDCG serves as a primary offline metric for gatekeeping model deployments. A new ranking model must demonstrate a statistically significant improvement in NDCG over the current production model before it is launched.
- Reduction of Online Risk: It provides a reliable, quantitative proxy for expected user satisfaction before costly and risky live experiments.
- Multi-Model Comparison: When choosing between several candidate algorithms, the one with the highest NDCG on a held-out validation set is typically selected for further testing.
- Monitoring Drift: Tracking NDCG on a fixed evaluation set over time can alert teams to performance degradation due to data or concept drift.
Academic Benchmarking and Competitions
NDCG is the standard evaluation metric for public datasets and challenges in information retrieval, such as the TREC conferences or the MS MARCO leaderboard.
- Reproducible Research: It provides a consistent, normalized score (between 0.0 and 1.0) that allows for direct comparison of algorithms published by different research groups.
- Dataset-Specific: Major datasets publish official evaluation scripts and report NDCG@10 or similar as the key metric for ranking submissions.
- Driving Innovation: The pursuit of higher NDCG scores on these benchmarks has driven advancements in neural ranking models, cross-encoders, and retrieval-augmented architectures.
Related Metrics and Practical Nuances
NDCG is used in conjunction with other metrics to provide a complete performance picture. Understanding its relationship to these metrics is essential for practitioners.
- vs. Precision/Recall: Precision@K measures accuracy at a cutoff but treats all relevant items equally. NDCG is superior as it uses graded relevance and positional discounting.
- vs. Mean Average Precision (MAP): MAP is designed for binary relevance and emphasizes recall. NDCG is preferred for multi-level relevance scales common in modern systems.
- Ideal Discounted Cumulative Gain (IDCG): This is the denominator in NDCG. It represents the score of a perfect ranking, providing an intuitive upper bound of 1.0.
- Cutoff Selection: The choice of
Kin NDCG@K is application-dependent: NDCG@5 for first-page web results, NDCG@100 for evaluating full retrieval sets in academic settings.
Frequently Asked Questions
Normalized Discounted Cumulative Gain (NDCG) is a core metric for evaluating the quality of ranked lists in information retrieval and Retrieval-Augmented Generation (RAG) systems. These FAQs address its mechanics, calculation, and practical application for engineers and CTOs.
Normalized Discounted Cumulative Gain (NDCG) is a ranking evaluation metric that measures the quality of a search result list by considering both the graded relevance of each item and its position, applying a logarithmic discount to items lower in the ranking. It is the normalized form of Discounted Cumulative Gain (DCG), which sums the relevance scores of results while reducing the contribution of scores from lower-ranked positions. The normalization is performed against an Ideal DCG (IDCG), which is the maximum possible DCG for a given set of results, producing a score between 0.0 and 1.0 where 1.0 represents a perfect ranking.
In the context of Retrieval-Augmented Generation (RAG), NDCG is used to evaluate the retriever component, assessing how well it orders relevant document chunks for a given query before they are passed to the generator. A high NDCG score indicates that the most relevant context is positioned at the top of the list, which is critical for minimizing prompt noise and reducing the likelihood of the language model generating hallucinations from less relevant information.
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
NDCG is a core metric for evaluating ranked retrieval results. Understanding related metrics provides a complete picture of system performance across different objectives like recall, precision, and rank sensitivity.
Recall@K
Recall@K measures the proportion of all relevant documents that are successfully retrieved within the top K results. It answers the question: "Did the system find all the relevant items?"
- Formula: (Number of relevant docs in top K) / (Total number of relevant docs).
- Focus: Completeness of retrieval. A high Recall@K means few relevant items are missed.
- Trade-off: Often inversely related to precision; retrieving more items (higher K) increases recall but can lower precision.
- Use Case: Critical in applications where missing a relevant document is costly, such as legal e-discovery or systematic literature reviews.
Mean Reciprocal Rank (MRR)
Mean Reciprocal Rank (MRR) is a rank-sensitive metric that evaluates systems where only the first relevant result matters. It calculates the average of the reciprocal of the rank at which the first relevant document is found.
- Formula: For a set of queries Q, MRR = (1/|Q|) * Σ (1 / rank_i), where rank_i is the position of the first relevant document for query i.
- Focus: Rank of the first hit. It heavily penalizes systems that bury the first relevant result.
- Interpretation: Scores range from 0 to 1. An MRR of 0.5 means the first relevant document is, on average, ranked 2nd.
- Use Case: Ideal for question-answering systems or web search where the user's primary need is satisfied by a single, high-quality result.
Precision@K
Precision@K measures the fraction of retrieved documents within the top K results that are relevant. It answers: "How much of what was retrieved is actually useful?"
- Formula: (Number of relevant docs in top K) / K.
- Focus: Purity or accuracy of the retrieved set. High precision means the user is not wasting time on irrelevant results.
- Context: Unlike NDCG, it treats all relevant items equally, regardless of their degree of relevance or specific rank within the top K.
- Use Case: Essential for user interfaces with limited space (e.g., mobile search) where showing irrelevant results degrades the user experience.
Mean Average Precision (MAP)
Mean Average Precision (MAP) is a single-figure metric that summarizes the quality of a ranked list across multiple levels of recall. It is the mean of the Average Precision scores for a set of queries.
- Calculation: For a single query, Average Precision is the average of Precision@K values computed at each rank where a relevant document is found. MAP averages this across all queries.
- Focus: Overall ranking quality, balancing both precision and recall. It rewards systems that retrieve many relevant documents early.
- Comparison to NDCG: MAP assumes binary relevance (relevant/not relevant), while NDCG can handle graded relevance scores (e.g., highly relevant, somewhat relevant).
- Use Case: The standard evaluation metric for many classic information retrieval benchmarks and competitions.
Discounted Cumulative Gain (DCG)
Discounted Cumulative Gain (DCG) is the unnormalized precursor to NDCG. It measures the cumulative gain of a search result list, applying a logarithmic discount to gains based on their rank.
- Core Principle: The utility (gain) of a document is reduced (discounted) the lower it appears in the list. This reflects the decreasing user attention with rank.
- Formula: A common formulation is DCG@K = Σ (relevance_i / log2(i + 1)), for i = 1 to K.
- Purpose: Quantifies the absolute quality of a single ranking. To compare across queries, DCG is normalized against an ideal ranking to become NDCG.
- Key Insight: DCG directly implements the core idea that highly relevant documents are more valuable when they appear earlier.
Ideal Discounted Cumulative Gain (IDCG)
Ideal Discounted Cumulative Gain (IDCG) is the maximum possible DCG score for a given set of query results. It is calculated by sorting all available relevant documents for a query in descending order of their true relevance scores.
- Role: Serves as the normalization factor in NDCG. NDCG = DCG / IDCG.
- Function: It establishes a perfect, achievable upper bound (a score of 1.0) for the ranking metric, allowing for fair comparison across queries with different numbers of relevant documents.
- Calculation: Requires knowledge of the true relevance judgments for all documents in the corpus relative to the query.
- Outcome: An NDCG score represents the system's performance as a percentage of the ideal ranking's quality.

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