|
@@ -0,0 +1,51 @@
|
|
|
+# LangChain <> Llama3 Cookbooks
|
|
|
+
|
|
|
+LLM agents use [planning, memory, and tools](https://lilianweng.github.io/posts/2023-06-23-agent/) to accomplish tasks.
|
|
|
+
|
|
|
+LangChain offers several different ways to implement agents.
|
|
|
+
|
|
|
+(1) Use [agent executor](https://python.langchain.com/docs/modules/agents/quick_start/) with [tool-calling](https://python.langchain.com/docs/integrations/chat/) versions of llama3.
|
|
|
+
|
|
|
+(2) Use [LangGraph](https://python.langchain.com/docs/langgraph), a library from LangChain that can be used to build reliable agents.
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### Agent Executor
|
|
|
+
|
|
|
+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 agent executor.
|
|
|
+
|
|
|
+This show how to build an agent that uses web search and retrieval tools.
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### LangGraph
|
|
|
+
|
|
|
+[LangGraph](https://python.langchain.com/docs/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:** Tools can be used at any step to modify state
|
|
|
+
|
|
|
+Our second notebook, `langgraph-agent`, shows how to build an agent that uses web search and retrieval tool in LangGraph.
|
|
|
+
|
|
|
+It discusses some of the trade-offs between agent executor and LangGraph.
|
|
|
+
|
|
|
+Our third notebook, `langgraph-rag-agent`, shows how to apply LangGraph to build advanced RAG agents that use 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.
|
|
|
+* Adaptive RAG [paper](https://arxiv.org/abs/2403.14403) 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, 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):
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+Our fouth notebook, `langgraph-rag-agent-local`, shows how to apply LangGraph to build advanced RAG agents that run locally and reliable.
|
|
|
+
|
|
|
+See this [video overview](https://www.youtube.com/watch?v=sgnrL7yo1TE) for more detail.
|