MMR relevance & diversity calculator
Change candidate relevance and pairwise similarity, then see why each result is selected. Compare a relevance-only order with diversity after a relevance-first seed.
Supply candidates and pairwise similarities
Calculations run in this page. This tool does not save inputs, send them to a calculation service or put them in the URL. Inputs and results are masked from optional session recording; other page scripts and extensions remain outside these guarantees. Use non-sensitive example IDs.
Candidates: ID,score per line, at most 12 IDs. Similarities: ID,ID,score once for every unordered pair; A,B and B,A are the same pair. Omit diagonal/self pairs. IDs: case-sensitive ASCII letters, digits, underscore or hyphen, 1–32 characters. Scores: 0–1, up to three decimal places, leading zero required. No headers, quoted fields, negative scores or exponents. Blank lines ignored and field-edge spaces trimmed. Each box is limited to 4,096 UTF-16 code units.
Lambda: 0–1 with up to three decimal places. Output count: integer 0–12. All supplied rows are validated even when the output count is zero. The seed is always the highest-relevance candidate, including at lambda zero. Ties use ascending ASCII ID.
Selection summary
4 candidates · 6 unordered pairs · lambda 0.500 · 3 selected.
Selection order: A → C → D
After the seed, maximize lambda × relevance − (1 − lambda) × maximum similarity to the selected set. No minimum score threshold is applied; negative objectives can still win. Output count cannot recover a missing candidate.
Candidate trace at every step
Step 1: select A (relevance-first seed)
Previously selected: None. Seed candidates are compared by relevance; no redundancy objective is evaluated.
| Candidate | Relevance | Max similarity | Relevance term | Redundancy penalty | Objective | Decision |
|---|---|---|---|---|---|---|
| A | 0.950 | Not applied | Not applied | Not applied | Seed | Selected |
| B | 0.940 | Not applied | Not applied | Not applied | Seed | Not selected this step |
| C | 0.800 | Not applied | Not applied | Not applied | Seed | Not selected this step |
| D | 0.650 | Not applied | Not applied | Not applied | Seed | Not selected this step |
Step 2: select C
Previously selected: A. All remaining candidates are compared below; equal objectives use ASCII ID.
| Candidate | Relevance | Max similarity | Relevance term | Redundancy penalty | Objective | Decision |
|---|---|---|---|---|---|---|
| C | 0.800 | 0.200 | 0.400000 | 0.100000 | 0.300000 | Selected |
| D | 0.650 | 0.100 | 0.325000 | 0.050000 | 0.275000 | Not selected this step |
| B | 0.940 | 0.990 | 0.470000 | 0.495000 | -0.025000 | Not selected this step |
Step 3: select D
Previously selected: A, C. All remaining candidates are compared below; equal objectives use ASCII ID.
| Candidate | Relevance | Max similarity | Relevance term | Redundancy penalty | Objective | Decision |
|---|---|---|---|---|---|---|
| D | 0.650 | 0.400 | 0.325000 | 0.200000 | 0.125000 | Selected |
| B | 0.940 | 0.990 | 0.470000 | 0.495000 | -0.025000 | Not selected this step |
Copy the trace report
Select and copy the report to retain normalized inputs, policies and every candidate contribution. Integer units are documented in the report; displayed objectives have six exact decimal places for this input precision.
Understand the four-candidate example
The supplied scores are invented teaching values, not measured embedding outputs. A has the highest relevance and is selected first. At lambda 0.5, B receives 0.470000 − 0.495000 = −0.025000, C receives 0.400000 − 0.100000 = 0.300000, and D receives 0.325000 − 0.050000 = 0.275000. C wins the second step.
After C is selected, D’s maximum similarity to the selected set rises from 0.1 to 0.4. Its next objective is 0.325000 − 0.200000 = 0.125000. The selected order is A, C, D. The trace shows the candidates that lost each step, so a winner can be checked against all remaining alternatives.
Lambda zero still uses the declared seed
This explorer always starts with the highest-relevance candidate, breaking ties by ascending ASCII ID. At lambda zero it then chooses the least redundant remaining candidate at each step. The sample becomes A, D, C. At lambda one, the sample becomes A, B, C. These are this tool’s explicit initialization and tie policies, not a claim that every MMR library returns the same order.
A similarity matrix is a policy input
Enter each unordered pair once. Reversing a pair does not create a new relationship, and duplicates are rejected. The matrix is symmetric by construction, with diagonal one implicit. Every pair is required even if you request a short output. Missing pairs are errors, rather than silently becoming zero similarity.
The calculator accepts nonnegative scores from zero through one. Raw cosine scores can be negative; those inputs require a different scoring contract. This tool does not clip them or claim that the supplied matrix can be generated by a particular embedding model. Shared ranges do not establish calibration between unrelated scoring methods.
Exact decisions for the allowed input precision
Inputs allow up to three decimal places. The calculator compares integer objective numerators over one million, keeping ties exact under that bound. A tie is resolved by document ID, independent of the order you pasted candidates. The report includes the integer units and full trace so another implementation can reproduce the decisions.
Candidate selection is not answer evaluation
MMR chooses from the candidates you supplied. It does not retrieve missing passages, enforce source quotas, establish factual accuracy or count prompt tokens. A negative objective can still be the largest remaining objective; this calculator has no quality threshold or early stopping rule beyond output count and candidate availability.
Evaluate retained evidence on judged queries when applying the method to RAG. A less similar passage can be irrelevant, while two overlapping passages may contain necessary supporting detail. Use the retrieval metrics calculator for labeled relevance calculations.
Continue from the calculation to an implementation
The MMR Python guide includes an exact-arithmetic reference and discusses score, depth and evaluation boundaries. Use the RRF calculator to merge ranked lists; it addresses a different selection stage.
Primary references: the original MMR paper and Elastic’s MMR documentation. This educational calculator returns greedy selection order; an engine can preserve another presentation order and requires separate integration checks.