Algorithm Search⌘K

Definitionintro

Mean reciprocal rank

Also called MRR.

The mean over queries of 1/r, where r is the rank of the first relevant result.

Reciprocal rank (RR) scores a ranking by the rank rr of its first relevant document: the value is 1/r1/r, and 0 when the ranking holds no relevant document. Mean reciprocal rank (MRR) is the arithmetic mean of RR over the queries. It models a user who wants one good answer and stops at the first one, so it fits known-item search and question answering. It ignores every relevant document after the first.

Definition

Input. A ranking d(1),…,d(n)d_{(1)}, \ldots, d_{(n)} of nn distinct document ids, with ranks starting at 1, and graded judgments g(d)∈{0,1,2,…}g(d) \in \{0, 1, 2, \ldots\}, where a document that is not judged has g(d)=0g(d) = 0. A document is relevant when g(d)≥1g(d) \ge 1. RR is the number of relevant documents in the judgments. An optional cutoff kk limits the ranking to its first kk ranks.

Value. When R≥1R \ge 1, let i1i_1 be the smallest rank i≤min⁡(k,n)i \le \min(k, n) whose document is relevant. Then

RR={1/i1if i1 exists,0otherwise.\mathrm{RR} = \begin{cases} 1/i_1 & \text{if } i_1 \text{ exists,} \\ 0 & \text{otherwise.} \end{cases}
  • Gain: binary, with the threshold g≥1g \ge 1.
  • Discount: 1/i1/i at the rank of the first relevant document. Every later rank has weight 0, whatever it holds.
  • Normalization: none is needed. The best value is 1, reached when rank 1 is relevant.
  • Cutoff: trec_eval uses the whole run (file m_recip_rank.c). The TREC-8 question answering track took 5 responses per question, so its score was RR at k=5k = 5, with the possible values 0, 1/5, 1/4, 1/3, 1/2 and 1 (Voorhees 1999). Say which kk a reported MRR uses.
  • Ties: RR changes when a tie group holds the first relevant document and a nonrelevant one. This area orders by score descending, then by document id ascending. trec_eval orders tied documents by document number in reverse lexical order.
  • No relevant documents (R=0R = 0): undefined. No ranking can do better than 0, so the value says nothing about the system. Return None and leave the query out of the mean. trec_eval sets no value for a query in its judgments file with no relevant document retrieved, so the query counts as 0 in its mean.

MRR over mm queries with R≥1R \ge 1 is the arithmetic mean 1m∑qRRq\frac{1}{m}\sum_q \mathrm{RR}_q.

Claim 1. If every query has a relevant document in its ranking, at ranks i(1),…,i(m)i^{(1)}, \ldots, i^{(m)}, then MRR is the reciprocal of the harmonic mean of these ranks.

Proof. The harmonic mean of i(1),…,i(m)i^{(1)}, \ldots, i^{(m)} is H=m/∑q(1/i(q))H = m / \sum_q (1/i^{(q)}). Its reciprocal is 1m∑q1/i(q)\frac{1}{m}\sum_q 1/i^{(q)}, which is MRR. □\square

So MRR is not the reciprocal of the mean rank. For two queries with first relevant ranks 1 and 10, MRR is (1+1/10)/2=0.55(1 + 1/10)/2 = 0.55, while 1/(mean rank)=1/5.5≈0.181/\text{(mean rank)} = 1/5.5 \approx 0.18. A single query with a good rank pulls MRR up much more than a bad rank pulls it down.

Claim 2. If R=1R = 1, RR equals average precision.

Proof. With one relevant document at rank i1i_1, AP is P@i1/1=1/i1\mathrm{P@}i_1 / 1 = 1/i_1, and both are 0 when that document is not retrieved. □\square

When R≥2R \ge 2 the two are not ordered. Relevant documents at ranks 1 and 10 with R=2R = 2 give RR 1 and AP (1+2/10)/2=0.6(1 + 2/10)/2 = 0.6. Relevant documents at ranks 2 and 3 give RR 1/21/2 and AP (1/2+2/3)/2=7/12(1/2 + 2/3)/2 = 7/12, which is larger.

Examples and non-examples

The toy collection

The toy collection of this area has four queries.

Query Ranking First relevant RR
q1 "sorted array search" 1, 6, 8, 2, 4 d1 at rank 1 1
q2 "posting list merge" 8, 5, 1, 4, 2 d5 at rank 2 1/2
q3 "rank documents" 2, 6, 7, 1, 5 d7 at rank 3 1/3
q4 "quantum circuit" 1, 2, 3, 4, 5 none, R=0R = 0 None

MRR =(1+1/2+1/3)/3=(11/6)/3=11/18≈0.6111= (1 + 1/2 + 1/3)/3 = (11/6)/3 = 11/18 \approx 0.6111. If q4 is kept with the value 0, the mean becomes 11/24≈0.458311/24 \approx 0.4583.

On q1, RR is 1 although only one of the three relevant documents is near the top. Average precision on the same ranking is 29/3629/36, and it would fall if d8 and d2 moved down. RR would not change.

Ties on q1

The fixed run gives d1 and d6 the same score 2.0. With this area's rule d1 comes first and RR=1\mathrm{RR} = 1. trec_eval puts d6 first and gets RR=1/2\mathrm{RR} = 1/2. The tie-aware value of McSherry and Najork (2008), the mean over both orders, is (1+1/2)/2=3/4(1 + 1/2)/2 = 3/4.

Non-examples

  • 1/(mean rank of the first relevant document)1/\text{(mean rank of the first relevant document)}. For the three toy queries the mean rank is (1+2+3)/3=2(1 + 2 + 3)/3 = 2, which gives 1/21/2, not 11/1811/18.
  • Reciprocal rank fusion. It also uses 1/rank1/\text{rank}, but it is a method to merge several rankings into one, with a constant added to each rank. It does not score a ranking against judgments.
  • Expected reciprocal rank. It uses graded judgments and a user who may stop at any relevant document with a probability that grows with the grade. With binary grades and certain stopping at the first relevant document it reduces to RR.
  • Success at kk, which is 1 if the first kk ranks hold a relevant document and 0 otherwise. It does not separate rank 1 from rank kk.

RR takes few values, and on a single query a move of the first relevant document from rank 1 to rank 2 halves it. A difference in MRR between two systems is therefore noisy on a small query set. To claim that one system is better, use a paired test over the queries, such as the sign test or a permutation test, and give the number of queries.

References

  1. The TREC-8 Question Answering Track Report, section on evaluation (five ranked responses per question, score is the reciprocal of the rank of the first correct response, 0 if none of the five is correct)
  2. trec_eval, the TREC evaluation program by Chris Buckley, maintained by NIST, file m_recip_rank.c (1/(i+1) for the first relevant retrieved document at index i, no cutoff, no value set when no relevant document is retrieved)
  3. Frank McSherry and Marc Najork, Computing information retrieval performance measures efficiently in the presence of tied scores, ECIR 2008, LNCS 4956, pp. 414-421, tie-aware reciprocal rank
  4. W. Bruce Croft, Donald Metzler and Trevor Strohman, Search Engines, Information Retrieval in Practice, Addison-Wesley, 2010, Chapter 8 (reciprocal rank and mean reciprocal rank)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/52K6S3/text.yaml