A. Calling 'get_relevant_documents' instead of 'retrieve_documents'.
B. Using 'k' instead of 'top_k' when initializing MMRRetriever.
C. Missing import statement for MMRRetriever.
D. Using 'lambda_mult' instead of 'lambda' parameter.
Solution
Step 1: Check parameter names in MMRRetriever initialization
The parameters k and lambda_mult are correct.
Step 2: Confirm method name correctness
get_relevant_documents is a valid method for retrievers.
Final Answer:
Missing import statement for MMRRetriever. -> Option C
Quick Check:
Missing import = NameError [OK]
Hint: Import MMRRetriever before use [OK]
Common Mistakes:
Forgetting import statement for MMRRetriever
Confusing method names
Wrong parameter names like top_k or lambda
5. You want to retrieve 3 documents related to "climate change" using Langchain. You want results that are relevant but also cover different aspects like causes, effects, and solutions. Which retrieval method and parameters should you choose?
hard
A. Use MMR retrieval with k=3 and lambda_mult=0 to get only closest matches.
B. Use similarity search with k=3 for closest matches only.
C. Use similarity search with k=1 repeated 3 times to get variety.
D. Use MMR retrieval with k=3 and lambda_mult=0.8 to balance relevance and diversity.
Solution
Step 1: Identify need for relevance and diversity
You want documents that are relevant but cover different aspects, so diversity is important.
Step 2: Choose retrieval method and parameters
MMR retrieval balances relevance and diversity using lambda_mult. A value like 0.8 prioritizes relevance while introducing some diversity.
Final Answer:
Use MMR retrieval with k=3 and lambda_mult=0.8 to balance relevance and diversity. -> Option D