Inferensys

Glossary

Normalized Discounted Cumulative Gain (NDCG)

A ranking evaluation metric that measures the usefulness of retrieved documents based on their graded relevance and position in the result list, penalizing relevant documents ranked lower.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
RANKING EVALUATION METRIC

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.

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.

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.

RANKING QUALITY METRICS

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.

01

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.

02

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.
03

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
04

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.
05

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.

06

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.
METRIC COMPARISON

NDCG vs. Other Ranking Metrics

Comparison of NDCG with other common ranking evaluation metrics for legal document retrieval systems.

FeatureNDCGMAPMRRRecall@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

RANKING EVALUATION

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.

Prasad Kumkar

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.