Learn/LangChain Mastery/Part 6 · 5. Retrieval & RAG Patterns
Lesson 39 of 68
SyllabusLangChain Mastery · Part 6

Similarity vs MMR

Diversity leads to better answers. Avoiding the echo chamber.

Course outline & contents
LangChain Mastery
The Retriever InterfaceSimilarity vs MMRMulti-Query RetrievalRAG-FusionQuery DecompositionParent Document RetrievalContextual CompressionPost-Retrieval Re-RankingConversational RAG & History

User asks: "Tell me about the iPhone 15 camera."

Similarity Search (k=4) returns:

  1. iPhone 15 has a 48MP camera.
  2. The camera on iPhone 15 is 48MP.
  3. The iPhone 15 features a 48MP sensor.
  4. 48MP is the resolution of the iPhone 15.

The LLM gets 4 versions of the same sentence. It misses info about "Night Mode," "Zoom," or "Video." This is Redundancy Collapse.

MMR tries to maximize Relevance (Similarity) while punishing Redundancy (Similarity to already selected docs).

Algorithm intuition:

  1. Find the most similar doc (Doc A). Select it.
  2. Find the next doc that is similar to Query BUT dissimilar to Doc A.
  3. Repeat.

MMR (k=4) returns:

  1. iPhone 15 has a 48MP camera. (High Relevance)
  2. Night Mode is improved by 2x. (High Relevance, Low overlap with #1)
  3. Video supports 4K60. (High Relevance, Low overlap with #1, #2)
  4. The new Telephoto lens is 5x. (High Relevance, Low overlap with #1, #2, #3)

If your RAG answers feel repetitive or shallow, switch to MMR. It forces the retriever to explore the "Concept Space" rather than getting stuck in one corner.

Key Intuition: "Don't tell me the same thing 5 times."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonThe Retriever InterfaceNext lesson →Multi-Query Retrieval