MMR — Maximal Marginal Relevance

Note: MMR (Maximal Marginal Relevance) is a diversity metric and reranking strategy. Do not confuse with MRR (Mean Reciprocal Rank), a ranking quality metric.

A reranking method that balances relevance and novelty. Instead of ranking purely by relevance, MMR penalizes results that are similar to already-selected results — reducing redundancy while preserving quality.

Formula

Where:

  • = candidate result set
  • = already-selected results
  • = query
  • = query-document relevance (e.g., cosine similarity)
  • = document-document similarity
  • = tradeoff parameter (0 = pure diversity, 1 = pure relevance)

Algorithm

Greedy iterative selection:

  1. Select the most relevant document as the first result
  2. For each subsequent position, pick the document that maximizes the MMR score — highest relevance minus penalty for similarity to already-chosen documents
  3. Repeat until the result list is full

Properties

  • Tunable: λ controls the relevance/diversity tradeoff
  • Greedy: not globally optimal, but O(n) per step — practical for reranking
  • Similarity-agnostic: works with any similarity function (BM25 score, embedding cosine, etc.)

Use Cases

  • Search result diversification: reduce ten near-duplicate product results in favor of different categories
  • Keyphrase extraction: select diverse keyphrases from a document rather than all from the same topic cluster
  • RAG context selection: choose diverse passages for LLM context to avoid redundant information
  • Facet result pages: ensure different facet values are represented in top results

Tradeoffs

Relevance-focused (λ→1)Diversity-focused (λ→0)
Top results are most relevantTop results cover more aspects
May show redundant contentMay surface lower-relevance items
Better for known-item searchBetter for exploratory / ambiguous queries

Complexity and Guarantees

Selecting the set that maximizes an MMR-style objective is NP-hard; the greedy procedure above is a heuristic. The DkMIPS work (Diversity-Aware k-Maximum Inner Product Search Revisited) splits the redundancy penalty into two common variants and shows they behave differently:

  • Average pairwise similarity gives a submodular objective. Running two greedy sets in parallel (DualGreedy) then has a constant 1/4 approximation, with an additive regularization term.
  • Maximum pairwise similarity, the form in the formula above, is neither submodular nor supermodular, so plain greedy has only a data-dependent bound.

DkMIPS also moves the MMR objective out of a post-retrieval rerank and into the Maximum Inner Product Search query itself, using inner product for both relevance and redundancy.

Swapping the Relevance Term

MMR’s relevance term is only as good as the similarity behind it. Jevjitsu - How We Tried Generalized Classifiers on Everything measured this on 240 WANDS queries. Qdrant’s built-in MMR at diversity 0.5, with relevance as vector similarity to the query, removed every near-duplicate pair but dropped nDCG@10 from 0.683 to 0.561. Replacing the relevance term with a Jev relevance probability (diversity 0.7) kept nDCG@10 at 0.719 with 0.22 near-duplicate pairs per page. Running MMR first and letting Jev rerank its top 20 gave 0.723 with 0.04. Both beat plain hybrid search on relevance and repetition. Neither matched a plain Jev rerank (0.769), which left duplicates in place and narrowed the page to 2.41 product classes. Even a human-label ordering showed only 2.66 classes, so relevant results can still be repetitive.