Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Langchain ai Langchain Maximal Marginal Relevance

From Leeroopedia
Revision as of 18:05, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/Langchain_ai_Langchain_Maximal_Marginal_Relevance.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Information_Retrieval, Vector_Search
Last Updated 2026-02-11 00:00 GMT

Overview

A retrieval strategy that balances relevance to the query with diversity among selected documents to reduce redundancy in results.

Description

Standard similarity search may return highly similar documents that cover the same information. Maximal Marginal Relevance (MMR) addresses this by iteratively selecting documents that are both relevant to the query and dissimilar to already-selected documents. The lambda_mult parameter controls the tradeoff: values near 1.0 favor relevance, values near 0.0 favor diversity.

Usage

Use MMR search when result diversity matters, such as when providing context to an LLM where redundant information wastes context window tokens.

Theoretical Basis

MMR=argmaxdiRS[λSim(di,q)(1λ)maxdjSSim(di,dj)]

Where R is the candidate set, S is the selected set, q is the query, and λ controls the relevance-diversity tradeoff.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment