Introduction to LangGraph's Multi-Agent RAG Research template for efficient document retrieval and query answering in LangChain.
Key Takeaways
- Multi-agent architecture enhances modularity and efficiency in research and retrieval tasks.
- Subgraphs enable hierarchical graph structures facilitating complex workflows.
- State management is crucial for communication between parent and child agents.
- LangGraph's template structure promotes clean code organization and scalability.
- The approach supports breaking down complex queries into manageable research steps.
What the video covers
- Introduction of the Rag Research Agent template for LangGraph Studio, inspired by LangChain documentation Q&A service.
- Demonstration of query analysis to determine relevance and need for additional user info.
- Breakdown of user questions into multiple research steps and queries.
- Use of a multi-agent architecture with a parent agent and a child researcher agent.
- Parent agent handles query analysis, routing, research plan creation, and user response.
- Researcher agent conducts document retrieval from a vector store based on the research plan.
- Explanation of subgraphs in LangGraph, where subgraphs act as nodes within parent graphs.
- Code organization includes separate modules for each graph with graph.py and state.py files.
- State schema defines communication between parent and child graphs, including message passing and query routing.
- The system exemplifies a custom multi-agent workflow with predefined agent call order.
Chapters
- 00:00Introduction to Rag Research Agent Template
- 00:29Query Analysis and Relevance Determination
- 01:00Creating a Research Plan and Breaking Down Queries
- 01:32Document Retrieval and Combining Results
- 02:09Multi-Agent Architecture Overview
- 02:42Agents Roles and Subgraphs in LangGraph
- 03:29Code Organization and Module Structure
- 03:58State Schema and Parent-Child Graph Communication
- 04:54Final Thoughts and Encouragement
Full Transcript — Download SRT & Markdown
Speaker A
Hi everyone, this is Faim from L Chain. Today, I'd like to introduce a new template we're releasing for Langra Studio: the Rag Research Agent template. It was motivated by our work on the Chat L Chain service we have for helping users answer questions about L Chain documentation.
Speaker A
answer questions about L chain documentation let's dive in going to ask a simple question about L chain documentation what are the runnables in L chain how me walk you through what's happening here first we're going to analyze the query and decide is it about
Speaker A
Let's dive in. We're going to ask a simple question about L Chain documentation: What are the runnables in L Chain? Let me walk you through what's happening here. First, we're going to analyze the query and decide: is it about L Chain? Do we need more information from the user, or is it completely unrelated? In our case, it is related to L Chain.
Speaker A
multiple research steps for each of those steps we're going to call the conduct research node and we're going to further do two additional steps one calling conduct research we're going to first take the question from the research step and break it down into
Speaker A
Then, we're going to create a research plan or effectively break down the original user's question into multiple research steps. For each of those steps, we're going to call the Conduct Research node, and we're going to further do two additional steps. One, calling Conduct Research, we're going to first take the question from the research step and break it down into individual queries.
Speaker A
end we're going to pass combine documents to the parent graph to respond to the user with the context of the retrieve documents this system is an example of a multi-agent architecture for more information on MTI multi- aent architectures check out Harrison's
Speaker A
For each of those queries, we're going to retrieve documents from our vector store. We're going to run that for each step in the research plan until we have all of the documents for each step. Then, at the end, we're going to pass combined documents to the parent graph to respond to the user with the context of the retrieved documents.
Speaker A
routing creating research plan and then responding to the user as well as the researcher agent that is actually conducting research or ring the documents based on the research plan there're two agents and what enables adding the child researcher agent in
Speaker A
This system is an example of a multi-agent architecture. For more information on multi-agent architectures, check out Harrison's conceptual video. Specifically, in our case, it's a custom multi-agent workflow where the order in which the agents are called is defined ahead of time.
Speaker A
generate queries and retrieve documents and now i' like to talk about the code organization and some key Concepts when working with multi-agents and subgraphs in L graph so for the template we're going to have separate modules for each graph in the source
Speaker A
The agents in our system are the parent agent that is doing query analysis and routing, creating the research plan, and then responding to the user, as well as the researcher agent that is actually conducting research or retrieving the documents based on the research plan. There are two agents, and what enables adding the child researcher agent in this case is Lang Graph's ability to add subgraphs.
Speaker A
and graph Pi file with the definition of graph nodes and edges as well as state.
Speaker A
Subgraphs are simply graphs that are added to another graph as nodes. So, in our case, Conduct Research is a node that calls a subgraph, and that subgraph contains two additional nodes: Generate Queries and Retrieve Documents.
Speaker A
each other let's take a closer look at the state for each of the graphs the parent graph is going to have the messages fied in the state that is the field that we use to invoke the graph for example we pass the human message
Speaker A
Now, I'd like to talk about the code organization and some key concepts when working with multi-agents and subgraphs in Lang Graph. For the template, we're going to have separate modules for each graph in the source code. So, in this case, we're going to have the Retrieval Graph directory here, as well as the Researcher Graph subdirectory here for the subgraph.
Speaker A
state are going to be the router that's going to contain information about the type of the query after we analyze it for example General query more information or L chain and we're going to have additional logic there for why
Speaker A
They're both going to have a similar structure in that they're going to have a graph.py file with the definition of graph nodes and edges, as well as state.py, which is going to contain the state schema definition for each graph.
Speaker A
also has documents fied that's what we're going to populate when retrieving the documents and we're going to pass this to the parent graph we're also going to receive the question which is effectively just one of the steps from
Speaker A
The state schema for working with parent and subgraphs is one of the most important concepts because it defines how the parent and child graph communicate with each other. Let's take a closer look at the state for each of the graphs.
Speaker A
inside the parent graph if we look at the conduct research node you'll see that we're directly invoking the researcher graph or subgraph inside that node function and when we're invoking it we're using question key which is only available in the state of the subgraph
Speaker A
The parent graph is going to have the messages field in the state. That is the field that we use to invoke the graph. For example, we pass the human message with the user query to start executing the graph. Then, at the end, once we get the response back from the graph, it's going to be a message or AI message with the final response.
Speaker A
only needs to know current step it needs to retrieve the documents for and so that's what we're doing here we pass a single step from the research plan as question and we get the list of retriev documents back from the researcher graph
Speaker A
The other keys in the parent state are going to be the router, which is going to contain information about the type of the query after we analyze it. For example, general query, more information, or L Chain. We're going to have additional logic there for why we analyze this.
Speaker A
conceptual videos and guides on multi-agent architectures and subgraphs we're excited to see what you do with this template and the applications you build on top of that catch you next time
Topics:LangGraphLangChainMulti-Agent ArchitectureRAGResearch AgentSubgraphsDocument RetrievalVector StoreQuery AnalysisCode Organization



![[ОБНОВЛЕНО]Разгон и Андервольт Nintendo Switch при помо… — Transcript](https://i.ytimg.com/vi/m3i355dC3Xs/maxresdefault.jpg)







