From 3d38e5667e8e0635bfe4b8cda87901c30e0f44f4 Mon Sep 17 00:00:00 2001 From: davidmyriel Date: Thu, 9 Jan 2025 17:28:38 -0500 Subject: [PATCH] fix content --- .../documentation/agentic-rag-crewai-zoom.md | 4 +- .../documentation/agentic-rag-langgraph.md | 112 ++++++------------ 2 files changed, 36 insertions(+), 80 deletions(-) diff --git a/qdrant-landing/content/documentation/agentic-rag-crewai-zoom.md b/qdrant-landing/content/documentation/agentic-rag-crewai-zoom.md index 59fc4bd63..0ee6ed2ff 100644 --- a/qdrant-landing/content/documentation/agentic-rag-crewai-zoom.md +++ b/qdrant-landing/content/documentation/agentic-rag-crewai-zoom.md @@ -13,7 +13,7 @@ social_preview_image: /documentation/examples/agentic-rag-crewai-zoom/social_pre By combining the power of Qdrant for vector search and CrewAI for orchestrating modular agents, you can build systems that don't just answer questions but analyze, interpret, and act. -Traditional RAG systems focus on fetching data and generating responses, but they lack the ability to reason deeply or handle multi-step processes. Agentic RAG solves this by combining: +Traditional RAG systems focus on fetching data and generating responses, but they lack the ability to reason deeply or handle multi-step processes. In this tutorial, we'll walk you through building an Agentic RAG system step by step. By the end, you'll have a working framework for storing data in a Qdrant Vector Database and extracting insights using CrewAI agents in conjunction with Vector Search over your data. @@ -34,7 +34,7 @@ The application first converts the meeting transcript into vector embeddings and When you interact with the system, here's what happens behind the scenes: -First the user submits a query to the system. In this example, we want to find out the avergae length of Marketing meetings. Since one of the data points from the meetings is the duration of the meeting, the agent can calculate the average duration of the meetings by averaging the duration of all meetings with the keyword "Marketing" in the topic or content. +First the user submits a query to the system. In this example, we want to find out the average length of Marketing meetings. Since one of the data points from the meetings is the duration of the meeting, the agent can calculate the average duration of the meetings by averaging the duration of all meetings with the keyword "Marketing" in the topic or content. ![User Query Interface](/articles_data/agentic-rag-crewai-zoom/query1.png) diff --git a/qdrant-landing/content/documentation/agentic-rag-langgraph.md b/qdrant-landing/content/documentation/agentic-rag-langgraph.md index 50e421be5..51d589f0b 100644 --- a/qdrant-landing/content/documentation/agentic-rag-langgraph.md +++ b/qdrant-landing/content/documentation/agentic-rag-langgraph.md @@ -8,68 +8,33 @@ social_preview_image: /documentation/examples/agentic-rag-langgraph/social_previ Traditional Retrieval-Augmented Generation (RAG) systems follow a straightforward path: query → retrieve → generate. Sure, this works well for many scenarios. But let’s face it—this linear approach often struggles when you're dealing with complex queries that demand multiple steps or pulling together diverse types of information. -Enter [Agentic RAG](https://qdrant.tech/articles/agentic-rag/), the next step in the RAG evolution. It takes things up a notch by introducing AI agents that can orchestrate multiple retrieval steps and smartly decide how to gather and use the information you need. Think of it this way: in an Agentic RAG workflow, RAG becomes just one powerful tool in a much bigger and more versatile toolkit. +[Agentic RAG](https://qdrant.tech/articles/agentic-rag/) takes things up a notch by introducing AI agents that can orchestrate multiple retrieval steps and smartly decide how to gather and use the information you need. Think of it this way: in an Agentic RAG workflow, RAG becomes just one powerful tool in a much bigger and more versatile toolkit. By combining LangGraph’s robust state management with Qdrant’s cutting-edge vector search, we’ll build a system that doesn’t just answer questions—it tackles complex, multi-step information retrieval tasks with finesse. ## What We’ll Build -Before diving into Agentic RAG, let’s clear something up: not every RAG implementation needs to be agentic. Traditional RAG systems are often simpler, less resource-intensive, and get the job done for many use cases. Agentic RAG, while powerful, introduces extra complexity, potential failure points, and higher computational costs. So, if a traditional RAG setup can meet your needs, stick with it—it’s the practical choice. +We’re building an AI agent to answer questions about Hugging Face and Transformers documentation using LangGraph. At the heart of our AI agent lies LangGraph, which acts like a conductor in an orchestra. It directs the flow between various components—deciding when to retrieve information, when to perform a web search, and when to generate responses. -That said, you might want to consider leveling up to Agentic RAG if you’re running into these roadblocks with your traditional setup: - -- **Query Refinement Challenges:** Does your system struggle with complex user queries? If breaking questions into sub-queries or rephrasing them is necessary to get meaningful results, it’s a sign traditional RAG might not be cutting it. -- **Multi-Step Information Gathering:** Are single retrievals falling short? If answers require stitching together data from multiple sources or making several retrieval passes, you’ll benefit from the orchestration power of Agentic RAG. -- **Context Quality Issues:** Does your system generate responses without ensuring the retrieved information is relevant or complete? Agentic RAG can step in to evaluate the quality of information before generating answers. -- **Tool Integration Needs:** Do you need to go beyond vector search? Whether it’s combining web search, APIs, or performing calculations, Agentic RAG shines when multiple tools need to work together seamlessly. - -We’re building an Agentic RAG system that takes smart decision-making to the next level. Unlike standard RAG, which sticks to searching a single vector database, our system juggles three powerful tools: two Qdrant vector stores and a web search engine. Here’s the magic—it doesn’t just blindly follow one path. Instead, it evaluates each query and decides whether to tap into the first vector store, the second one, or search the web. +The components are: two Qdrant vector stores and the Brave web search engine. However, our agent doesn’t just blindly follow one path. Instead, it evaluates each query and decides whether to tap into the first vector store, the second one, or search the web. This selective approach gives your system the flexibility to choose the best data source for the job, rather than being locked into the same retrieval process every time, like traditional RAG. While we won’t dive into query refinement in this tutorial, the concepts you’ll learn here are a solid foundation for adding that functionality down the line. -## How It Works - -The Agentic RAG (Retrieval-Augmented Generation) system is powered by an AI agent that smartly coordinates multiple tools and databases to deliver precise answers to your queries. Here’s how the architecture of Agentic RAG shapes up: +## Workflow ![image1](/documentation/examples/agentic-rag-langgraph/image1.png) -Fig. 1: Agentic RAG Workflow - -### Agentic RAG Workflow - -Here’s a step-by-step breakdown of how the Agentic RAG system works: - -- **User Input:** You start by entering a query or request through an interface, like a chatbot or a web form. This query is sent straight to the AI Agent, the brain of the operation. -- **AI Agent Processes the Query:** The AI Agent analyzes your query, figuring out what you’re asking and which tools or data sources will best answer your question. -- **Tool Selection:** Based on its analysis, the AI Agent picks the right tool for the job. Your data is spread across two vector databases, and depending on the query, it chooses the appropriate one. For queries needing real-time or external web data, the agent taps into a web search tool powered by BraveSearchAPI. -- **Query Execution:** The AI Agent then puts its chosen tool to work: - - **RAG Tool 1** queries Vector Database 1. - - **RAG Tool 2** queries Vector Database 2. - - **Web Search Tool** dives into the internet using the search API. -- **Data Retrieval:** The results roll in: - - Vector Database 1 and 2 return the most relevant documents for your query. - - The Web Search Tool provides up-to-date or external information. -- **Response Generation:** Using a text generation model (like GPT), the AI Agent crafts a detailed and accurate response tailored to your query. -- **User Response:** The polished response is sent back to you through the interface, ready to use. - -Let’s dive into the workings of the RAG Tool: +| **Step** | **Description** | +|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **1. User Input** | You start by entering a query or request through an interface, like a chatbot or a web form. This query is sent straight to the AI Agent, the brain of the operation.| +| **2. AI Agent Processes the Query** | The AI Agent analyzes your query, figuring out what you’re asking and which tools or data sources will best answer your question. | +| **3. Tool Selection** | Based on its analysis, the AI Agent picks the right tool for the job. Your data is spread across two vector databases, and depending on the query, it chooses the appropriate one. For queries needing real-time or external web data, the agent taps into a web search tool powered by BraveSearchAPI. | +| **4. Query Execution** | The AI Agent then puts its chosen tool to work:
- **RAG Tool 1** queries Vector Database 1.
- **RAG Tool 2** queries Vector Database 2.
- **Web Search Tool** dives into the internet using the search API. | +| **5. Data Retrieval** | The results roll in:
- Vector Database 1 and 2 return the most relevant documents for your query.
- The Web Search Tool provides up-to-date or external information.| +| **6. Response Generation** | Using a text generation model (like GPT), the AI Agent crafts a detailed and accurate response tailored to your query. | +| **7. User Response** | The polished response is sent back to you through the interface, ready to use. | -![image3](/documentation/examples/agentic-rag-langgraph/image3.png) - -Fig. 2: Architecture of the RAG Tool - -- **AI Agent Receives Input:** The AI agent, powered by OpenAI, takes your query as the starting point. -- **Query Extraction:** The agent breaks down your query into key components, preparing it for further processing. -- **Embedding Generation:** OpenAI transforms the query into vector embeddings using a specialized embedding model. -- **Vector Database Querying:** These embeddings are sent to a vector database, such as Qdrant, to fetch relevant documents. -- **Document Retrieval:** The vector database compares the query embeddings against its stored vectors and pulls the most relevant documents. -- **Context Preparation:** The retrieved documents are processed and structured to create a rich context for the large language model (LLM). -- **LLM Response Generation:** OpenAI’s LLM takes this context and crafts a response perfectly tailored to your query. -- **Response Delivery:** Finally, the AI agent pulls it all together and delivers a polished response straight to you. - -In the next section, we’ll explore the technology stack required to bring these components to life. - -## The Architecture +## The Stack The architecture taps into cutting-edge tools to power efficient Agentic RAG workflows. Here’s a quick overview of its components and the technologies you’ll need: @@ -82,17 +47,9 @@ The architecture taps into cutting-edge tools to power efficient Agentic RAG wor Ready to start building this system from the ground up? Let’s get to it! -## The Implementation - -We’re building an AI agent to answer questions about Hugging Face and Transformers documentation using LangGraph. Let’s break it down into the basics, working on the problem step by step. - -### Understanding the Foundation +## Implementation -At the heart of our AI agent lies LangGraph, which acts like a conductor in an orchestra. It directs the flow between various components—deciding when to retrieve information, when to perform a web search, and when to generate responses. - -### Prerequisites - -Before we dive into building our agent, let’s get everything set up. Don’t worry, we’ve got you covered! +Before we dive into building our agent, let’s get everything set up. ### Qdrant Vector Database Setup @@ -344,7 +301,7 @@ graph_builder.add_edge(START, "agent") This is what the graph looks like: -![image2](/documentation/examples/agentic-rag-langgraph/image2.png) +![image2](/documentation/examples/agentic-rag-langgraph/image2.jpg) Fig. 3: Agentic RAG with LangGraph @@ -363,41 +320,40 @@ def run_agent(user_input: str): Now, you’re ready to ask questions about Hugging Face and Transformers! Our agent will intelligently combine information from the documentation with web search results when needed. -For example, you can ask: *"In the Transformers library, are there any multilingual models?"* +For example, you can ask: + +```txt +In the Transformers library, are there any multilingual models? +``` The agent will dive into the Transformers documentation, extract relevant details about multilingual models, and deliver a clear, comprehensive answer. Here’s what the response might look like: +```txt Yes, the Transformers library includes several multilingual models. Here are some examples: -*BERT Multilingual**: Models like `bert-base-multilingual-uncased` can be used just like monolingual models. +BERT Multilingual: +Models like `bert-base-multilingual-uncased` can be used just like monolingual models. -*XLM (Cross-lingual Language Model)**: Models like `xlm-mlm-ende-1024` (English-German), `xlm-mlm-enfr-1024` (English-French), and others use language embeddings to specify the language used at inference. +XLM (Cross-lingual Language Model): +Models like `xlm-mlm-ende-1024` (English-German), `xlm-mlm-enfr-1024` (English-French), and others use language embeddings to specify the language used at inference. -*M2M100*: Models like `facebook/m2m100_418M` and `facebook/m2m100_1.2B` are used for multilingual translation. +M2M100: +Models like `facebook/m2m100_418M` and `facebook/m2m100_1.2B` are used for multilingual translation. -*MBart*: Models like `facebook/mbart-large-50-one-to-many-mmt` and `facebook/mbart-large-50-many-to-many-mmt` are used for multilingual machine translation across 50 languages. +MBart: +Models like `facebook/mbart-large-50-one-to-many-mmt` and `facebook/mbart-large-50-many-to-many-mmt` are used for multilingual machine translation across 50 languages. These models are designed to handle multiple languages and can be used for tasks like translation, classification, and more. +``` --- -We’ve successfully implemented Agentic RAG. But this is just the beginning—there’s plenty more you can explore to take your system to the next level. - -### What's Next? - -Here are some exciting ways to extend and enhance your implementation: - -- **Incorporate Additional Documentation Sources**Expand your agent’s knowledge base by integrating more documentation repositories. -- **Explore Different Search Strategies**Experiment with advanced search methods to improve retrieval accuracy and relevance. -- **Add Memory for Context**Equip your agent with memory capabilities to maintain context across multiple queries for a more conversational experience. -- **Implement Error Handling and Retry Mechanisms**Make your system more robust by adding mechanisms to gracefully handle errors and retry failed operations. - -The beauty of LangGraph is that you can effortlessly modify your graph structure to introduce new features while keeping your codebase clean, organized, and easy to maintain. - ## Conclusion +We’ve successfully implemented Agentic RAG. But this is just the beginning—there’s plenty more you can explore to take your system to the next level. + Agentic RAG is transforming how businesses connect data sources with AI, enabling smarter and more dynamic interactions. In this tutorial, you’ve learned how to build an Agentic RAG system that combines the power of LangGraph, Qdrant, and web search into one seamless workflow. This system doesn’t just stop at retrieving relevant information from Hugging Face and Transformers documentation. It also smartly falls back to web search when needed, ensuring no query goes unanswered. With Qdrant as the vector database backbone, you get fast, scalable semantic search that excels at retrieving precise information—even from massive datasets.