What is MMR (Maximal Marginal Relevance)?

MMR (Maximal Marginal Relevance) is a ranking method balancing relevance and diversity by selecting, at each step, the candidate highly similar to the query yet dissimilar to results already selected.

Unlike top-k retrieval by similarity alone, which can put near-identical chunks at the top, MMR penalises overlap with already selected results at each new pick. A λ parameter sets the weight between relevance and diversity.

Topic
Embeddings, document processing and RAG
Origin
Carbonell and Goldstein, 1998

How MMR (Maximal Marginal Relevance) works

  1. A broad candidate set most similar to the query is retrieved first.
  2. The first pick is the candidate most similar to the query.
  3. At each next step the score is λ times the candidate's query similarity minus (1 minus λ) times its highest similarity to selected results; the top scorer is added.
  4. This repeats until enough are chosen; as λ nears one, ranking becomes pure similarity.

In more detail

The selection formula and normalising similarity scales

At each step MMR picks the candidate whose query similarity, weighted by λ, minus its highest similarity to already selected chunks, weighted by 1 minus λ, is largest. Because the two terms are subtracted, query-to-document and document-to-document similarities must sit on a comparable scale. If the first comes from an unnormalised BM25 or cross-encoder score while the second is cosine similarity between 0 and 1, one term dominates unless scores are min-max or sigmoid normalised first.

Computational cost and candidate pool size

Greedy MMR compares every remaining candidate with the growing selected set, so choosing k results from N candidates takes on the order of k times N comparisons or N squared if the full pairwise matrix is precomputed. That is why MMR runs as a reranking step over a bounded candidate pool (the fetch_k parameter in many libraries) rather than across a whole index of millions of chunks.

Combining a cross-encoder with MMR

A common production pattern pairs a cross-encoder with MMR: the candidate pool from hybrid search is first scored against the query by the cross-encoder and normalised to between 0 and 1, then MMR runs on the stored embeddings for document-to-document similarity. This keeps query relevance high without losing diversity.

Diversity-aware evaluation metrics

Standard metrics such as Recall@k do not penalise repetition, so evaluating MMR calls for diversity-aware metrics such as alpha-nDCG or subtopic recall. In multi-hop RAG it is also worth measuring whether the distinct facts needed for the answer actually reach the final context.

Commonly confused terms

TermHow it differs
Cross-encoder rerankerA cross-encoder reranker jointly scores each query-document pair to produce a much sharper individual relevance score, whereas MMR trades off relevance against inter-document similarity to reduce redundancy; in practice, MMR often runs after or alongside a reranker.
RRFReciprocal Rank Fusion (RRF) merges ranked lists from multiple retrievers (such as BM25 and dense search) based solely on rank positions, whereas MMR reorders a single candidate pool using explicit pairwise candidate similarity to enforce diversity.

Why MMR (Maximal Marginal Relevance) matters for on-premises AI

If chunks in a RAG context repeat each other, the model sees the same information repeatedly and may miss different relevant information. The paper introducing the method proposed MMR to reduce redundancy while keeping query relevance, both when reranking retrieved documents and when selecting passages for text summarisation. A survey of search result diversification argues every query is somewhat ambiguous, so a ranking should cover the different information needs it may represent. The cost is that a badly tuned λ lets less relevant chunks into context.

ON-PREMISES EXAMPLE

A media company's news archive assistant reranks retrieval results with MMR so its context holds stories covering different angles of an event rather than near-identical agency copies.

Common questions

How is λ chosen in MMR?

By testing on validation questions. A high λ favours relevance; a low λ favours diversity.

How does MMR differ from a reranker model?

A reranker measures each candidate's relevance to the query better. MMR also accounts for repetition among selected results; the two can be combined.

Sources

In the glossary: Glossary, M to Q

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.