|
@@ -1,52 +1,24 @@
|
|
|
# LangChain <> Llama3 Cookbooks
|
|
|
|
|
|
-LLM agents use [planning, memory, and tools](https://lilianweng.github.io/posts/2023-06-23-agent/) to accomplish tasks. Agents can empower Llama 3 with important new capabilities. Here, we will show how to give Llama 3 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!
|
|
|
+### `Agents`
|
|
|
|
|
|
-LangChain offers several different ways to implement agents with Llama 3:
|
|
|
+LLM agents use [planning, memory, and tools](https://lilianweng.github.io/posts/2023-06-23-agent/) to accomplish tasks. Here, we show how to build agents capable of [tool-calling](https://python.langchain.com/docs/integrations/chat/) using [LangGraph](https://python.langchain.com/docs/langgraph) with Llama 3.
|
|
|
|
|
|
-(1) `ReAct agent` - Uses [AgentExecutor](https://python.langchain.com/docs/modules/agents/quick_start/) with [tool-calling](https://python.langchain.com/docs/integrations/chat/) versions of Llama 3.
|
|
|
+Agents can empower Llama 3 with important new capabilities. In particular, we will show how to give Llama 3 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!
|
|
|
|
|
|
-(2) `LangGraph tool calling agent` - Uses [LangGraph](https://python.langchain.com/docs/langgraph) with [tool-calling](https://python.langchain.com/docs/integrations/chat/) versions of Llama 3.
|
|
|
+Tool-calling agents with LangGraph use two nodes: (1) a node with an LLM decides which tool to invoke based upon the user question. It outputs the tool name and arguments to use. (2) the tool name and arguments are passed to a tool node, which calls the tool itself with the specified arguments and returns the result back to the LLM.
|
|
|
|
|
|
-(3) `LangGraph custom agent` - Uses [LangGraph](https://python.langchain.com/docs/langgraph) with **any** version of Llama 3 (so long as it supports structured output).
|
|
|
+
|
|
|
|
|
|
-As we move from option (1) to (3) the degree of customization and flexibility increases:
|
|
|
+Our first notebook, `langgraph-tool-calling-agent`, shows how to build our agent mentioned above using LangGraph.
|
|
|
|
|
|
-(1) `ReAct agent` using AgentExecutor is a great for getting started quickly with minimal code, but requires a version of Llama 3 with reliable tool-calling, is the least customizable, and uses higher-level AgentExecutor abstraction.
|
|
|
-
|
|
|
-(2) `LangGraph tool calling agent` is more customizable than (1) because the LLM assistant (planning) and tool call (action) nodes are defined by the user, but it still requires a version of Llama 3 with reliable tool-calling.
|
|
|
-
|
|
|
-(3) `LangGraph custom agent` does not require a version of Llama 3 with reliable tool-calling and is the most customizable, but requires the most work to implement.
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-### `ReAct agent`
|
|
|
-
|
|
|
-The AgentExecutor manages the loop of planning, executing tool calls, and processing outputs until an AgentFinish signal is generated, indicating task completion.
|
|
|
-
|
|
|
-Our first notebook, `tool-calling-agent`, shows how to build a [tool calling agent](https://python.langchain.com/docs/modules/agents/agent_types/tool_calling/) with AgentExecutor and Llama 3.
|
|
|
-
|
|
|
----
|
|
|
-
|
|
|
-### `LangGraph tool calling agent`
|
|
|
-
|
|
|
-[LangGraph](https://python.langchain.com/docs/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.
|
|
|
+See this [video overview](https://www.youtube.com/watch?v=j2OAeeujQ9M) for more detail on the design of this agent.
|
|
|
|
|
|
---
|
|
|
|
|
|
-### `LangGraph RAG Agent`
|
|
|
+### `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:
|
|
|
+Our second notebook, `langgraph-rag-agent`, shows how to apply LangGraph to build a custom Llama 3 powered RAG agent that uses ideas from 3 papers:
|
|
|
|
|
|
* Corrective-RAG (CRAG) [paper](https://arxiv.org/pdf/2401.15884.pdf) uses self-grading on retrieved documents and web-search fallback if documents are not relevant.
|
|
|
* Self-RAG [paper](https://arxiv.org/abs/2310.11511) adds self-grading on generations for hallucinations and for ability to answer the question.
|
|
@@ -65,6 +37,6 @@ We will build from CRAG (blue, below) to Self-RAG (green) and finally to Adaptiv
|
|
|
|
|
|
### `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.
|
|
|
+Our third 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](https://www.youtube.com/watch?v=sgnrL7yo1TE) for more detail on the design of this agent.
|