0
0
LangChainframework~10 mins

Multi-query retrieval for better recall in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the MultiQueryRetriever class from langchain.

LangChain
from langchain.retrievers import [1]
Drag options to blanks, or click blank then click option'
AMultiQueryRetriever
BBaseRetriever
CVectorStoreRetriever
DSimpleRetriever
Attempts:
3 left
💡 Hint
Common Mistakes
Importing a wrong retriever class like BaseRetriever or SimpleRetriever.
Forgetting to import from the retrievers submodule.
2fill in blank
medium

Complete the code to create a MultiQueryRetriever with two queries.

LangChain
retriever = MultiQueryRetriever(
    retrievers=[
        retriever1,
        retriever2
    ],
    queries=[[1]]
)
Drag options to blanks, or click blank then click option'
A['How to code?']
B['AI', 'ML']
C['What is AI?', 'Explain machine learning']
D['Query1', 'Query2', 'Query3']
Attempts:
3 left
💡 Hint
Common Mistakes
Providing too few or too many queries.
Using short keywords instead of full questions.
3fill in blank
hard

Fix the error in the code to correctly retrieve documents using MultiQueryRetriever.

LangChain
docs = retriever.[1]('Explain AI and ML')
Drag options to blanks, or click blank then click option'
Afetch
Bsearch
Cretrieve_docs
Dget_documents
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'fetch' or 'search'.
Confusing method names from other libraries.
4fill in blank
hard

Fill both blanks to create a MultiQueryRetriever that combines two retrievers and uses two queries.

LangChain
retriever = MultiQueryRetriever(
    retrievers=[[1], [2]],
    queries=['What is AI?', 'What is NLP?']
)
Drag options to blanks, or click blank then click option'
Aretriever_a
Bretriever_b
Cretriever_c
Dretriever_d
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same retriever twice.
Using undefined retriever variable names.
5fill in blank
hard

Fill all three blanks to create a MultiQueryRetriever, run a query, and print the number of documents retrieved.

LangChain
retriever = MultiQueryRetriever(
    retrievers=[[1], [2]],
    queries=['Define AI', 'Define ML']
)
docs = retriever.[3]('Define AI and ML')
print(len(docs))
Drag options to blanks, or click blank then click option'
Aretriever_x
Bretriever_y
Cget_documents
Dretriever_z
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names for retrieval.
Using undefined retriever variables.