﻿{"id":3662,"date":"2025-09-02T10:50:51","date_gmt":"2025-09-02T05:20:51","guid":{"rendered":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/?p=3662"},"modified":"2025-09-02T10:50:51","modified_gmt":"2025-09-02T05:20:51","slug":"rag-demystified-part-3","status":"publish","type":"post","link":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/artificial-intelligence\/rag-demystified-part-3.html","title":{"rendered":"RAG Demystified: Part 3"},"content":{"rendered":"<p>We have discussed the core components of RAG in <a href=\"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/artificial-intelligence\/rag-series-1.html\">Part 1<\/a> and explored similarity metrics, embedding processes, and chunking strategies in <a href=\"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/artificial-intelligence\/rag-series-2.html\">Part 2<\/a>. In this third installment, we&#8217;ll dive deep into advanced retrieval techniques, hybrid approaches, and cutting-edge RAG architectures that are revolutionizing how we build intelligent systems.<\/p>\n<h3>Static vs Dynamic Embeddings:<\/h3>\n<p>When we embed chunks, we can choose between static and dynamic embedding approaches, each with distinct advantages and use cases.<\/p>\n<h3>Static embedding:<\/h3>\n<p>Static embeddings refer to fixed vector representations of words or tokens that remain constant regardless of the context in which they appear. These embeddings are typically pre-trained on large corpora using models like Word2Vec or GloVe and capture general semantic and syntactic relationships between words. In contrast to dynamic embeddings, which adapt based on surrounding context, static embeddings assign the same vector to a word in every instance, regardless of sentence structure or meaning[1].<\/p>\n<pre>Static Embedding Example:<\/pre>\n<p>The word &#8220;bank&#8221; gets the same vector in both sentences:<\/p>\n<ul>\n<li>&#8220;He sat by the river bank&#8221; \u2192 vector for bank: [0.45, 0.12, 0.88, 0.36]<\/li>\n<li>&#8220;She deposited money in the bank&#8221; \u2192 vector for bank: [0.45, 0.12, 0.88, 0.36]<\/li>\n<\/ul>\n<p>Each word in the vocabulary has one fixed vector for static embedding.<\/p>\n<h4>Advantages:<\/h4>\n<p>Static embeddings offer several advantages, including computational efficiency, which enables faster inference and reduces memory requirements. Additionally, they provide consistent representations, making them reliable and stable across different tasks and inputs.<\/p>\n<h4>Limitations:<\/h4>\n<p>While static embeddings are computationally efficient and easy to use, they lack the ability to capture contextual nuances, making them less effective for complex or ambiguous queries. Modern Retrieval-Augmented Generation (RAG) systems increasingly favor contextual embeddings from transformer-based models for improved accuracy and relevance.<\/p>\n<p>Popular static embedding models include <em>Word2Vec, GloVe<\/em>, and<em> FastText.<\/em><\/p>\n<h3>Dynamic embedding:<\/h3>\n<p>While static embeddings proved to be strong baselines for measuring semantic similarity, they inherently failed to capture the rich contextual information of natural language. For example, a static model would produce the identical vector for the word &#8220;bank&#8221; in both &#8220;river bank&#8221; and &#8220;money bank,&#8221; despite their distinct meanings. Dynamic embeddings, on the other hand, generate vector representations of words or sentences that vary based on the surrounding context within the text.<\/p>\n<pre>Dynamic Embedding Example:<\/pre>\n<p>With a dynamic model, the word &#8220;bank&#8221; has different vectors based on context:<\/p>\n<ul>\n<li>&#8220;He sat by the river bank&#8221; \u2192 vector for bank: [0.33, 0.55, 0.74, 0.21]<\/li>\n<li>&#8220;She deposited money in the bank&#8221; \u2192 vector for bank: [0.91, 0.13, 0.48, 0.62]<\/li>\n<\/ul>\n<p>Popular models for dynamic embeddings include <em>BERT, SBERT, all-MiniLM, the E5 family, Cohere Embed,<\/em> and<em> OpenAI&#8217;s text embedding<\/em> models.<\/p>\n<h4>Advantages:<\/h4>\n<p>Dynamic embeddings provide context-aware representations that improve the handling of ambiguity and deliver superior performance on complex tasks. They are adaptable to domain-specific contexts, making them highly versatile.<\/p>\n<h4>Limitations:<\/h4>\n<p>Higher computational costs, slower inference speeds, increased memory requirements, and greater implementation complexity are the downsides of using dynamic embeddings<\/p>\n<h3>The Need for Hybrid Approaches:<\/h3>\n<p>There is no single embedding model that works optimally across all industries. While general-purpose embeddings provide a good starting point for building Retrieval-Augmented Generation (RAG) systems, achieving high performance typically requires industry-specific specialization.<\/p>\n<p>When working with domain-specific data, the embedding model may not be trained on specific technical or uncommon terms. Modern RAG systems often employ hybrid approach where specific terms can be effectively retrieved using sparse technique, while semantic understanding is handled by dense vector representations. This combination helps improve recall and relevance in domain-sensitive applications. One of the most effective sparse retrieval techniques is BM25.<\/p>\n<p>Let&#8217;s explore how BM25 works<\/p>\n<h3>BM25 Algorithm:<\/h3>\n<p>BM25 (Best Match 25) is a ranking function widely used in search engines and information retrieval systems. It builds on the TF-IDF model by introducing enhancements like term frequency saturation and document length normalization, offering a more accurate measure of a document\u2019s relevance to a search query[2].<\/p>\n<h4>Why BM25 Matters<\/h4>\n<p>Unlike simple TF-IDF, BM25 addresses two critical issues[3]:<\/p>\n<p>Term frequency saturation: Prevents documents with excessive keyword stuffing from dominating results<br \/>\nDocument length normalization: Ensures fair comparison between short and long documents<\/p>\n<h4>Core Components of BM25:<\/h4>\n<h4>1. Inverse Document Frequency (IDF):<\/h4>\n<p>IDF measures how informative a term is by penalizing common terms and rewarding rare ones.<\/p>\n<h5>Formula:<\/h5>\n<pre>IDF(qi) = log(1 + (N - df(qi) + 0.5)\/(df(qi) + 0.5))<\/pre>\n<p>Where:<\/p>\n<ul>\n<li>N = total number of documents<\/li>\n<li>df(qi) = number of documents containing term a<\/li>\n<li>0.5 constant is added to avoid division by zero, incase if both N and n(qi) are equal and also to avoid negative IDF.<\/li>\n<\/ul>\n<h4>2. Term Frequency Saturation (TF):<\/h4>\n<p>BM25 limits the influence of term repetition\u2014more appearances help, but with diminishing returns.<\/p>\n<p>Formula:<\/p>\n<pre>TF_component = (f(qi, d) \u00d7 (k1 + 1)) \/ (f(qi, d) + k1 \u00d7 (1 - b + b \u00d7 |d|\/avgdl))<\/pre>\n<p>Where:<\/p>\n<ul>\n<li>f(qi, d) = term frequency of qi in document d<\/li>\n<li>|d| = document length<\/li>\n<li>avgdl = average document length<\/li>\n<li>k1 = saturation parameter (typically 1.2-2.0)<\/li>\n<li>b = length normalization (typically 0.75)<\/li>\n<\/ul>\n<h4>BM25 Parameter Tuning:<\/h4>\n<h4>k1 (Term Frequency Saturation):<\/h4>\n<p>Higher values (1.5-2.0): Less saturation, term frequency matters more<br \/>\nLower values (0.5-1.0): More saturation, diminishing returns kick in sooner<\/p>\n<p><strong>b (Length Normalization):<\/strong><\/p>\n<p>b=1: Full length normalization<br \/>\nb=0: No length normalization<br \/>\nb=0.75: Balanced approach (most common)<\/p>\n<h4>3. Document Length Normalization:<\/h4>\n<p>Longer documents naturally have a higher probability of containing a query term and having higher term frequencies. The BM25 algorithm penalizes longer documents to prevent them from having an unfair advantage in relevance scoring. This is where document length normalization comes in. The parameter b in the term frequency formula controls the degree of this normalization. If b is set to 1, the document&#8217;s length fully normalizes the term frequency. If it&#8217;s set to 0, there is no normalization.<\/p>\n<h4>Full BM25 Formula<\/h4>\n<p>The total BM25 score of document D for query Q = {q1, &#8230;, qn}:<\/p>\n<p>BM25(D,Q) = \u03a3 IDF(qi) \u00d7 TF_component(qi, D)<\/p>\n<p>Example Query: \u201cQuantum Physics\u201d<\/p>\n<p>Documents:<\/p>\n<ul>\n<li>D1: Quantum entanglement is a phenomenon in quantum physics. (8 words)<\/li>\n<li>D2: Einstein called quantum entanglement spooky action at a distance. (9 words)<\/li>\n<li>D3: Quantum physics explores the strange world of entanglement. (8 words)<\/li>\n<\/ul>\n<p>The above documents are indexed using Inverted index. it keeps track of terms and their document name matching.<\/p>\n<p>For instance:<br \/>\nFor term: quantum<\/p>\n<pre>It can be hashed to properties like\r\nPosting List: [\r\n(docID: D1, term_freq: 2),\r\n(docID: D2, term_freq: 1),\r\n(docID: D3, term_freq: 1)]<\/pre>\n<p>Query: quantum physics<\/p>\n<h4>BM25 Calculation<\/h4>\n<p>Step 1: avgdl = (8 + 9 + 8) \/ 3 = 8.33<br \/>\nStep 2: IDF values<\/p>\n<ul>\n<li>\u00a0&#8220;quantum&#8221; in all 3 docs \u2192 IDF \u2248 0.133<\/li>\n<li>\u00a0&#8220;physics&#8221; in 2 docs \u2192 IDF \u2248 0.47<\/li>\n<\/ul>\n<p>Step 3: Term frequencies<\/p>\n<ul>\n<li>D1: quantum=2, physics=1<\/li>\n<li>D2: quantum=1, physics=0<\/li>\n<li>D3: quantum=1, physics=1<\/li>\n<\/ul>\n<p>Using k1 = 1.5, b = 0.75:<\/p>\n<p>D1 (|d| = 8):<br \/>\n0.133 * 2*(2.5)<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n2+1.5\u22c5(1\u22120.75+(0.75 * 8\/8.33)<br \/>\n\u200b<br \/>\n\u200b\u22480.133 * 5\/3.455 \u22480.192<\/p>\n<p>Similary Score for &#8220;physics&#8221; is calculated using the same formula: \u22480.479<\/p>\n<p>Total Score for D1 = 0.192 + 0.479 = 0.671<br \/>\nScore(&#8220;quantum&#8221;) \u2248 0.192<br \/>\nScore(&#8220;physics&#8221;) \u2248 0.479<br \/>\n<strong>Total: 0.671<\/strong><\/p>\n<p>D2 (|d| = 9):<\/p>\n<p>Score(&#8220;quantum&#8221;) \u2248 0.128<br \/>\nScore(&#8220;physics&#8221;) = 0<br \/>\n<strong>Total: 0.128<\/strong><\/p>\n<p>D3 (|d| = 8):<\/p>\n<p>Score(&#8220;quantum&#8221;) \u2248 0.135<br \/>\nScore(&#8220;physics&#8221;) \u2248 0.479<br \/>\n<strong>Total: 0.614<\/strong><\/p>\n<p>Final Ranking (Most Relevant First)<\/p>\n<p>1. D1 \u2013 0.671<br \/>\n2. D3 \u2013 0.614<br \/>\n3. D2 \u2013 0.128<\/p>\n<p>we know how dense vector works, it does not necessarily be dense if your use case depends on sparse or static we can choose over that also. Now we need to combine both BM25 and dense vector results to a single combine results, well there are many popular algorithm which can do this, we&#8217;ll examine one popular algorithm: Reciprocal Rank Fusion.<\/p>\n<h4>Reciprocal Rank Fusion (RRF):<\/h4>\n<p>RRF is a ranking fusion technique that combines multiple ranked lists of documents from different retrieval systems or queries. Instead of relying on the retrieval scores, RRF assigns scores to documents based solely on their rank positions in each list by using the reciprocal of the rank. The final ranking is determined by summing these reciprocal rank scores across all lists. This approach emphasizes documents that appear near the top of any list, improving overall retrieval effectiveness without depending on the original retrieval scores[4].<\/p>\n<h5>Formula:<\/h5>\n<pre>RRF_score = \u03a3 (1 \/ (k + rank_i))<\/pre>\n<p>Where:<\/p>\n<p>k = 60 (standard dampening constant)<br \/>\nrank_i = rank from retrieval system i<\/p>\n<h4>Complete RRF Example<\/h4>\n<h4>Step 1: BM25 rank<\/h4>\n<table style=\"border-collapse: collapse;width: 50%\" border=\"1\">\n<thead>\n<tr>\n<th>Doc ID<\/th>\n<th>BM25 Score<\/th>\n<th>BM25 Rank<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>D1<\/td>\n<td>0.671<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>D3<\/td>\n<td>0.614<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>D2<\/td>\n<td>0.128<\/td>\n<td>3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Step 2: Simulated Dense Retrieval (Cosine Similarity)<\/h4>\n<p>Let\u2019s assume you used an embedding model like `all-MiniLM-L6-v2`, and the cosine similarities for the query &#8220;quantum physics&#8221; with each document are as follows:<\/p>\n<table style=\"border-collapse: collapse;width: 50%\" border=\"1\">\n<thead>\n<tr>\n<th>Doc ID<\/th>\n<th>Cosine Similarity<\/th>\n<th>Dense Rank<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>D3<\/td>\n<td>0.94<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>D1<\/td>\n<td>0.91<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>D2<\/td>\n<td>0.76<\/td>\n<td>3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These are plausible\u2014D3 has high semantic alignment with both terms, D1 is close behind, D2 is more about &#8220;entanglement&#8221; and less about &#8220;physics.&#8221;<\/p>\n<h4>Step 3: Apply Reciprocal Rank Fusion (RRF)<\/h4>\n<p>Formula:<\/p>\n<pre>RRF = \u2211 i=1 to n 1\/(k + rank_di)<\/pre>\n<p>Where:<\/p>\n<ul>\n<li>n =number of rankers (2: BM25 and Dense)<\/li>\n<li>k = 60 (commonly used constant to dampen dominance)<\/li>\n<\/ul>\n<p>For each document:<\/p>\n<p>D1<\/p>\n<ul>\n<li>BM25 rank: 1 \u2192 1\/(60 + 1) = 1\/61 \u2248 0.01639<\/li>\n<li>Dense rank: 2 \u2192 1\/(60 + 2) = 1\/62 \u2248 0.01613<\/li>\n<li>RRF Score: 0.01639 + 0.01613 = 0.03252<\/li>\n<\/ul>\n<p>D2<\/p>\n<ul>\n<li>BM25 rank: 3 \u2192 1\/(60 + 3) = 1\/63 \u2248 0.01587<\/li>\n<li>Dense rank: 3 \u2192 1\/(60 + 3) = 1\/63 \u2248 0.01587<\/li>\n<li>RRF Score: 0.01587 + 0.01587 = 0.03174<\/li>\n<\/ul>\n<p>D3<\/p>\n<ul>\n<li>BM25 rank: 2 \u2192 1\/(60 + 2) = 1\/62 \u2248 0.01613<\/li>\n<li>Dense rank: 1 \u2192 1\/(60 + 1) = 1\/61 \u2248 0.01639<\/li>\n<li>RRF Score: 0.01613 + 0.01639 = 0.03252<\/li>\n<\/ul>\n<h4>Step 4: Final Hybrid Ranking via RRF<\/h4>\n<table style=\"border-collapse: collapse;width: 50%\" border=\"1\">\n<thead>\n<tr>\n<th>Doc ID<\/th>\n<th>RRF Score<\/th>\n<th>Final Rank<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>D1<\/td>\n<td>0.03252<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>D3<\/td>\n<td>0.03252<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>D2<\/td>\n<td>0.03174<\/td>\n<td>3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>On top of hybrid search, a reranker model can be used to reorder retrieved documents, further validating their relevance. This is especially useful in hybrid systems combining BM25 and dense vector retrieval. Popular reranking models include BGE, ColBERT, and LLM-based rerankers.<\/p>\n<h3>Advanced RAG Architectures<\/h3>\n<p>Modern RAG systems have evolved beyond simple retrieve-and-generate patterns. Let&#8217;s explore cutting-edge architectures that address specific challenges.<\/p>\n<h3>1. HyDe (Hypothetical Document Embedding)<\/h3>\n<p>It is an advanced variant of Retrieval-Augmented Generation (RAG) that enhances retrieval quality by generating a hypothetical answer based on the user&#8217;s query. Instead of directly fetching documents from a knowledge base for a user query, this approach first uses a language model to generate a synthetic or &#8220;ideal&#8221; document that represents what a good answer might look like. This hypothetical document is then embedded and used as a query to retrieve the most relevant documents.<\/p>\n<h4>Workflow:<\/h4>\n<p>\u2022 The user provides a query.<br \/>\n\u2022 The model generates a synthetic document that hypothetically answers the query.<br \/>\n\u2022 The hypothetical document is embedded and used to retrieve documents from a knowledge base.<br \/>\n\u2022 The model generates a final answer using the retrieved documents, guided by the hypothetical context.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Bridges query-document gap<br \/>\n&#8211; Improves retrieval for complex questions<br \/>\n&#8211; Integrates with existing retrieval systems, requiring minimal modifications<\/p>\n<h3>2. Corrective RAG:<\/h3>\n<p>CRAG implements a self-grading technique for retrieved documents to improve the accuracy. unlike traditional RAG architecture, which does not validates or grades the retrieval documents,\u00a0 CRAG evaluates the quality of the information before moving to the generation phase. CRAG breaks down the retrieved documents into &#8220;knowledge strips&#8221; and grades each strip for relevance. when the confidence on retrieved documents is low, CRAG uses web search to fetch more suitable information to answer the user&#8217;s query[5].<\/p>\n<h4>Workflow:<\/h4>\n<p>The CRAG pipeline follows a conditional, corrective flow:<br \/>\nA. The user submits a query.<br \/>\nB. Documents are retrieved from a static corpus.<br \/>\nC. A lightweight retrieval evaluator (based on T5) scores the relevance of each document to the query.<br \/>\nD. Based on confidence scores, one of three actions is taken:<br \/>\n\u2022 Correct: If relevant documents are found, they are refined.<br \/>\n\u2022 Incorrect: If all documents are irrelevant, a web search is triggered.<br \/>\n\u2022 Ambiguous: If relevance is uncertain, both internal and external sources are used.<br \/>\nE. Retrieved documents are decomposed into knowledge strips (e.g., D1 \u2192 K11, K12, K13). Each strip is scored, irrelevant ones are filtered out, and relevant ones are recomposed into a refined knowledge base.<br \/>\nF. The refined knowledge is passed to a language model to generate the final response.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Self-correcting mechanism<br \/>\n&#8211; Reduces hallucination<\/p>\n<h3>3. Self-RAG:<\/h3>\n<p>Self- RAG is a framework that enables language models to decide when to retrieve external knowledge and how to evaluate it. It uses special reflection tokens like ISREL, ISSUP, and ISUSE to assess the relevance, support, and usefulness of generated content. The model retrieves documents only when needed, generates candidate outputs, and critiques them to select the most factual and helpful response. This self-reflective process improves factual accuracy and citation quality in generation tasks[6].<\/p>\n<h4>Workflow:<\/h4>\n<p>1. User provides a query<br \/>\n2. Model decides whether retrieval is required<br \/>\n\u2022 The model predicts a special Retrieve token (Yes, No, or Continue) to determine if external knowledge is needed.<br \/>\n\u2022 This decision is based on the input and any previously generated content.<br \/>\n3. If retrieval is required<br \/>\n\u2022 The model adds the Retrieve=Yes token in the output.<br \/>\n\u2022 It then fetches documents from a knowledge base (e.g., Wikipedia) using a retriever like Contriever.<br \/>\n4. For each retrieved document<br \/>\n\u2022 The model generates a candidate output segment (e.g., a sentence).<br \/>\n\u2022 This is done in parallel for each document.<br \/>\n5. Each candidate output is evaluated using reflection tokens:<br \/>\n\u2022 ISREL: Is the document relevant to the query?<br \/>\n\u2022 ISSUP: Does the document support the generated output?<br \/>\n\u2022 ISUSE: How useful is the output overall (rated 1\u20135)?<br \/>\n6. Best output is selected<br \/>\n\u2022 A beam search ranks the outputs using a weighted score based on the reflection tokens.<br \/>\n\u2022 The best segment is chosen and added to the final response.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Dynamic retrieval decisions<br \/>\n&#8211; Built-in fact-checking<br \/>\n&#8211; Improved citation quality<\/p>\n<h3>4. Agentic RAG:<\/h3>\n<p>Agentic RAG is an advanced paradigm that enhances traditional RAG systems by embedding autonomous AI agents into the retrieval and generation pipeline. These agents are capable of:<br \/>\n\u2022 Dynamic decision-making<br \/>\n\u2022 Iterative reasoning<br \/>\n\u2022 Tool use<br \/>\n\u2022 Multi-agent collaboration<br \/>\nThis enables Agentic RAG systems to adaptively manage complex, multi-step tasks and deliver highly contextual, real-time, and accurate responses across diverse domains such as healthcare, finance, education, and legal analysis. The Agentic RAG workflow can vary depending on the architecture (single-agent, multi-agent)[7].<\/p>\n<h4>Workflow:<\/h4>\n<p>1. A user submits a query to the system.<br \/>\n2. A coordinator agent evaluates the query and delegates tasks to specialized agents based on the query type and complexity.<br \/>\n3. Specialized Retrieval Agents:<br \/>\nAgents retrieve data from:<br \/>\n\u2022 Structured databases (via SQL)<br \/>\n\u2022 Unstructured documents (via semantic search)<br \/>\n\u2022 Web sources (via APIs)<br \/>\n\u2022 Graph knowledge bases (for relational reasoning)<br \/>\n\u2022 Recommendation systems (for personalization)<br \/>\nAgents may use external tools (e.g., vector search, web search, APIs) to enhance retrieval and reasoning.<br \/>\n4. Agents reflect on intermediate outputs, critique results, and plan next steps iteratively to refine the response.<br \/>\n5. Retrieved and validated data is passed to a Large Language Model (LLM) for synthesis into a coherent, context-aware response.<br \/>\n6. The final output is generated and delivered to the user, often with citations or actionable insights.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Handles complex, multi-step queries<br \/>\n&#8211; Specialized expertise per domain<br \/>\n&#8211; Iterative improvement<\/p>\n<h3>5. Multi-step Reasoning:<\/h3>\n<p>Traditional RAG often performs retrieval and generation in a single step. Multi-step reasoning involves breaking down complex queries into a series of simpler sub-queries, performing retrieval and generation at each step.This enables the RAG system to handle questions that require logical reasoning, inference, or the synthesis of information from multiple sources[8].<\/p>\n<h4>Workflow:<\/h4>\n<p>1. Query Decomposition: Break down the complex query into simpler sub-queries.<br \/>\n2. Iterative Retrieval and Generation: For each sub-query, retrieve relevant information and generate intermediate reasoning steps.<br \/>\n3. Knowledge Fusion: Combine all intermediate responses and retrieved content.<br \/>\n4. Reasoning Chains: Use the fused knowledge to build a coherent chain of reasoning, which may loop back to guide further retrieval.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Improves factual accuracy<br \/>\n&#8211; Handles complex analytical queries<\/p>\n<h3>6. Multi-Modal RAG:<\/h3>\n<p>Multimodal RAG is an advanced RAG framework that enhances the capabilities of large language models (LLMs) by enabling them to reason over multiple types of data not just text, but also images, audio, video, and more. It extends the traditional RAG pipeline, which retrieves relevant textual documents to support answer generation, by incorporating multimodal content into both the retrieval and generation stages[9].<\/p>\n<h4>Workflow:<\/h4>\n<p>1. Data Extraction: Collect and ingest multimodal data from various sources:<\/p>\n<ul>\n<li>Text: documents, manuals, web pages<\/li>\n<li>Images: diagrams, screenshots, photos<\/li>\n<li>Audio\/Video : recordings, tutorials<\/li>\n<\/ul>\n<p>2. Embedding Generation: Convert each modality into vector representations.<\/p>\n<ul>\n<li>Text \u2192 via a text encoder (e.g., BERT, OpenAI)<\/li>\n<li>Image \u2192 via a vision encoder (e.g., CLIP, BLIP)<\/li>\n<li>Audio \u2192 via an audio encoder (e.g., Whisper)<\/li>\n<\/ul>\n<p>3. Vector Store Setup: Choose how to organize and store embeddings<\/p>\n<ul>\n<li>Single vector store: Combine all modalities (e.g., text + image summaries)<\/li>\n<li>Multiple vector stores: Separate stores for each modality (e.g., one for text, one for images)<\/li>\n<\/ul>\n<p>4. Query Embedding: Embed the user query using multimodal.<\/p>\n<p>5. Similarity Search:Perform separate similarity searches in vector stores.Retrieve top-k relevant text chunks and images. Combine retrieved content into a unified context.<\/p>\n<p>6. Answer Generation: Feed them into a multimodal LLM to generate the final answer.<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Richer context for generation<br \/>\n&#8211; Handles diverse query types<\/p>\n<h3>7. Graph RAG:<\/h3>\n<p>GraphRAG represents an enhanced RAG framework that augments large language model (LLM) capabilities by incorporating graph-structured data into both retrieval and generation processes. In contrast to conventional RAG systems that depend on flat text or image embeddings, GraphRAG exploits the interconnected and multi-faceted characteristics of graph structures to obtain information that is more contextually meaningful and structurally pertinent[10].<\/p>\n<h4>Workflow:<\/h4>\n<h4>1. Ingestion Phase:<\/h4>\n<p>This phase prepares the graph-structured knowledge base from raw data.<br \/>\n\u2022 Identify key entities or concepts from source documents.<br \/>\n\u2022 Detect and define relationships between entities (e.g., &#8220;works for&#8221;, &#8220;located in&#8221;).<br \/>\n\u2022 Construct a graph network where nodes represents entities\/concepts and edges represents the connections between them.<br \/>\n\u2022 Encode each node into a vector using embedding models.<br \/>\n\u2022 Maintain the graph structure in a graph database or memory-efficient format for fast retrieval.<\/p>\n<h4>2. Query Phase:<\/h4>\n<p>This phase handles user queries and generates responses using the graph.<br \/>\n\u2022 Perform entity recognition and relation extraction from the user query.<br \/>\n\u2022 Encode the query into a vector using the same embedding model used during ingestion.<br \/>\n\u2022 Formulate a structured query (e.g., SPARQL, Cypher) or identify seed nodes for traversal.<br \/>\n\u2022 Traverse the graph (e.g., BFS, DFS, GNN-based) to retrieve relevant nodes, paths, or subgraphs.<br \/>\n\u2022 Prune, rerank, or verbalize the retrieved subgraph to prepare it for the LLM.<br \/>\n\u2022 Feed the organized context into an LLM or hybrid model to generate a grounded response<\/p>\n<h4>Advantages:<\/h4>\n<p>&#8211; Captures complex relationships<br \/>\n&#8211; Enables reasoning over connections<br \/>\n&#8211; Handles multi-hop queries<br \/>\n&#8211; Provides explainable retrieval paths<\/p>\n<h3>Looking Ahead: RAG Part 4 Preview<\/h3>\n<p>In our final installment of this RAG series, we&#8217;ll cover<\/p>\n<ul>\n<li>Fine-tuning Embedding Models<\/li>\n<li>Popular RAG Tools and Frameworks<\/li>\n<\/ul>\n<p>Stay tuned<\/p>\n<h3>References:<\/h3>\n<p>[1] <a href=\"https:\/\/zilliz.com\/ai-faq\/what-is-the-difference-between-static-and-contextual-embeddings\">what is the difference between static and contextual embeddings.<\/a><\/p>\n<p>[2] <a href=\"https:\/\/www.researchgate.net\/publication\/220613776_The_Probabilistic_Relevance_Framework_BM25_and_Beyond\">The probabilistic relevance framework: BM25 and beyond<\/a>.<\/p>\n<p>[3] <a href=\"https:\/\/zilliz.com\/learn\/mastering-bm25-a-deep-dive-into-the-algorithm-and-application-in-milvus\">Mastering BM25: A deep dive into the algorithm and application in Milvus.<\/a><\/p>\n<p>[4] <a href=\"https:\/\/docs.zilliz.com\/docs\/reranking-rrf\">Re-ranking with Reciprocal Rank Fusion (RRF).<\/a><\/p>\n<p>[5] <a href=\"https:\/\/arxiv.org\/pdf\/2401.15884\">Corrective Retrieval Augmented Generation.\u00a0<\/a><\/p>\n<p>[6] <a href=\"https:\/\/arxiv.org\/pdf\/2310.11511\">Self-RAG: Self evaluating the retrieved information using special tokens.<\/a><\/p>\n<p>[7] <a href=\"https:\/\/arxiv.org\/pdf\/2501.09136\">Agentic Retrieval-Augmented Generation.<\/a><\/p>\n<p>[8] <a href=\"https:\/\/arxiv.org\/pdf\/2212.10509\">Multi-Step Reasoning Using Chain-of-Thought.<\/a><\/p>\n<p>[9] <a href=\"https:\/\/arxiv.org\/pdf\/2410.21943\">Optimizing RAG with multimodal inputs for industrial applications.<\/a><\/p>\n<p>[10] <a href=\"https:\/\/arxiv.org\/pdf\/2501.00309\">Retrieval-Augmented Generation with Graphs.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have discussed the core components of RAG in Part 1 and explored similarity [&hellip;]<\/p>\n","protected":false},"author":834,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[4],"tags":[423,425,426,424,427,324],"coauthors":[358,326,372],"class_list":["post-3662","post","type-post","status-publish","format-standard","hentry","category-artificial-intelligence","tag-bm25","tag-crag","tag-graphrag","tag-hybridsearch","tag-rrf","tag-rag"],"acf":[],"_links":{"self":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/users\/834"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/comments?post=3662"}],"version-history":[{"count":14,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3662\/revisions"}],"predecessor-version":[{"id":4296,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3662\/revisions\/4296"}],"wp:attachment":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/media?parent=3662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/categories?post=3662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/tags?post=3662"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/coauthors?post=3662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}