Normalized Discounted Cumulative Gain (NDCG) is a ranking evaluation metric that measures the usefulness of retrieved documents based on their graded relevance and position, penalizing relevant documents ranked lower. It calculates the Cumulative Gain (CG) by summing relevance scores, applies a logarithmic discount to reduce the contribution of documents further down the list, and normalizes this Discounted Cumulative Gain (DCG) against the Ideal DCG (IDCG)—the best possible ranking—to produce 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 metric that evaluates the quality of a ranked list of results by measuring the usefulness, or 'gain,' of a document based on its position in the list, penalizing highly relevant documents that appear lower.
In legal AI, NDCG is critical for evaluating legal embedding models and retrieval systems where multi-level relevance grades exist, such as distinguishing between a directly on-point case, a tangentially related statute, and an irrelevant document. Unlike binary metrics, NDCG captures the nuance of graded legal relevance, ensuring that a system placing a highly authoritative precedent at rank 10 is scored worse than one placing it at rank 1, aligning metric performance with the practical needs of legal research.
Key Characteristics of NDCG
Normalized Discounted Cumulative Gain (NDCG) is the gold-standard metric for evaluating ranked retrieval where relevance is graded on a multi-level scale. Unlike binary metrics, it rewards systems that place highly relevant documents at the top of the result list and penalizes those that bury them.
Graded Relevance Judgments
NDCG operates on multi-level relevance scores rather than binary relevant/not-relevant labels. In legal retrieval, a Supreme Court precedent directly on point might score 3, a related circuit court decision 2, a tangentially relevant statute 1, and an irrelevant document 0. This granularity captures the nuanced utility of legal documents where degrees of relevance matter for building arguments. The gain for each document is typically computed as 2^relevance - 1, giving exponentially more weight to highly relevant items.
Position-Aware Discounting
The 'Discounted' in NDCG applies a logarithmic discount factor to each document's gain based on its rank position. The discount for position p is 1 / log₂(p + 1), meaning:
- Position 1: full gain (discount = 1.0)
- Position 5: gain reduced by ~39%
- Position 10: gain reduced by ~54% This models real legal research behavior—attorneys rarely examine documents beyond the first page of results, making top-heavy ranking precision critical.
Ideal DCG Normalization
The 'Normalized' component divides the achieved DCG by the Ideal DCG (IDCG)—the DCG score of a perfect ranking where all documents are sorted by descending relevance. This produces a score between 0.0 and 1.0, where 1.0 represents perfect ordering. Normalization enables:
- Cross-query comparability: queries with many relevant documents don't inflate scores
- Benchmark consistency: different test collections can be compared fairly
- Legal retrieval systems can be evaluated uniformly whether a query returns 3 or 30 relevant cases
Cutoff-Based Evaluation
NDCG is typically reported at specific rank cutoffs, written as NDCG@k where k is the number of top results considered. Common values in legal retrieval:
- NDCG@5: Measures first-page quality for tight integration into legal workflows
- NDCG@10: Standard information retrieval benchmark
- NDCG@20: Evaluates recall-oriented legal research where exhaustive search matters A system might achieve NDCG@5 of 0.89 but NDCG@20 of 0.72, revealing that it excels at top-heavy precision but struggles with exhaustive recall.
Handling Ties and Missing Judgments
NDCG gracefully handles incomplete relevance judgments—a common scenario in large legal corpora where human annotation is expensive. Unjudged documents are typically treated as non-relevant (gain = 0). For tied relevance scores within the ideal ranking, any permutation of equally relevant documents produces the same IDCG. This property makes NDCG robust to annotation sparsity, as missing judgments simply lower the absolute score without breaking the metric's comparative validity across systems.
Comparison with MAP and MRR
NDCG differs from related ranking metrics in important ways:
- vs. Mean Average Precision (MAP): MAP assumes binary relevance; NDCG captures graded relevance essential for legal documents where 'somewhat relevant' differs from 'directly on point'
- vs. Mean Reciprocal Rank (MRR): MRR only cares about the first relevant document; NDCG rewards systems that surface multiple highly relevant documents
- vs. Recall@k: Recall ignores ranking order entirely; NDCG heavily penalizes relevant documents appearing late in results For legal multi-document reasoning tasks, NDCG is preferred because it aligns with the attorney's need to find all strong precedents, not just one.
NDCG vs. Other Ranking Metrics
Comparison of NDCG with other common ranking evaluation metrics for legal document retrieval systems.
| Feature | NDCG | MAP | MRR | Recall@K |
|---|---|---|---|---|
Graded relevance support | ||||
Position-aware scoring | ||||
Binary relevance only | ||||
Handles multi-level judgments | ||||
Normalized across queries | ||||
Penalizes low-ranked relevant docs | ||||
Single relevant doc focus | ||||
Typical legal use case | Multi-grade precedent ranking | Patent prior art search | Case citation lookup | E-discovery recall |
Frequently Asked Questions
Clear answers to common questions about Normalized Discounted Cumulative Gain (NDCG), the standard metric for evaluating the quality of ranked retrieval results in legal AI and search systems.
Normalized Discounted Cumulative Gain (NDCG) is a ranking evaluation metric that measures the usefulness of a retrieved document list based on its graded relevance and the position of each document, penalizing relevant documents that appear lower in the results. It works by first computing the Cumulative Gain (CG) , which is the sum of relevance scores for all documents in the result set. This gain is then discounted logarithmically by position to model user behavior—users are less likely to examine documents ranked further down. Finally, the Discounted Cumulative Gain (DCG) is normalized against the Ideal DCG (IDCG) , which represents a perfect ranking where all documents are sorted by descending relevance. The resulting NDCG score ranges from 0 to 1, where 1 indicates a perfect ranking. For legal retrieval systems, NDCG is preferred over binary metrics because it captures the nuanced relevance gradations common in case law—a directly on-point precedent is more valuable than a tangentially related citation.
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 metric for evaluating ranked retrieval. These related concepts form the essential toolkit for measuring, optimizing, and understanding the performance of legal search and recommendation systems.
Mean Average Precision (MAP)
A binary relevance metric that computes the mean of average precision scores across multiple queries. Unlike NDCG, MAP treats relevance as a binary judgment (relevant or not relevant) rather than a graded scale.
- Calculation: Averages the precision at each position where a relevant document is retrieved
- Use Case: Strong baseline for legal search when relevance is a yes/no decision
- Limitation: Cannot distinguish between highly relevant and marginally relevant documents, making it less suitable than NDCG for nuanced legal ranking
Discounted Cumulative Gain (DCG)
The un-normalized precursor to NDCG that accumulates graded relevance scores with a logarithmic position discount. DCG provides the raw numerator that NDCG normalizes against the ideal ranking.
- Formula: DCG_p = Σᵢ₌₁ᵖ (2^{rel_i} - 1) / log₂(i + 1)
- Position Discount: The log₂(i+1) divisor penalizes relevant documents appearing lower in results
- Relationship: NDCG = DCG / IDCG, where IDCG is the ideal DCG for a perfect ranking
- Insight: DCG alone cannot be compared across queries with different numbers of relevant documents, which is why normalization is essential
Cross-Encoder Reranker
A two-stage retrieval architecture where a computationally expensive cross-encoder jointly processes the query and each candidate document to produce a fine-grained relevance score. This reranking step directly optimizes the NDCG of the final result list.
- Mechanism: Unlike bi-encoders that encode query and document independently, cross-encoders attend across all token pairs
- NDCG Impact: Applying a cross-encoder reranker to top-k candidates from a fast first-pass retrieval typically improves NDCG by 5-15%
- Trade-off: High latency per document pair limits application to a small candidate set, making it complementary to efficient embedding-based retrieval
Hard Negative Mining
A training data strategy that identifies documents which are superficially similar to a query but not relevant, and uses them as negative examples during contrastive learning. This directly improves the model's ability to discriminate, which is measured by NDCG.
- Method: Retrieve top candidates with a baseline model, then label false positives as hard negatives
- Legal Application: In case law retrieval, a dissenting opinion on the same topic is a classic hard negative
- NDCG Connection: Models trained with hard negatives show significantly higher NDCG because they learn to push away confusing near-matches that would otherwise pollute top ranks
Query Expansion
A technique that augments the original search query with related terms, synonyms, or generated text to improve recall. When evaluated with NDCG, effective query expansion increases the metric by surfacing relevant documents that would otherwise be missed due to vocabulary mismatch.
- Legal Example: Expanding 'slip and fall' to include 'premises liability' and 'trip hazard'
- Methods: Pseudo-relevance feedback, thesaurus lookup, or synthetic query generation via LLMs
- NDCG Effect: Primarily improves recall at lower ranks, increasing cumulative gain; the position discount in NDCG ensures that newly retrieved relevant documents are rewarded proportionally to their rank

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