Normalized Discounted Cumulative Gain (NDCG) is a ranking quality metric that measures the usefulness of a ranked list by assigning higher weight to relevant items appearing at the top positions and normalizing the score against an ideal ranking. It extends Cumulative Gain (CG) by applying a logarithmic discount to penalize relevant items buried deep in the list, reflecting the diminishing user attention at lower ranks.
Glossary
Normalized Discounted Cumulative Gain (NDCG)

What is Normalized Discounted Cumulative Gain (NDCG)?
A measure of ranking quality that evaluates a list's usefulness by giving higher weight to relevant items at the top, then normalizing the score against an ideal ranking.
The metric is normalized by dividing the Discounted Cumulative Gain (DCG) of the predicted ranking by the DCG of the ideal ranking (IDCG), producing a score between 0 and 1. NDCG is the primary evaluation metric for learning-to-rank models and deep learning recommender systems, as it handles graded relevance judgments rather than binary labels, making it sensitive to the nuanced value of partially relevant items.
Key Characteristics of NDCG
Normalized Discounted Cumulative Gain (NDCG) is the gold-standard metric for evaluating the quality of a ranked list. It measures not just relevance, but the positional importance of that relevance, normalizing the score against an ideal ordering to enable comparison across different queries.
Position-Aware Scoring
NDCG fundamentally operates on the principle that highly relevant items must appear at the top of a ranked list. Unlike flat metrics like precision, NDCG applies a logarithmic discount to relevance gains based on their position. An item at rank 1 contributes its full relevance score, while an item at rank 100 contributes a heavily discounted fraction. This directly models user behavior, where attention and click probability decay rapidly as users scan down a list of search results or product recommendations.
Multi-Graded Relevance
NDCG supports nuanced, non-binary relevance judgments. Instead of a simple relevant/irrelevant label, items are assigned a graded relevance score (e.g., 0 for 'irrelevant', 1 for 'tangential', 3 for 'relevant', 5 for 'perfect match'). This allows the metric to penalize a system that ranks a 'tangential' result above a 'perfect' one, even if both are technically 'relevant' in a binary sense. The gain is typically computed as 2^rel - 1, giving exponentially higher credit to higher relevance grades.
Ideal Normalization (IDCG)
The 'Normalized' in NDCG is its most critical feature. The raw Discounted Cumulative Gain (DCG) is divided by the Ideal DCG (IDCG)—the DCG of the perfect ranking for that specific query. This normalization bounds the score between 0.0 and 1.0, making it query-agnostic. A score of 1.0 indicates a perfect ranking. This allows you to average NDCG across a test set of diverse queries where the number of relevant items varies wildly, a scenario where raw DCG would be meaningless.
Calculation Formula
The formal definition is NDCG@k = DCG@k / IDCG@k. The DCG is calculated as the sum over all positions i up to k of (2^{rel_i} - 1) / log_2(i + 1). The numerator is the gain from the item's relevance grade, and the denominator is the positional discount. The IDCG is computed by sorting all items in the corpus by their true relevance grade in descending order and calculating the DCG of that ideal list. This normalization ensures the score reflects the system's ability to sort items correctly.
Cutoff Evaluation (NDCG@k)
NDCG is almost always evaluated at a specific cutoff k, denoted as NDCG@k (e.g., NDCG@10, NDCG@50). This focuses the evaluation on the top of the ranked list, which is the only part most users interact with. The choice of k is domain-specific: a search engine might optimize for NDCG@5, while a recommendation carousel might look at NDCG@20. This metric ignores the ordering of items beyond the cutoff, aligning the evaluation with the practical limits of a user interface.
Handling Missing Judgments
A practical challenge with NDCG is unjudged documents. In large-scale evaluation, it's impossible to label every item. The standard approach is to treat unjudged items as irrelevant (gain=0). This is a conservative assumption that penalizes systems for surfacing unvetted content. More advanced techniques like bpref or inferred relevance models exist, but the zero-gain assumption remains the industry default for its simplicity and safety, ensuring that systems are not rewarded for returning items of unknown quality.
NDCG vs. Other Ranking Metrics
How Normalized Discounted Cumulative Gain compares to alternative ranking evaluation metrics across key properties for recommender system evaluation.
| Property | NDCG | Precision@K | Recall@K | MRR |
|---|---|---|---|---|
Handles graded relevance | ||||
Position-aware weighting | ||||
Normalized across queries | ||||
Binary relevance only | ||||
Sensitive to total relevant count | ||||
Penalizes relevant items at bottom | ||||
Ideal for multi-level labels |
Frequently Asked Questions
Precise answers to the most common technical questions about Normalized Discounted Cumulative Gain, its calculation, and its role in evaluating ranking quality.
Normalized Discounted Cumulative Gain (NDCG) is a ranking quality metric that measures the usefulness of a ranked list by giving higher weight to relevant items appearing at the top positions and normalizing the score against an ideal ranking. It works by first computing the Discounted Cumulative Gain (DCG), which sums the graded relevance scores of each item in the list, applying a logarithmic discount factor based on position so that highly relevant items ranked lower contribute less to the total. This DCG is then divided by the Ideal DCG (IDCG)—the DCG of the perfectly ordered list where all items are sorted by descending relevance—yielding a normalized score between 0 and 1. An NDCG of 1.0 indicates a perfect ranking. The metric is widely used in information retrieval and recommender systems because it handles graded relevance (e.g., 0-4 scale) rather than binary judgments, making it sensitive to varying degrees of usefulness.
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 cornerstone of learning-to-rank evaluation. These related concepts define the broader ecosystem of retrieval assessment, model training objectives, and the infrastructure required to serve ranked results.
Recall@K
An evaluation metric that measures the proportion of all relevant items that appear within the top K positions of a ranked list. Unlike NDCG, Recall@K is position-insensitive within the cutoff—a relevant item at rank 1 counts the same as one at rank K. This makes it ideal for assessing retrieval stages where exhaustive recall is prioritized over precise ordering. For example, if a user has 10 relevant items in a catalog and 7 appear in the top 100 results, Recall@100 = 0.7. It is often paired with Precision@K to balance completeness against signal-to-noise ratio.
Mean Reciprocal Rank (MRR)
A metric that evaluates systems where there is exactly one relevant item and the user needs it at the top. MRR is the average of the reciprocal of the rank at which the first relevant item appears across multiple queries. A relevant item at rank 1 yields a score of 1.0; at rank 5, 0.2. This metric is dominant in question-answering systems and FAQ retrieval where the user expects a single correct answer, not a ranked list of possibilities.
Mean Average Precision (MAP)
A binary relevance metric that computes the average of precision values calculated at each position where a relevant document is retrieved. MAP provides a single-figure measure of quality across recall levels, heavily penalizing systems that bury relevant items deep in the ranking. Unlike NDCG, MAP treats all relevant items as equally relevant—it cannot distinguish between highly relevant and marginally relevant results. It remains standard in information retrieval benchmarks where graded relevance judgments are unavailable.
Discounted Cumulative Gain (DCG)
The unnormalized precursor to NDCG. DCG accumulates the relevance score of each item, logarithmically discounted by its position. The formula is: DCG@K = Σ(i=1 to K) (2^rel_i - 1) / log₂(i + 1). The exponential gain function (2^rel - 1) ensures that highly relevant items contribute disproportionately more than marginally relevant ones. DCG is useful for comparing systems on the same query but cannot be averaged across queries with different numbers of relevant items—hence the need for normalization.
Ideal DCG (IDCG)
The maximum possible DCG achievable for a given query, computed by sorting all items in descending order of true relevance and calculating DCG on this perfect ranking. IDCG serves as the normalization factor in NDCG: NDCG = DCG / IDCG. This normalization bounds the score between 0 and 1 and enables meaningful averaging across queries with vastly different numbers of relevant items. Without IDCG normalization, a query with 50 relevant items would dominate the aggregate metric.
Pairwise Loss Functions
Training objectives that frame ranking as a binary classification on item pairs. Instead of predicting absolute relevance scores, the model learns to predict which of two items should rank higher. Bayesian Personalized Ranking (BPR) is the canonical example, maximizing the probability that an observed item is preferred over an unobserved one. Pairwise losses directly optimize the relative ordering that NDCG measures, often yielding better ranking performance than pointwise regression approaches that treat relevance prediction as an independent task.

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