Jeff Tang 6d7f6ff91e langgraph-agent summary update 11 月之前
..
README.md ea5d4d60fe tool-calling-agent update; README 11 月之前
langgraph-agent.ipynb 6d7f6ff91e langgraph-agent summary update 11 月之前
langgraph-rag-agent-local.ipynb c6769a0870 folder structure change 11 月之前
langgraph-rag-agent.ipynb c6769a0870 folder structure change 11 月之前
tool-calling-agent.ipynb ea5d4d60fe tool-calling-agent update; README 11 月之前

README.md

LangChain <> Llama3 Cookbooks

LLM agents use planning, memory, and tools to accomplish tasks.

LangChain offers several different ways to implement agents.

(1) Use AgentExecutor with tool-calling versions of Llama 3.

(2) Use LangGraph, a library from LangChain that can be used to build reliable agents with Llama 3.


AgentExecutor Agent

AgentExecutor is the runtime for an agent. AgentExecutor calls the agent, executes the actions it chooses, passes the action outputs back to the agent, and repeats.

Our first notebook, tool-calling-agent, shows how to build a tool calling agent with AgentExecutor and Llama 3.

This shows how to build an agent that uses web search, text2image, image2text, and text2speech tools.


LangGraph Agent

LangGraph is a library from LangChain that can be used to build reliable agents.

LangGraph can be used to build agents with a few pieces:

  • Planning: Define a control flow of steps that you want the agent to take (a graph)
  • Memory: Persist information (graph state) across these steps
  • Tool use: Modify state at any step

Our second notebook, langgraph-agent, shows an alternative way to AgentExecutor to build a Llama 3 powered agent in LangGraph.

It discusses some of the trade-offs between AgentExecutor and LangGraph.


LangGraph RAG Agent

Our third notebook, langgraph-rag-agent, shows how to apply LangGraph to build advanced Llama 3 powered RAG agents that use ideas from 3 papers:

  • Corrective-RAG (CRAG) paper uses self-grading on retrieved documents and web-search fallback if documents are not relevant.
  • Self-RAG paper adds self-grading on generations for hallucinations and for ability to answer the question.
  • Adaptive RAG paper routes queries between different RAG approaches based on their complexity.

We implement each approach as a control flow in LangGraph:

  • Planning: The sequence of RAG steps (e.g., retrieval, grading, and generation) that we want the agent to take
  • Memory: All the RAG-related information (input question, retrieved documents, etc) that we want to pass between steps
  • Tool use: All the tools needed for RAG (e.g., decide web search or vectorstore retrieval based on the question)

We will build from CRAG (blue, below) to Self-RAG (green) and finally to Adaptive RAG (red):

Screenshot 2024-05-03 at 10 50 02 AM


Local LangGraph RAG Agent

Our fourth notebook, langgraph-rag-agent-local, shows how to apply LangGraph to build advanced RAG agents using Llama 3 that run locally and reliably.

See this video overview for more detail.