Maximal Marginal Relevance (MMR) is a greedy algorithm that constructs a ranked list by maximizing a linear combination of relevance and novelty. For each candidate, it computes a score that rewards high similarity to the query while penalizing high similarity to previously selected items, controlled by a trade-off parameter lambda.
Glossary
Maximal Marginal Relevance (MMR)

What is Maximal Marginal Relevance (MMR)?
Maximal Marginal Relevance (MMR) is a re-ranking algorithm that iteratively selects documents or keyphrases by balancing their relevance to a query against their redundancy with items already selected, ensuring a diverse result set.
Originally proposed by Carbonell and Goldstein for text summarization and information retrieval, MMR is widely applied in keyphrase extraction to prevent the selection of near-duplicate phrases. By suppressing redundant candidates, it ensures the final set of keyphrases provides broad topical coverage of the source document.
Key Features of MMR
Maximal Marginal Relevance (MMR) is a re-ranking algorithm that constructs a diverse yet relevant set of keyphrases by iteratively penalizing candidates that are too similar to already selected terms.
The Core Greedy Algorithm
MMR builds the final keyphrase set iteratively. In each step, it selects the candidate that maximizes the MMR score, which is a linear combination of relevance and novelty. The algorithm starts with the most relevant phrase and then penalizes subsequent candidates based on their maximum similarity to the already chosen set, ensuring broad topical coverage.
The Lambda Hyperparameter
The λ (lambda) parameter, typically ranging from 0 to 1, controls the trade-off between relevance and diversity.
- λ=1: Pure relevance ranking; the algorithm ignores redundancy and selects the top-scoring candidates.
- λ=0: Maximal diversity; the algorithm aggressively penalizes similarity, potentially selecting less relevant but unique phrases.
- λ=0.5 to 0.7: A common balanced range for keyphrase extraction, ensuring the selected terms are both salient and distinct.
Similarity Metric Selection
The penalty term in MMR relies on a pairwise similarity function between candidate phrases. The choice of this metric critically shapes the final output.
- Cosine Similarity on TF-IDF vectors: A classic, sparse representation that penalizes lexical overlap.
- Cosine Similarity on Embeddings: Using models like BERT or Sentence-BERT captures semantic redundancy, penalizing synonyms and paraphrases.
- Jaccard Similarity: A simple token-overlap coefficient useful for penalizing exact word repetition.
Relevance Scoring Foundation
MMR is a re-ranking framework, not a standalone extraction method. It requires an initial relevance score for each candidate phrase. This score can come from any upstream method:
- TF-IDF or BM25 for statistical salience.
- TextRank for graph-based centrality.
- Embedding similarity (e.g., cosine similarity between the phrase embedding and the document embedding). MMR then adjusts these raw relevance scores by subtracting the redundancy penalty.
Redundancy Penalty Mechanism
For a candidate phrase c and the set of already selected phrases S, the penalty is calculated as max_{s in S} sim(c, s). This means a candidate is penalized based on its similarity to the single most similar already-selected phrase. This max-based penalty aggressively prevents near-duplicate keyphrases from entering the final set, promoting a high-level topical diversity rather than a clustered set of related terms.
Frequently Asked Questions
Clear, technical answers to the most common questions about the Maximal Marginal Relevance algorithm and its role in keyphrase extraction and search diversification.
Maximal Marginal Relevance (MMR) is a greedy re-ranking algorithm that iteratively selects documents or keyphrases by balancing their relevance to a query against their redundancy with items already selected. The core mechanism uses a linear combination formula: MMR = Argmax[ λ * Sim(D_i, Q) - (1 - λ) * max Sim(D_i, D_j) ], where λ controls the diversity-relevance trade-off. At each iteration, the algorithm computes the marginal gain of adding a candidate—subtracting the maximum similarity it shares with the existing result set from its query relevance score. This ensures the final ranked list maximizes novelty while minimizing repetition, making it essential for search result diversification and keyphrase extraction where presenting redundant information degrades user utility.
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.
Related Terms
Explore the core algorithms and evaluation concepts that surround Maximal Marginal Relevance in the keyphrase extraction pipeline.
TextRank
A graph-based ranking algorithm that builds a word or phrase co-occurrence network and applies PageRank to identify the most salient keyphrases.
- Mechanism: Vertices are lexical units; edges represent co-occurrence within a sliding window.
- Redundancy Handling: Unlike MMR, TextRank relies on graph centrality rather than explicit diversity penalties.
- Use Case: Unsupervised extraction of present keyphrases without external corpora.
EmbedRank
An embedding-based approach that ranks candidate phrases by the cosine similarity between their sentence embeddings and the document embedding.
- Semantic Core: Uses Sentence-BERT or similar models to capture topical alignment.
- MMR Variant: EmbedRank++ applies MMR to the ranked list to penalize redundancy among selected phrases.
- Advantage: Captures semantic similarity beyond exact lexical overlap.
Reciprocal Rank Fusion
A robust data fusion method that combines ranked lists by summing the reciprocal of the rank positions assigned to each candidate.
- Formula:
RRF_score(d) = Σ 1/(k + rank_i(d))where k is a constant (typically 60). - Relationship to MMR: Often used to merge the output of multiple extraction algorithms before applying MMR re-ranking.
- Strength: Outperforms linear combination when rank distributions are disparate.
F1@K
An evaluation metric computing the harmonic mean of precision and recall for the top-K predicted keyphrases against a gold-standard set.
- Precision@K: Correct predictions in top-K / K.
- Recall@K: Correct predictions in top-K / total gold keyphrases.
- MMR Context: MMR optimizes for this metric by ensuring the top-K set is both relevant and diverse.
Candidate Scoring
The process of assigning a numerical weight to each candidate phrase based on features like frequency, position, and semantic similarity.
- Features: TF-IDF, first occurrence offset, POS tag patterns, embedding similarity.
- Pre-MMR Step: Candidate scoring establishes the initial relevance ranking that MMR then re-orders for diversity.
- Supervised Variants: Models like BERT-KPE learn to score candidates directly from labeled data.
Phraseness vs. Informativeness
Two orthogonal scoring dimensions used in unsupervised keyphrase extraction.
- Phraseness: Measures how linguistically well-formed a candidate is (e.g., noun phrase chunking).
- Informativeness: Measures how well a phrase captures the document's topical content.
- MMR Integration: MMR primarily operates on the informativeness dimension, ensuring selected phrases cover distinct aspects of the document.

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