# Normalized discounted cumulative gain

> Source: https://aiwiki.ai/wiki/ndcg
> Updated: 2026-11-18
> Fact-checked: 2026-11-18
> Categories: Information Retrieval, Machine Learning, Model Evaluation
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Normalized discounted cumulative gain." aiwiki.ai, 18 Nov 2026. https://aiwiki.ai/wiki/ndcg
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**Normalized discounted cumulative gain** (**NDCG**, also written **nDCG**) is an evaluation measure for ranked lists that rewards a system for placing highly relevant items near the top. It adds up the graded relevance ("gain") of each item in a ranking, shrinks the contribution of items found further down the list with a logarithmic discount, and divides the result by the score of the best possible ordering, so that a perfect ranking scores 1.[1][5] Kalervo Järvelin and Jaana Kekäläinen of the University of Tampere presented cumulated gain and discounted cumulated gain at SIGIR 2000 and added the normalized form in a 2002 article in *ACM Transactions on Information Systems*.[1][2] NDCG is one of the standard metrics of [information retrieval](https://aiwiki.ai/wiki/information_retrieval) and [learning to rank](https://aiwiki.ai/wiki/ranking): it was used to score RankNet in 2005, LambdaRank and LambdaMART were built to optimize it, and NDCG at cutoff 10 (NDCG@10) is the headline retrieval metric of the 2019 TREC Deep Learning track, the BEIR benchmark and the [MTEB](https://aiwiki.ai/wiki/mteb) text-embedding benchmark.[3][5][7][8][9]

## Motivation

Classic retrieval measures such as [precision](https://aiwiki.ai/wiki/precision) and [recall](https://aiwiki.ai/wiki/recall) treat relevance as binary: a document is relevant or it is not. Järvelin and Kekäläinen argued that this gives a retrieval technique the same credit for a marginally relevant document as for a highly relevant one, and pointed out that TREC counted a document as relevant if it had even one sentence pertaining to the request.[1] Their measures rest on two observations stated in the 2002 article: highly relevant documents are more valuable than marginally relevant ones, and the lower a relevant document is ranked, the less valuable it is to the user, because the user is less likely ever to examine it.[1] The first observation leads to graded gain values; the second leads to the rank-based discount.

Christopher Burges summarized the same advantages from the learning-to-rank side in 2010: NDCG and expected reciprocal rank (ERR) handle multiple levels of relevance, whereas mean reciprocal rank (MRR) and mean [average precision](https://aiwiki.ai/wiki/average_precision) (MAP) are designed for binary relevance, and they include a position dependence that gives higher-ranked results more weight, which he called "particularly appropriate for web search".[5]

<figure class="embedvideo">
<iframe src="https://www.youtube-nocookie.com/embed/BvRMAgx0mvA" title="nDCG: the evaluation metric you've (probably) never heard of"></iframe>
<figcaption>"nDCG: the evaluation metric you've (probably) never heard of", video from ritvikmath, published August 23, 2021. <a href="https://www.youtube.com/watch?v=BvRMAgx0mvA">Watch on YouTube</a>.</figcaption>
</figure>

## Definition

### Cumulative gain

Each item in a ranked list is replaced by a gain value derived from its relevance judgment. In the definitions of the 2002 article the gain is the relevance score itself on a 0 to 3 scale (its case study also tried other weights, described below), so a ranking becomes a gain vector such as $G = \langle 3, 2, 3, 0, 0, 1, 2, 2, 3, 0, \ldots \rangle$.[1] Cumulative gain (CG) at rank $i$ is the sum of the gains from rank 1 to rank $i$; for that vector the CG at rank 7 is 11.[1] CG ignores order within the cutoff: swapping two items above rank $i$ does not change CG at rank $i$.

### Discounted cumulative gain

Discounted cumulative gain (DCG) divides each gain by a function of its rank before adding it. Järvelin and Kekäläinen wanted a discount that "progressively reduces the document score as its rank increases but not too steeply", and chose the logarithm of the rank, noting that with base 2 a document at position 1024 still keeps one tenth of its value.[1] In their original formulation, with logarithm base $b$, ranks below $b$ are not discounted at all and each later rank $i$ contributes $G[i] / \log_b i$:[1]

$$\mathrm{DCG}[i] = \begin{cases} \mathrm{CG}[i] & \text{if } i < b \\ \mathrm{DCG}[i-1] + G[i] / \log_b i & \text{if } i \ge b \end{cases}$$

The authors skipped rank 1 because $\log_b 1 = 0$, and skipped ranks 2 to $b-1$ because dividing by a logarithm smaller than 1 would boost those ranks rather than discount them.[1] They described base 2 as modelling an impatient searcher and a larger base such as 10 as modelling a persistent one.[1]

Later work settled on dividing by $\log(1+i)$; Wang and colleagues wrote in 2013 that this discount "dominated the literature and applications".[6] With base 2 the divisor equals 1 at rank 1, so every rank from 2 onward is discounted. Truncated at rank $k$:

$$\mathrm{DCG@}k = \sum_{i=1}^{k} \frac{g(\mathit{rel}_i)}{\log_2(i+1)}$$

where $\mathit{rel}_i$ is the relevance grade of the item at rank $i$ and $g$ is the gain function. NIST's trec_eval program divides by $\log_2$ of rank plus one in its `ndcg` measure,[11] and Burges defined DCG@T with $\log(1+i)$ in the denominator.[5] Wang and colleagues note that the base of this logarithm does not matter once DCG is normalized, because changing the base multiplies every term by the same constant.[6]

### Gain functions

Two gain functions are in common use:

- **Linear gain**, $g(\mathit{rel}) = \mathit{rel}$: the relevance grade is used directly. This is the default in trec_eval, which documents that "Gain values are set to the appropriate relevance level by default" and lets the user override the gain for each level on the command line,[11] and in scikit-learn's `ndcg_score`, which sums the true relevance scores of the ranked items.[13][14]
- **Exponential gain**, $g(\mathit{rel}) = 2^{\mathit{rel}} - 1$: each step up the relevance scale roughly doubles the reward. The 2005 RankNet paper by Burges and colleagues at Microsoft computed NDCG with $(2^{r(j)} - 1)/\log(1+j)$ on web-search ratings, truncated at rank 15.[3] The organizers of the 2010 Yahoo! Learning to Rank Challenge wrote that, following that paper, "it became usual to assign exponentially high weight to highly relevant documents", and used the exponential form themselves.[4] LightGBM's default `label_gain` for its LambdaRank objective is the sequence 0, 1, 3, 7, 15, 31, 63, and so on, which is $2^{\mathit{rel}} - 1$.[15]

With binary relevance (grades 0 and 1) the two gain functions give identical values. With graded labels they can give different values and can order systems differently, so an NDCG figure on graded judgments is fully specified only when its gain function is stated.

### Normalization and the ideal ranking

DCG values are not comparable across queries: a query with many highly relevant documents can reach a much larger DCG than one with a single marginal document. Normalization divides DCG by the ideal DCG (IDCG), the DCG of the best possible ordering, obtained by sorting all judged relevant items by decreasing grade:[1][5]

$$\mathrm{NDCG@}k = \frac{\mathrm{DCG@}k}{\mathrm{IDCG@}k}$$

The result lies between 0 and 1 when gains are non-negative, and equals 1 only for an ideal ordering.[5][6] NDCG is defined per query; in the 2010 Yahoo! challenge, for example, a submission's score was the arithmetic mean of the per-query values.[4]

In the 2002 article the ideal vector is built from the full recall base of the topic (every document judged relevant, at each level), not from the documents a particular system happened to retrieve. The authors set this against the earlier sliding-ratio measure, whose ideal changes with the size of the retrieved list.[1] trec_eval follows the same approach: it keeps accumulating ideal gain from the judged relevant documents after the system's retrieved list has run out.[11] Library functions that take only the scored items as input, such as scikit-learn's, compute the ideal from the true labels of those items alone.[14]

### Cutoff

NDCG is usually reported at a cutoff $k$, written NDCG@k, which ignores everything below rank $k$. trec_eval's `ndcg_cut` measure computes it by default at cutoffs 5, 10, 15, 20, 30, 100, 200, 500 and 1000.[12] Burges gave the example that if only the first page of returned results matters, one might take $T = 10$.[5] Wang and colleagues describe NDCG@k as a combination of a slowly decaying logarithmic discount and a hard cut-off, with the discount set to zero for ranks larger than $k$.[6]

## Worked example

The 2002 article illustrates the measures with the gain vector $\langle 3, 2, 3, 0, 0, 1, 2, 2, 3, 0 \rangle$ and a sample ideal vector $\langle 3, 3, 3, 2, 2, 2, 1, 1, 1, 1 \rangle$.[1] With the original base-2 formulation, the paper reports the following values:[1]

| Rank | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Gain | 3 | 2 | 3 | 0 | 0 | 1 | 2 | 2 | 3 | 0 |
| CG | 3 | 5 | 8 | 8 | 8 | 9 | 11 | 13 | 16 | 16 |
| DCG ($b = 2$) | 3 | 5 | 6.89 | 6.89 | 6.89 | 7.28 | 7.99 | 8.66 | 9.61 | 9.61 |
| Ideal DCG ($b = 2$) | 3 | 6 | 7.89 | 8.89 | 9.75 | 10.52 | 10.88 | 11.21 | 11.53 | 11.83 |

Dividing the two DCG rows rank by rank gives the normalized DCG vector; at rank 10 the system has collected $9.61 / 11.83 \approx 0.81$ of the ideal discounted gain.

Applying the modern $\log_2(i+1)$ discount to the same two vectors gives different numbers. With linear gain, DCG@10 is about 8.32 against an ideal of about 9.98, so NDCG@10 is about 0.83; with exponential gain, DCG@10 is about 16.80 against about 19.68, so NDCG@10 is about 0.85. At a cutoff of 5 the linear-gain value is about 0.72.

## History

| Year | Event |
|---|---|
| 2000 | Järvelin and Kekäläinen present cumulated gain and discounted cumulated gain in "IR evaluation methods for retrieving highly relevant documents" at SIGIR 2000.[1][2] |
| 2001 | The two measures are applied in the TREC 2001 Web Track, according to the 2002 article.[1] |
| 2002 | "Cumulated gain-based evaluation of IR techniques" (*ACM TOIS* 20(4), pages 422-446) adds the normalized nCG and nDCG measures.[1] |
| 2005 | RankNet (ICML 2005) reports NDCG@15 with exponential gain on commercial web-search data.[3] |
| 2006 | Burges, Ragno and Le introduce LambdaRank, which scales pairwise gradients by the change in NDCG.[5] |
| 2010 | The Yahoo! Learning to Rank Challenge reports NDCG@10 alongside ERR; an ensemble of LambdaMART rankers wins Track 1.[4][5] |
| 2013 | Wang and colleagues publish a theoretical analysis of NDCG-type measures at COLT 2013.[6] |
| 2020 | The TREC 2019 Deep Learning track overview names NDCG@10 its main metric.[7] |
| 2021 | BEIR adopts nDCG@10 for all of its zero-shot retrieval datasets.[8] |
| 2023 | MTEB, published at EACL 2023, uses nDCG@10 as the main retrieval metric.[9] |

The 2002 article demonstrated the measures on 20 topics from the TREC-7 ad hoc track. The authors used result lists from five participants in the manual track and new relevance judgments on a four-point scale (irrelevant, marginally, fairly and highly relevant) made by six master's students in information studies.[1] They tried three weighting schemes (0-1-1-1, 0-0-0-1 and 0-1-10-100) and logarithm bases 2 and 10, and found that both the weighting and the discount changed the order of the runs; in the authors' reading of their nDCG curves, moving from flat 0-1-1-1 weights to 0-1-10-100 made one run appear more effective than the others.[1]

## Use in evaluation

### Information retrieval benchmarks

The organizers of the TREC 2019 Deep Learning track chose NDCG@10 as the main metric for both the document and passage ranking tasks, "since it makes use of our 4-level judgments and focuses on the first results that users will see".[7] The BEIR benchmark for zero-shot retrieval, presented at the NeurIPS 2021 Datasets and Benchmarks track, wanted a single metric that could be computed comparably on every dataset. Its authors rejected precision and recall as rank-unaware and MRR and MAP as unable to use graded judgments, wrote that nDCG@k "provides a good balance suitable for both tasks involving binary and graded relevance judgements", and computed nDCG@10 for all datasets with the Python interface to trec_eval.[8] The paper used that metric to compare lexical retrieval with [BM25](https://aiwiki.ai/wiki/bm25), sparse retrievers, dense bi-encoders, the late-interaction model [ColBERT](https://aiwiki.ai/wiki/colbert) and [re-ranking](https://aiwiki.ai/wiki/re-ranking) with a [cross-encoder](https://aiwiki.ai/wiki/cross_encoder).[8]

MTEB, the Massive Text Embedding Benchmark for text [embedding](https://aiwiki.ai/wiki/embeddings) models, reuses BEIR's datasets and evaluation for its retrieval tasks and makes nDCG@10 the main metric, while also computing MRR@k, MAP@k, precision@k and recall@k.[9] Its multilingual successor [MMTEB](https://aiwiki.ai/wiki/mmteb) (ICLR 2025) uses nDCG@10 as the primary retrieval metric unless a dataset's own publication specifies another.[10]

### Learning to rank

As a function of model scores, NDCG is flat or discontinuous everywhere, because it depends only on the sorted order; Burges noted that this makes direct gradient descent "problematic, since the gradient is everywhere either zero or not defined".[5] LambdaRank sidesteps the problem by writing the gradient directly: for each pair of documents it takes the pairwise RankNet gradient and multiplies it by $|\Delta \mathrm{NDCG}|$, the change in NDCG that swapping the two documents would cause.[5] Burges reported that such a model empirically optimizes NDCG, and that replacing $|\Delta \mathrm{NDCG}|$ with the change in another measure, such as MRR or MAP, adapts the method to that measure.[5] LambdaMART, the gradient-boosted tree version, is built on the same gradients.[5]

These ideas are exposed in [gradient boosting](https://aiwiki.ai/wiki/gradient_boosting) libraries. [LightGBM](https://aiwiki.ai/wiki/lightgbm) offers a `lambdarank` objective with configurable `label_gain`, an `ndcg` evaluation metric with positions set by `eval_at`, and a `lambdarank_truncation_level` parameter whose documentation says it is "closely related to the desirable cutoff k in the metric NDCG@k" being optimized.[15] Wang and colleagues also cite work showing that NDCG-consistent surrogate losses exist, which they read as a sign that NDCG is "a good ranking measure from a learning-to-rank point of view".[6]

### Recommender systems

Krichene and Rendle of Google Research studied the evaluation of item recommendation in [recommender systems](https://aiwiki.ai/wiki/recommender_system), in which a withheld relevant item is ranked among the candidates and its position $r$ is recorded. With one relevant item and no cutoff, NDCG reduces to $1/\log_2(r+1)$, so rank 1 is worth about 1.58 times rank 2; average precision, by comparison, values rank 1 at twice rank 2.[16] They showed that a shortcut which, they wrote, had recently become common, ranking the relevant item against only a small random sample of irrelevant items, makes sampled NDCG inconsistent with exact NDCG: a sampled comparison can say that recommender A beats recommender B when the exact metric says the reverse, even in expectation, and as the sample shrinks every metric collapses toward the area under the ROC curve. They recommended avoiding sampling for metric calculation and applying a correction when sampling cannot be avoided.[16]

## Theoretical properties

Wang, Wang, Li, He, Liu and Chen studied NDCG-type measures formally in a 2013 COLT paper. They showed that standard NDCG with the $1/\log(1+r)$ discount converges to 1 for every ranking function as the number of ranked items goes to infinity, which at first sight suggests it cannot tell good rankers from bad ones.[6] They then proposed a property called consistent distinguishability (for every pair of substantially different ranking functions, the measure picks the better one consistently on almost all datasets) and proved that logarithmic-discount NDCG has it despite the shared limit.[6] Characterizing other discounts, they found that $r^{-1}$ (called Zipfian in the IR literature) is a critical point: discounts that decay more slowly keep strong distinguishability, while discounts that decay substantially faster lose it. They also analyzed NDCG@k for different choices of $k$ and discount, and reported that experiments on web-search data agreed with the theory.[6] BEIR's authors cite this paper for "the theoretical advantages of the metric".[8]

## Limitations and criticism

- **Arbitrary parameters.** Järvelin and Kekäläinen acknowledged that the cutoff rank, the gain values and the discount are all choices the evaluator must make, that quantifying how much more relevant one document is than another "remains arbitrary", and that the mathematics "cannot advise us on which to choose". They suggested deriving the parameters from a realistic user scenario, or reporting several combinations.[1] Their own case study showed that changing the weighting changed the relative order of the runs.[1]
- **Gain and implementation differences.** Linear and exponential gains, and the original and modern discounts, give different numbers on graded data (see the worked example), so NDCG values from different tools or papers are comparable only when the formula is the same.[1][3][11]
- **Position model.** NDCG's discount depends only on rank and does not model a user who stops after finding a satisfying result. Expected reciprocal rank, proposed by Chapelle and colleagues in 2009, is based on a cascade user model instead; in the 2010 Yahoo! challenge the organizers ranked submissions by ERR, reported NDCG for information only, and found that the best submissions by NDCG and by ERR were not the same.[4]
- **Queries with no relevant items.** When no item has positive gain, IDCG is zero and the ratio is undefined. scikit-learn assigns such samples a score of 0.[14]
- **Negative or unusual labels.** scikit-learn warns that negative values in the true relevance scores "may result in an output that is not between 0 and 1".[13]
- **Ties.** When a model gives several items the same score, their order is arbitrary. scikit-learn by default averages the gain over tied positions, citing McSherry and Najork's method for tied scores, and offers `ignore_ties=True` to skip that step for speed.[13][14]
- **Sampled evaluation.** As described above, computing NDCG on a sampled candidate set can reverse the conclusions of exact evaluation.[16]

## Comparison with other ranking metrics

| Metric | Graded relevance | Position-sensitive | Notes |
|---|---|---|---|
| [Precision](https://aiwiki.ai/wiki/precision) / recall at k | No | No (within the cutoff) | Described by BEIR's authors as rank-unaware[8] |
| MRR | No | Yes | Rank-aware but designed for binary relevance[5][8] |
| MAP | No | Yes | Mean of [average precision](https://aiwiki.ai/wiki/average_precision); rank-aware but designed for binary relevance[5][8] |
| ERR | Yes | Yes | Cascade user model; primary metric of the 2010 Yahoo! challenge[4] |
| NDCG | Yes | Yes | Logarithmic discount, normalized by the ideal ranking[1][5] |

## See also

- [Ranking](https://aiwiki.ai/wiki/ranking)
- [Information retrieval](https://aiwiki.ai/wiki/information_retrieval)
- [Average precision](https://aiwiki.ai/wiki/average_precision)
- [Recommender system](https://aiwiki.ai/wiki/recommender_system)
- [MTEB](https://aiwiki.ai/wiki/mteb)
- [Model evaluation](https://aiwiki.ai/wiki/model_evaluation)

## References

1. Järvelin, K., & Kekäläinen, J. "Cumulated gain-based evaluation of IR techniques". ACM Transactions on Information Systems, 20(4), 422-446, October 2002. https://doi.org/10.1145/582415.582418
2. Järvelin, K., & Kekäläinen, J. "IR evaluation methods for retrieving highly relevant documents". Proceedings of the 23rd Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, 41-48, July 2000. https://doi.org/10.1145/345508.345545
3. Burges, C., Shaked, T., Renshaw, E., Lazier, A., Deeds, M., Hamilton, N., & Hullender, G. "Learning to rank using gradient descent". Proceedings of the 22nd International Conference on Machine Learning (ICML '05), 89-96, 2005. https://doi.org/10.1145/1102351.1102363
4. Chapelle, O., & Chang, Y. "Yahoo! Learning to Rank Challenge Overview". JMLR: Workshop and Conference Proceedings 14, 1-24, 2011. https://proceedings.mlr.press/v14/chapelle11a/chapelle11a.pdf
5. Burges, C. J. C. "From RankNet to LambdaRank to LambdaMART: An Overview". Microsoft Research Technical Report MSR-TR-2010-82, 2010. https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/MSR-TR-2010-82.pdf
6. Wang, Y., Wang, L., Li, Y., He, D., Liu, T.-Y., & Chen, W. "A Theoretical Analysis of NDCG Type Ranking Measures". Conference on Learning Theory (COLT 2013); arXiv:1304.6480, April 2013. https://arxiv.org/abs/1304.6480
7. Craswell, N., Mitra, B., Yilmaz, E., Campos, D., & Voorhees, E. M. "Overview of the TREC 2019 deep learning track". arXiv:2003.07820, March 2020. https://arxiv.org/abs/2003.07820
8. Thakur, N., Reimers, N., Rücklé, A., Srivastava, A., & Gurevych, I. "BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models". NeurIPS 2021 Datasets and Benchmarks Track; arXiv:2104.08663. https://arxiv.org/abs/2104.08663
9. Muennighoff, N., Tazi, N., Magne, L., & Reimers, N. "MTEB: Massive Text Embedding Benchmark". Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics, 2014-2037, 2023; arXiv:2210.07316. https://arxiv.org/abs/2210.07316
10. Enevoldsen, K., Chung, I., Kerboua, I., Kardos, M., et al. "MMTEB: Massive Multilingual Text Embedding Benchmark". ICLR 2025; arXiv:2502.13595. https://arxiv.org/abs/2502.13595
11. NIST. "m_ndcg.c" (ndcg, dcg and ideal_dcg measures). trec_eval source code, GitHub. https://github.com/usnistgov/trec_eval/blob/master/m_ndcg.c
12. NIST. "m_ndcg_cut.c" (ndcg_cut measure). trec_eval source code, GitHub. https://github.com/usnistgov/trec_eval/blob/master/m_ndcg_cut.c
13. scikit-learn developers. "sklearn.metrics.ndcg_score". scikit-learn documentation. https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ndcg_score.html
14. scikit-learn developers. "sklearn/metrics/_ranking.py" (`_dcg_sample_scores` and `_ndcg_sample_scores`). scikit-learn source code, GitHub. https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/metrics/_ranking.py
15. LightGBM developers. "Parameters". LightGBM documentation. https://lightgbm.readthedocs.io/en/latest/Parameters.html
16. Krichene, W., & Rendle, S. "On Sampled Metrics for Item Recommendation (Extended Abstract)". Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence (IJCAI-21), Sister Conferences Best Papers Track, 4784-4788, August 2021. https://www.ijcai.org/proceedings/2021/0651.pdf

