AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

QdrantVectorStore.As_retriever(Search_type='Mmr') Inverts Lambda_mult Semantics

The QdrantVectorStore MMR retriever passes LangChain's lambda_mult as Qdrant's diversity parameter, but Qdrant interprets diversity as 1 - lambda, resulting in inverted behavior: lambda_mult=0.0 maximizes relevance instead of diversity.

highConfidence 95%Langchain_qdrantAffected V1.1.0

Origin Analysis

In langchain_qdrant/qdrant.py, the _search_mmr method constructs models.Mmr(diversity=lambda_mult, candidates_limit=fetch_k). However, Qdrant's Mmr model defines diversity as 1 - lambda, where lambda controls the trade-off between relevance and diversity. Since LangChain's lambda_mult is the direct trade-off parameter, passing it as diversity reverses the effect.
Use the provided Python script in the issue: create Qdrant collection, add documents, call vector_store.as_retriever(search_type='mmr', search_kwargs={'k':3, 'fetch_k': len(docs), 'lambda_mult': 0.0}), invoke query 'What is LangChain?'. Observe that output documents are highly relevant (low diversity), while manual MMR with lambda_mult=0.0 selects diverse documents. This indicates inversion.

Fixing Code Block

Edge Case Audit

Applying this patch changes retrieval semantics; users who previously tuned lambda_mult based on observed inverted behavior will see changed results. Re-evaluate hyperparameters after upgrade. Ensure all code paths using MMR with Qdrant are tested. No concurrency or threading issues anticipated. Rollback by reverting this patch.

Ecosystem Topology