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.
Glossary
Maximum Marginal Relevance (MMR)

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.
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.
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.
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.
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.
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.
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_typeparameter for vector store retrievers.
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.
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.
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.
| Feature | MMR | Extractive Summarization | Contrastive 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 |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
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.
Related Terms
Core algorithms and techniques that govern how AI models select, condense, and present information while balancing relevance against redundancy.
Diversity Constraint
A parameter in decoding or retrieval algorithms that penalizes repetition and encourages the selection of semantically varied tokens or passages. In MMR, the diversity constraint is explicitly controlled by the λ (lambda) hyperparameter, which trades off relevance against novelty. A higher diversity weight produces more comprehensive, non-redundant summaries by actively suppressing content that is too similar to what has already been selected.
Redundancy Penalty
A scoring mechanism that reduces the weight of a token or passage if it is highly similar to content already present in the generated summary or retrieved set. MMR implements this through cosine similarity between candidate passages and already-selected content. The penalty is subtracted from the relevance score, ensuring that each new sentence adds incremental information value rather than restating known facts.
Extractive Summarization
An NLP technique that identifies and directly copies the most salient sentences from a source document without altering the original wording. MMR is a foundational algorithm for extractive summarization, iteratively selecting sentences that maximize query relevance while minimizing similarity to the existing summary set. This contrasts with abstractive methods that generate novel phrasing.
Query-Focused Summarization
A summarization task that generates a concise answer specifically tailored to a user's natural language query rather than providing a general overview. MMR was originally designed for this exact use case, where the relevance term measures similarity between candidate passages and the query, while the redundancy term ensures the summary covers diverse aspects of the answer rather than repeating the same point.
Cosine Similarity
The mathematical backbone of MMR's redundancy calculation. It measures the cosine of the angle between two vectors in a high-dimensional embedding space, producing a score from -1 to 1 where 1 indicates identical direction. In MMR, cosine similarity between the candidate passage and each already-selected passage is computed, and the maximum similarity value is used as the penalty term to ensure diversity.
Information Gain Scoring
A content evaluation metric that quantifies the unique, substantive value a piece of content provides beyond what is already known. MMR operationalizes this concept algorithmically: each selected passage should maximize the marginal information gain—the relevance to the query minus the redundancy with prior selections. This ensures every sentence in a summary contributes novel information.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us