CH14 chain (Chains)
The chain creation phase is a step that binds all of the previous seven-step processes together and assembles them into one RAG pipeline to complete.
The structure below represents the structure of the document-based RAG.
Reference
Copy
# Run Chain
# Enter a query for the document and print out the answer.
question = "The name of the AI developed by Samsung Electronics is?"
response = chain.invoke(question)Below is the quintet code for the finished chain.
Copy
# Create a Chain
chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)LCEL (LangChain Expression Language) grammar is used to tie the entire process of the previous 7 steps into one chain.
Reference
Last updated