Retrieval-Augmented Generation (RAG) is an advanced approach that combines the capabilities of information retrieval systems with generative AI models. By leveraging external knowledge sources during the generation process, RAG ensures the creation of accurate, contextually relevant, and up-to-date content. This hybrid methodology bridges the gap between static generative models and dynamic, information-rich environments, making it a powerful tool for applications requiring precise and reliable outputs.
flowchart LR
subgraph "RAG System"
A[User Query] --> B[Query Processing]
B --> C[Knowledge Retrieval]
C --> D[Context Selection]
D --> E[Response Generation]
E --> F[Final Response]
end
G[(External Knowledge Sources)] --> C
style G fill:#f9f9f9,stroke:#999,stroke-width:1px
style A fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style F fill:#e8f5e9,stroke:#43a047,stroke-width:2px
A basic Retrieval-Augmented Generation (RAG) system processes and queries PDF/CSV documents by encoding their content into a vector store, which can then be queried to retrieve relevant information.
flowchart TD
A[Document Collection] --> B[Text Extraction]
B --> C[Text Chunking]
C --> D[Embedding Generation]
D --> E[Vector Store]
F[User Query] --> G[Query Embedding]
G --> H[Similarity Search]
E --> H
H --> I[Retrieve Relevant Chunks]
I --> J[Generate Response]
style A fill:#f0f8ff,stroke:#4682b4
style E fill:#f0fff0,stroke:#2e8b57
style F fill:#fff0f5,stroke:#ff69b4
style J fill:#f5f5dc,stroke:#bdb76b
The “Reliable-RAG” method enhances the traditional Retrieval-Augmented Generation (RAG) approach by incorporating additional layers of validation and refinement to ensure the accuracy and reliability of retrieved information.
flowchart TD
A[Document Collection] --> B[Text Chunking]
B --> C[Vector Embedding]
C --> D[Vector Store]
E[User Query] --> F[Query Embedding]
F --> G[Initial Retrieval]
D --> G
G --> H[Relevance Checking]
H --> I{Relevant?}
I -- Yes --> J[Answer Generation]
I -- No --> K[Requery or Expand Search]
J --> L[Hallucination Detection]
L --> M{Contains Hallucinations?}
M -- Yes --> N[Refine Answer]
M -- No --> O[Return Answer with Sources]
style E fill:#ffe6cc,stroke:#d79b00
style H fill:#d5e8d4,stroke:#82b366
style L fill:#d5e8d4,stroke:#82b366
style O fill:#dae8fc,stroke:#6c8ebf
The Propositions Chunking method enhances document processing by breaking input text into smaller, atomic units called propositions. These propositions are designed to be factual, self-contained, and concise, enabling efficient encoding into a vector store for future retrieval.
flowchart TD
A[Original Document] --> B[Initial Chunking]
B --> C[LLM Proposition Extraction]
C --> D[Proposition Validation]
D --> E{Quality Check}
E -- Pass --> F[Proposition Embedding]
E -- Fail --> G[Refine Proposition]
G --> D
F --> H[Vector Store]
I[User Query] --> J[Query Processing]
J --> K[Retrieval from Vector Store]
H --> K
K --> L[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style C fill:#e1f5fe,stroke:#0288d1
style E fill:#fff9c4,stroke:#fbc02d
style H fill:#e8f5e9,stroke:#43a047
style L fill:#fce4ec,stroke:#e91e63
Retrieval-Augmented Generation (RAG) systems often encounter challenges when handling complex or ambiguous queries. Query transformation techniques address these challenges by reformulating or expanding queries to improve the match with relevant documents.
flowchart TD
A[Original Query] --> B{Query Analysis}
B --> C[Query Rewriting]
B --> D[Step-back Prompting]
B --> E[Sub-query Decomposition]
C --> F[Specific Query]
D --> G[Generalized Query]
E --> H[Sub-query 1]
E --> I[Sub-query 2]
E --> J[Sub-query 3]
F --> K[Document Retrieval]
G --> K
H --> K
I --> K
J --> K
K --> L[Response Generation]
style A fill:#f9f9f9,stroke:#999
style B fill:#dae8fc,stroke:#6c8ebf
style C fill:#d5e8d4,stroke:#82b366
style D fill:#d5e8d4,stroke:#82b366
style E fill:#d5e8d4,stroke:#82b366
style L fill:#ffe6cc,stroke:#d79b00
Hypothetical Document Embedding (HyDE) tackles the challenge of bridging the semantic gap between brief queries and longer, more detailed documents by transforming the query into a full hypothetical document.
flowchart LR
A[User Query] --> B[LLM]
B --> C[Hypothetical Document]
C --> D[Document Embedding]
E[Document Collection] --> F[Document Processing]
F --> G[Document Chunks]
G --> H[Document Embeddings]
D --> I[Similarity Search]
H --> I
I --> J[Retrieved Documents]
J --> K[Response Generation]
style A fill:#ffcccc,stroke:#ff6666
style C fill:#ccffcc,stroke:#66ff66
style E fill:#ccccff,stroke:#6666ff
style K fill:#ffffcc,stroke:#ffff66
Contextual Chunk Headers (CCH) address the challenge of insufficient context within individual chunks by augmenting them with higher-level context, ensuring better retrieval accuracy and comprehension by the language model.
flowchart TD
A[Original Document] --> B[Extract Hierarchical Structure]
A --> C[Create Text Chunks]
B --> D[Generate Contextual Headers]
D --> E[Combine Headers with Chunks]
C --> E
E --> F[Enhanced Chunks]
F --> G[Vector Embedding]
G --> H[Vector Store]
I[User Query] --> J[Query Processing]
J --> K[Retrieval]
H --> K
K --> L[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style D fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style F fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style L fill:#fce4ec,stroke:#e91e63
Relevant Segment Extraction (RSE) provides a dynamic approach to address the challenges of chunk size optimization by reconstructing multi-chunk segments of contiguous text from retrieved chunks.
flowchart TD
A[Document] --> B[Small Chunk Division]
B --> C[Vector Embedding]
C --> D[Vector Store]
E[User Query] --> F[Query Embedding]
F --> G[Initial Retrieval]
D --> G
G --> H[Identify Key Chunks]
H --> I[Find Adjacent Chunks]
I --> J[Reconstruct Contiguous Segment]
J --> K[Provide Context to LLM]
K --> L[Generate Response]
style A fill:#f5f5f5,stroke:#333333
style H fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style J fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style L fill:#fce4ec,stroke:#e91e63
The Context Enrichment Window enhances the standard retrieval process by including surrounding context for each retrieved chunk, resulting in more coherent and comprehensive information.
flowchart LR
A[Document] --> B[Standard Chunking]
B --> C[Vector Embedding]
C --> D[Vector Store]
E[User Query] --> F[Initial Retrieval]
D --> F
F --> G[Top K Chunks]
G --> H[Context Window Expansion]
H --> I[Surrounding Chunks]
I --> J[Context-Enriched Result]
J --> K[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style G fill:#e1f5fe,stroke:#0288d1
style H fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style J fill:#ffe0b2,stroke:#ff9800,stroke-width:2px
Semantic chunking addresses the limitations of traditional text splitting methods by dividing text at natural breakpoints, preserving semantic coherence within each chunk.
flowchart TD
A[Document] --> B[Text Extraction]
B --> C[Text Analysis]
C --> D[Identify Semantic Boundaries]
D --> E[Create Semantic Chunks]
E --> F[Vector Embedding]
F --> G[Vector Store]
H[User Query] --> I[Query Processing]
I --> J[Retrieval]
G --> J
J --> K[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style E fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style K fill:#fce4ec,stroke:#e91e63
Contextual compression tackles the inefficiency of traditional document retrieval by extracting and compressing only the most relevant portions of retrieved documents, resulting in a more focused and streamlined retrieval process.
flowchart TD
A[Document Collection] --> B[Vector Embedding]
B --> C[Vector Store]
D[User Query] --> E[Initial Retrieval]
C --> E
E --> F[Retrieved Chunks]
F --> G[LLM-based Compressor]
G --> H[Identify Query-Relevant Sections]
H --> I[Remove Irrelevant Content]
I --> J[Compressed Result]
J --> K[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style G fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style I fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style K fill:#fce4ec,stroke:#e91e63
This technique enhances document retrieval within a vector database by generating additional questions related to each text fragment, improving the standard retrieval process.
flowchart TD
A[Document] --> B[Text Chunking]
B --> C[For Each Chunk]
C --> D[LLM Question Generation]
D --> E[Generate Relevant Questions]
E --> F[Associate Questions with Chunks]
F --> G[Vector Embedding]
G --> H[Enhanced Vector Store]
I[User Query] --> J[Query Processing]
J --> K[Retrieval]
H --> K
K --> L[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style E fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style L fill:#fce4ec,stroke:#e91e63
Fusion retrieval combines vector-based (semantic) and keyword-based (BM25) retrieval methods to create a more robust and accurate retrieval system that can handle a wider range of queries effectively.
flowchart TD
A[Document Collection] --> B[Text Processing]
B --> C[Vector Embedding]
B --> D[BM25 Indexing]
C --> E[Vector Store]
D --> F[BM25 Index]
G[User Query] --> H[Query for Vector Search]
G --> I[Query for Keyword Search]
H --> J[Vector-based Retrieval]
I --> K[Keyword-based Retrieval]
E --> J
F --> K
J --> L[Vector Results]
K --> M[Keyword Results]
L --> N[Fusion Algorithm]
M --> N
N --> O[Reranked Results]
O --> P[Response Generation]
style E fill:#e1f5fe,stroke:#0288d1
style F fill:#e8f5e9,stroke:#43a047
style N fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style P fill:#fce4ec,stroke:#e91e63
Reranking allows for more sophisticated relevance assessment, taking into account nuanced relationships between queries and documents that might be missed by traditional retrieval techniques.
flowchart TD
A[User Query] --> B[Initial Retrieval]
C[Vector Store] --> B
B --> D[Initial Results]
D --> E[Reranking Process]
E --> F[For Each Document]
F --> G[Calculate Relevance Score]
G --> H[LLM/Cross-Encoder Scoring]
H --> I[Sort by Relevance Score]
I --> J[Reranked Results]
J --> K[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style E fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style H fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style K fill:#fce4ec,stroke:#e91e63
Hierarchical indexing provides a two-tier system for improved efficiency and context-aware retrieval, ensuring more relevant and precise results.
PDF Processing and Text Chunking
Extracts text from PDFs and divides it into manageable chunks for processing.
Asynchronous Document Summarization
Summarizes text chunks using language models like OpenAI’s GPT-4, providing high-level overviews of document sections.
Vector Store Creation
Builds separate vector stores for summaries and detailed chunks using technologies like FAISS and OpenAI embeddings, enabling efficient similarity search.
Custom Hierarchical Retrieval Function
Implements a retrieval process that searches summaries first and drills down into detailed chunks as needed for more granular results.
flowchart TD
A[Document Collection] --> B[Text Chunking]
B --> C[Document Chunks]
C --> D[Summary Generation]
C --> E[Detailed Chunks Vector Store]
D --> F[Summaries Vector Store]
G[User Query] --> H[Query Embedding]
H --> I[Search Summaries First]
F --> I
I --> J[Identify Relevant Sections]
J --> K[Drill Down to Detailed Chunks]
E --> K
K --> L[Retrieve Relevant Detail Chunks]
L --> M[Response Generation]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style I fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style K fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style M fill:#fce4ec,stroke:#e91e63
Improved Retrieval Efficiency
Searching summaries first helps quickly locate relevant sections without processing the entire dataset.
Better Context Preservation
Maintains a broader understanding of document structure, ensuring that retrieved information aligns with the overall context.
Scalability
Particularly effective for large documents or datasets, where flat indexing methods may struggle with performance or context.
Flexibility
Allows customization of the retrieval process, such as adjusting the number of summaries and detailed chunks retrieved, to suit different use cases or query types.
Multi-modal Retrieval-Augmented Generation (RAG) systems are designed to handle the complexity of documents containing both text and images, such as PDFs.
PDF Parsers
Extract text and images from PDFs, preparing the content for further processing.
Multi-Modal LLM
Summarizes and interprets images, tables, and textual content within the document.
Embeddings
Converts document fragments, including text and image descriptions, into embeddings for similarity-based retrieval.
Vectorstore
Stores embeddings for efficient search and retrieval of relevant document content.
Framework
Orchestrates the end-to-end pipeline, from retrieval to response generation, ensuring seamless integration of multi-modal data.
flowchart TD
A[Multi-modal Document] --> B[Content Extraction]
B --> C[Text Content]
B --> D[Visual Content]
C --> E[Text Processing]
D --> F[Vision Processing]
F --> G[Image Description/Analysis]
E --> H[Text Embedding]
G --> I[Visual Content Embedding]
H --> J[Unified Vector Store]
I --> J
K[User Query] --> L[Query Processing]
L --> M[Multi-modal Retrieval]
J --> M
M --> N[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style F fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style J fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style N fill:#fce4ec,stroke:#e91e63
Simplified Retrieval
Handles complex documents containing diverse data types, enabling straightforward access to relevant content.
Streamlined Question-Answering
Facilitates efficient Q&A processes by integrating both text and visual elements into the retrieval and response generation workflow.
Flexible Architecture
Supports scalability and adaptation to additional document types, expanding its applicability across various domains.
Incorporating feedback loops enables RAG systems to adapt and improve continually, ensuring higher relevance and accuracy over time.
PDF Content Extraction
Extracts textual content from PDF documents to make them searchable and indexable.
Vectorstore
Stores embeddings of document content for efficient similarity-based retrieval.
Retriever
Identifies and fetches documents most relevant to user queries based on embeddings.
Language Model
Generates responses using the context provided by retrieved documents.
Feedback Collection
Captures user feedback regarding the quality, relevance, and accuracy of the system’s responses.
Feedback Storage
Maintains collected feedback for long-term use and system training.
Relevance Score Adjustment
Dynamically updates the relevance scores of documents based on user feedback, improving future retrieval accuracy.
Index Fine-Tuning
Periodically refines the vectorstore using accumulated feedback to reflect evolving user needs and document content.
flowchart TD
A[User Query] --> B[Initial Retrieval]
C[Vector Store] --> B
B --> D[Generate Response]
D --> E[Provide Response to User]
E --> F[Collect User Feedback]
F --> G{Positive Feedback?}
G -- Yes --> H[Reinforce Document Relevance]
G -- No --> I[Reduce Document Relevance]
H --> J[Update Retrieval Model]
I --> J
J --> K[Improved Vector Store]
K --> C
style A fill:#f5f5f5,stroke:#333333
style F fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style J fill:#e8f5e9,stroke:#43a047,stroke-width:2px
Continuous Improvement
The system learns and evolves from user interactions, progressively enhancing response quality.
Personalization
Adapts retrieval and response strategies to align with individual or collective user preferences over time.
Increased Relevance
Feedback integration ensures that retrieved documents become more pertinent to user queries in future interactions.
Quality Control
Reduces the likelihood of repeating irrelevant or low-quality responses, maintaining a high standard of output.
Adaptability
Adjusts to changes in user needs or content within the knowledge base, ensuring long-term reliability and effectiveness.
Adaptive Retrieval addresses the limitation of uniform retrieval approaches by employing tailored strategies that align with the specific requirements of different queries.
Query Classifier
Categorizes queries into distinct types, such as Factual, Analytical, Opinion, or Contextual, to determine the most appropriate retrieval strategy.
LLM Integration
Utilizes Large Language Models (LLMs) to enhance the retrieval, ranking, and contextual understanding processes.
flowchart TD
A[User Query] --> B[Query Analysis]
B --> C[Query Classification]
C --> D{Query Type}
D -- Factual --> E[Precision-focused Strategy]
D -- Analytical --> F[Breadth-focused Strategy]
D -- Opinion --> G[Multiple Perspectives Strategy]
D -- Contextual --> H[User Context Strategy]
E --> I[Retrieve Specific Documents]
F --> J[Retrieve Diverse Documents]
G --> K[Retrieve Varied Viewpoints]
H --> L[Retrieve User-Relevant Documents]
I --> M[Final Response Generation]
J --> M
K --> M
L --> M
style C fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style D fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style M fill:#fce4ec,stroke:#e91e63
Improved Accuracy
Tailoring retrieval strategies to specific query types enhances the precision and relevance of responses.
Flexibility
Adapts dynamically to diverse query requirements, offering a versatile solution for various user needs.
Context-Awareness
For contextual queries, the system integrates user-specific information, ensuring personalized and meaningful responses.
Diverse Perspectives
Actively gathers and presents multiple viewpoints for opinion-based queries, fostering balanced and comprehensive insights.
Comprehensive Analysis
The analytical strategy provides in-depth exploration of complex topics, supporting thorough and well-rounded responses.
The DeepEval library provides a comprehensive framework for evaluating the performance of Retrieval-Augmented Generation (RAG) systems with a flexible and robust design that enables the assessment of various performance metrics.
flowchart TD
A[RAG System] --> B[Test Cases]
B --> C[Evaluation Process]
C --> D[Correctness Evaluation]
C --> E[Faithfulness Evaluation]
C --> F[Contextual Relevancy Evaluation]
C --> G[Other Custom Metrics]
D --> H[Aggregated Results]
E --> H
F --> H
G --> H
H --> I[Performance Analysis]
I --> J[System Improvement Recommendations]
style A fill:#f5f5f5,stroke:#333333
style C fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style H fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style J fill:#fce4ec,stroke:#e91e63
The GroUSE framework provides an automated evaluation solution by leveraging Large Language Models (LLMs) with finely tuned prompts to address potential failure modes in Grounded Question Answering.
flowchart TD
A[RAG System] --> B[Generated Responses]
C[Reference Contexts] --> D[GroUSE Evaluation]
B --> D
D --> E[Answer Relevancy Check]
D --> F[Completeness Check]
D --> G[Faithfulness Check]
D --> H[Usefulness Check]
E --> I[Judge LLM Assessment]
F --> I
G --> I
H --> I
I --> J[Failure Mode Identification]
J --> K[Performance Report]
K --> L[System Improvement Guidelines]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style I fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style L fill:#fce4ec,stroke:#e91e63
Explainable Retrieval addresses the lack of transparency in traditional document retrieval systems by combining effective retrieval with clear, comprehensible explanations.
flowchart TD
A[User Query] --> B[Document Retrieval]
C[Vector Store] --> B
B --> D[Retrieved Documents]
D --> E[LLM Explanation Process]
E --> F[For Each Document]
F --> G[Generate Relevance Explanation]
G --> H[Document + Explanation]
H --> I[Explainable Results]
I --> J[Response Generation]
style A fill:#f5f5f5,stroke:#333333
style E fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style G fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style J fill:#fce4ec,stroke:#e91e63
GraphRAG offers a novel approach to Retrieval-Augmented Generation (RAG) by addressing the challenges of maintaining context in long documents and drawing connections between related pieces of information using a graph-based knowledge structure.
flowchart TD
A[Document Collection] --> B[Text Chunking]
B --> C[Generate Embeddings]
C --> D[Build Knowledge Graph]
D --> E[Connect Related Chunks]
E --> F[Establish Relationships]
F --> G[Complete Knowledge Graph]
H[User Query] --> I[Query Analysis]
I --> J[Graph Traversal]
G --> J
J --> K[Identify Relevant Paths]
K --> L[Extract Context from Graph]
L --> M[Generate Response]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style E fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style J fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style M fill:#fce4ec,stroke:#e91e63
Microsoft’s graph-based approach to Retrieval-Augmented Generation (RAG) tackles the challenges of synthesizing information from diverse sources by connecting related data and enhancing semantic understanding.
flowchart TD
A[Document Corpus] --> B[Entity Extraction]
B --> C[Relationship Identification]
C --> D[Knowledge Graph Construction]
D --> E[Community Detection Algorithm]
E --> F[Identify Entity Clusters]
F --> G[Generate Cluster Summaries]
G --> H[Enhanced Knowledge Base]
I[User Query] --> J[Query Analysis]
J --> K[Retrieve Relevant Clusters]
H --> K
K --> L[Extract Combined Context]
L --> M[Generate Response]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style F fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style G fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style M fill:#fce4ec,stroke:#e91e63
RAPTOR redefines document retrieval by employing a hierarchical structure that enables seamless navigation between high-level overviews and specific details.
flowchart TD
A[Document Collection] --> B[Document Chunking]
B --> C[Create Level 0 Chunks]
C --> D[Recursive Summarization]
D --> E[Level 1 Summaries]
E --> F[Level 2 Summaries]
F --> G[Level N Summaries]
H[Complete Hierarchy] --> I[Vector Embedding]
I --> J[Multi-level Vector Store]
K[User Query] --> L[Query Analysis]
L --> M[Determine Appropriate Level]
M --> N[Level-specific Retrieval]
J --> N
N --> O[Navigate Hierarchy as Needed]
O --> P[Extract Relevant Context]
P --> Q[Generate Response]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style H fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style M fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style Q fill:#fce4ec,stroke:#e91e63
Self-RAG introduces a refined approach to question answering by dynamically balancing information retrieval and response generation, ensuring that responses are both factually grounded and flexible.
flowchart TD
A[User Query] --> B[Retrieval Decision Module]
B --> C{Retrieval Needed?}
C -- Yes --> D[Document Retrieval]
C -- No --> E[Generate Without Retrieval]
F[Vector Store] --> D
D --> G[Relevance Filtering]
G --> H[Extract Best Documents]
H --> I[Response Generation with Context]
E --> J[Direct Response Generation]
I --> K[Support Assessment]
J --> K
K --> L[Utility Evaluation]
L --> M[Final Response]
style B fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style G fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style K fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style M fill:#fce4ec,stroke:#e91e63
Corrective RAG is a methodology designed to address shortcomings in traditional Retrieval-Augmented Generation (RAG) systems, particularly when retrieved data is irrelevant, incomplete, or outdated.
flowchart TD
A[User Query] --> B[Initial Local Knowledge Retrieval]
C[Vector Store] --> B
B --> D[Relevance Evaluation]
D --> E{Sufficient Relevant Data?}
E -- Yes --> F[Knowledge Refinement]
E -- No --> G[Web Search Query Formulation]
G --> H[Execute Web Search]
H --> I[Process Web Results]
I --> J[Combine with Local Knowledge]
F --> J
J --> K[Response Generation]
K --> L[Final Response]
style D fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
style E fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style J fill:#e8f5e9,stroke:#43a047,stroke-width:2px
style L fill:#fce4ec,stroke:#e91e63