Thuta Learning
LangChain
AdvancedAIAdvanced

Retrieval Chain

LangChainLesson 12

In RAG, the documents that best match the user's query are searched for in the vector store using a Retriever. Those documents and the original query are then sent to the LLM to generate an answer.

python
# Create a retriever from the vector store
retriever = vectorstore.as_retriever()

# Create a chain that combines the retrieved documents and the question
# and sends it to the LLM.
# (This requires a more complex chain setup)

response = qa_chain.invoke({"query": "What is the main topic of the document?"})
You should see
(The LLM will return an answer based on the information in the document you provided)

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Retrieval Chain | Thuta Learning