Lance Martin 06aa1eac19 Update README.md 1 年間 前
..
README.md 06aa1eac19 Update README.md 1 年間 前
langgraph-custom-agent.ipynb b9074e1d09 Add langgraph tool calling agent 1 年間 前
langgraph-rag-agent-local.ipynb c6769a0870 folder structure change 1 年間 前
langgraph-rag-agent.ipynb c6769a0870 folder structure change 1 年間 前
langgraph-tool-calling-agent.ipynb b9074e1d09 Add langgraph tool calling agent 1 年間 前
tool-calling-agent.ipynb b9074e1d09 Add langgraph tool calling agent 1 年間 前

README.md

LangChain <> Llama3 Cookbooks

LLM agents use planning, memory, and tools to accomplish tasks. Agents can empower llama3 with important new capabilities. Here, we will show how to give llama3 the ability to perform web search, as well as multi-modality: image generation (text-to-image), image analysis (image-to-text), and voice (text-to-speech) tools!

LangChain offers several different ways to implement agents with Llama 3:

(1) Tool calling agent - Uses AgentExecutor with tool-calling versions of Llama 3.

(2) LangGraph tool calling agent - Uses LangGraph with tool-calling versions of Llama 3.

(3) LangGraph custom agent - Uses LangGraph with any version of Llama 3 (so long as it supports supports structured output).

As we move from option (1) to (3) the degree of customization and flexibility increaces:

(1) Tool calling agent is great for getting started quickly with minimal code, but requires a version of Llama 3 with reliable tool-calling, is the least customiable, and uses high-level agent executor abstraction.

(2) LangGraph tool calling agent is more customizable than (1), but still requires a version of Llama 3 with reliable tool-calling.

(3) LangGraph custom agent does not a version of Llama 3 with reliable tool-calling and is the most customizable, but requires the most work to implement.

langgraph_agent_architectures


Tool calling agent with AgentExecutor

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.


LangGraph tool calling agent

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

Our second notebook, langgraph-tool-calling-agent, shows an alternative to AgentExecutor for building a Llama 3 powered agent.


LangGraph custom agent

Our third notebook, langgraph-custom-agent, shows how to build a Llama 3 powered agent without reliance on tool-calling.


LangGraph RAG Agent

Our fourth notebook, langgraph-rag-agent, shows how to apply LangGraph to build a custom Llama 3 powered RAG agent 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):


Local LangGraph RAG Agent

Our fifth 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 on the design of this agent.