Inferensys

Glossary

Maximum Marginal Relevance (MMR)

An algorithm for information retrieval and summarization that selects passages by balancing their relevance to a query against their similarity to already-selected content to reduce redundancy.
Developer working on RAG retrieval system, document chunks visible on screen, technical workspace with code editor.
INFORMATION RETRIEVAL

What is Maximum Marginal Relevance (MMR)?

A query-focused algorithm for text selection and summarization that balances relevance against novelty to reduce redundancy in retrieved results.

Maximum Marginal Relevance (MMR) is an iterative algorithm for information retrieval and text summarization that selects passages by maximizing their relevance to a user query while simultaneously minimizing their similarity to documents already selected. First proposed by Carbonell and Goldstein in 1998, MMR constructs a ranked list where each newly chosen item is the one that best satisfies a linear combination of query relevance and a diversity constraint, explicitly penalizing redundancy.

The algorithm operates by computing a marginal relevance score for each candidate document at every iteration: MMR = argmax[λ * Sim(D_i, Q) - (1-λ) * max(Sim(D_i, D_j))], where λ controls the relevance-diversity trade-off. This redundancy penalty ensures the final result set provides comprehensive coverage of the information space rather than returning near-duplicate passages, making MMR foundational to modern query-focused summarization and retrieval-augmented generation pipelines.

Algorithm Mechanics

Key Characteristics of MMR

Maximum Marginal Relevance (MMR) is a greedy algorithm that constructs a ranked list or summary by iteratively selecting passages that maximize a linear combination of query relevance and novelty, penalizing similarity to already-selected items to reduce redundancy.

01

The Core Lambda Parameter

MMR balances two competing objectives using a mixing parameter λ (lambda):

  • λ = 1: Pure relevance ranking. The algorithm selects items solely based on similarity to the query, ignoring redundancy entirely.
  • λ = 0: Pure diversity ranking. The algorithm maximizes novelty, selecting items that are maximally dissimilar to each other.
  • Typical values range from 0.5 to 0.7, providing a tunable trade-off between relevance and diversity in the final result set.
02

Greedy Incremental Selection

MMR builds its output set iteratively, one document at a time, rather than evaluating all possible combinations globally.

  • The first selection is always the document with the highest pure relevance score to the query.
  • Each subsequent selection re-scores all remaining candidates by subtracting a penalty proportional to their maximum similarity to any already-chosen document.
  • This greedy approach is computationally efficient, with a time complexity of O(n²) for selecting k items from a candidate set of size n, making it practical for real-time search and summarization.
03

Redundancy Penalty Mechanism

The novelty component of MMR explicitly penalizes content that is too similar to what has already been selected.

  • Similarity is typically computed using cosine similarity between TF-IDF or embedding vectors.
  • The penalty is calculated as the maximum similarity between a candidate and any previously selected item, not the average similarity.
  • This max-penalty approach aggressively suppresses near-duplicate content, ensuring each selected passage contributes unique information to the final summary or result list.
04

MMR in Retrieval-Augmented Generation

MMR is a critical post-retrieval step in modern RAG pipelines to prevent context window pollution.

  • After a vector database returns a set of top-k relevant chunks, MMR re-ranks them to maximize information diversity within the limited token budget sent to the LLM.
  • This prevents the model from receiving five nearly identical passages about the same sub-topic, which wastes context and provides no additional grounding value.
  • Frameworks like LangChain and LlamaIndex implement MMR as a standard search_type parameter for vector store retrievers.
05

Mathematical Formulation

The MMR score for a candidate document Dᵢ given a query Q and the set of already-selected documents S is defined as:

MMR(Dᵢ) = λ · Sim(Dᵢ, Q) — (1 — λ) · max(Dⱼ ∈ S) Sim(Dᵢ, Dⱼ)

  • Sim(Dᵢ, Q): The relevance score between the candidate and the query.
  • max(Dⱼ ∈ S) Sim(Dᵢ, Dⱼ): The highest similarity between the candidate and any already-selected document.
  • The subtraction of the penalty term directly reduces the score of candidates that are redundant with the existing set.
06

Origin and Primary Use Cases

Introduced by Carbonell and Goldstein in 1998, MMR was originally designed for text summarization and information retrieval.

  • Query-focused summarization: Producing concise, non-redundant summaries that address a specific user query.
  • Search result diversification: Ensuring the top results for an ambiguous query cover all possible interpretations.
  • Recommender systems: Presenting users with a diverse set of recommendations rather than highly similar items.
  • The algorithm remains widely used because it requires no training and is fully transparent in its selection logic.
COMPARATIVE ANALYSIS

MMR vs. Related Summarization Techniques

A feature-level comparison of Maximum Marginal Relevance against other core summarization and decoding strategies used to control redundancy and relevance in AI-generated outputs.

FeatureMMRExtractive SummarizationContrastive Decoding

Primary Objective

Maximize relevance while minimizing redundancy

Select most salient existing sentences

Amplify expert model behavior over amateur model

Output Type

Extractive (passage selection)

Extractive (sentence selection)

Abstractive (novel token generation)

Redundancy Handling

Explicit cosine similarity penalty

Implicit via salience ranking only

Implicit via logit contrast

Query Dependence

Requires a user query for relevance scoring

Optional; can be generic or query-focused

Not query-dependent

Requires External Models

Typical Latency Overhead

Moderate (pairwise similarity computation)

Low (simple ranking)

High (dual forward passes)

Primary Use Case

Search result diversification, multi-document summarization

News summarization, snippet generation

Improving factual accuracy in open-ended generation

MMR EXPLAINED

Frequently Asked Questions

Clear, technical answers to the most common questions about the Maximum Marginal Relevance algorithm and its role in reducing redundancy in AI-generated summaries and search results.

Maximum Marginal Relevance (MMR) is an information retrieval and text summarization algorithm that selects passages by iteratively balancing their relevance to a user's query against their similarity to already-selected content. The core mechanism uses a linear combination formula: MMR = argmax[λ * Sim1(Di, Q) - (1-λ) * max Sim2(Di, Dj)], where λ controls the diversity-relevance trade-off. At each step, the algorithm scores every candidate document Di based on how well it matches the query Q (using a metric like cosine similarity on TF-IDF or embeddings), then subtracts a penalty proportional to its maximum similarity to any document Dj already in the selected set. This greedy approach ensures the final ranked list maximizes coverage of the information space while minimizing redundant content, making it foundational for query-focused summarization and diversity-constrained retrieval in modern AI systems.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.