Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
LangChain - RAG Chain Construction
Identify the error in this code snippet:
retriever = ContextualCompressionRetriever()
results = retriever.get_relevant_documents('query')
AIncorrect method name get_relevant_documents
BQuery should be a list, not a string
CMissing base retriever argument in constructor
DContextualCompressionRetriever cannot be instantiated
Step-by-Step Solution
Solution:
  1. Step 1: Check constructor usage

    ContextualCompressionRetriever requires a base retriever argument when instantiated.
  2. Step 2: Verify method and argument types

    Method name and query type are correct; error is missing argument.
  3. Final Answer:

    Missing base retriever argument in constructor -> Option C
  4. Quick Check:

    Constructor requires base retriever = B [OK]
Quick Trick: Always pass base retriever when creating ContextualCompressionRetriever [OK]
Common Mistakes:
  • Forgetting required constructor arguments
  • Misnaming methods
  • Passing wrong query types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes