What is the main purpose of similarity search in Langchain?
Think about how Langchain uses vectors to find related content.
Similarity search uses vector embeddings to find documents closest in meaning to the query.
What unique behavior does Maximal Marginal Relevance (MMR) retrieval add compared to simple similarity search?
MMR tries to mix relevance with variety in results.
MMR retrieval selects documents that are relevant but also diverse to reduce repetition.
Which code snippet correctly initializes an MMR retriever with a vector store in Langchain?
from langchain.vectorstores import FAISS from langchain.retrievers import MMRRetriever vectorstore = FAISS.load_local('my_faiss_index') # Choose the correct MMR retriever initialization:
Check the parameter names carefully in the MMRRetriever constructor.
The correct parameters are vectorstore, k, fetch_k, and lambda_mult.
Given a query, what difference would you expect in the list of documents returned by similarity search vs MMR retrieval?
Think about how MMR tries to reduce repeated information.
Similarity search focuses on closeness to query, MMR adds diversity to avoid repeated content.
You use MMR retrieval but notice the results are very similar and not diverse. Which mistake in your code is most likely causing this?
retriever = MMRRetriever(vectorstore=vectorstore, k=5, fetch_k=5, lambda_mult=0.0) results = retriever.get_relevant_documents(query)
Check the effect of the lambda_mult parameter on diversity.
Lambda_mult controls the trade-off between relevance and diversity; 0 means no diversity.