<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GenAI Journal]]></title><description><![CDATA[GenAI Journal]]></description><link>https://gopallalwani09.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 09:58:40 GMT</lastBuildDate><atom:link href="https://gopallalwani09.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Retrieval-Augmented Generation (RAG): Architecture, Applications, and Limitations]]></title><description><![CDATA[Lets think of an closed-book exam in which the syllabus was 500-600 pages and we had to remember each and every factual information. Now in exam if a question comes from a topic which we know partiall]]></description><link>https://gopallalwani09.hashnode.dev/retrieval-augmented-generation-rag-architecture-applications-and-limitations</link><guid isPermaLink="true">https://gopallalwani09.hashnode.dev/retrieval-augmented-generation-rag-architecture-applications-and-limitations</guid><dc:creator><![CDATA[Gopal M. Lalwani]]></dc:creator><pubDate>Sat, 18 Jul 2026 13:46:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a44d1306cff3c7b35334ea7/15d0758b-312e-450a-ab34-0a4f161ebca0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lets think of an closed-book exam in which the syllabus was 500-600 pages and we had to remember each and every factual information. Now in exam if a question comes from a topic which we know partially. So instead of leaving the question blank we instead tend to make up the answer. This is the same situation with an LLM if we ask it something and it does not have enough info on that then it will try to make up things.  </p>
<p>Instead if the exam was open-book, looking at any question we will see our book's index and try to find that chapter which is related to our question and then in that we will search for our answer. This is what RAG is.</p>
<h3>What RAG is and why it was introduced ?</h3>
<p>Large Language Models (LLMs) are trained on large amount of data, enabling them to perform a wide range of language tasks. However, their knowledge is limited to the data available during training, meaning they cannot access newly published information or private documents. As a result, they may produce outdated or incorrect responses, a phenomenon known as <strong>hallucination</strong>.</p>
<p><strong>Retrieval-Augmented Generation (RAG)</strong> was introduced to overcome this limitation. Instead of relying solely on the model's internal knowledge, RAG retrieves relevant information from an external knowledge source such as documents, databases, or knowledge bases and provides it to the LLM as context before it generates a response.</p>
<h3>How a basic RAG pipeline works</h3>
<img src="https://cdn.hashnode.com/uploads/covers/6a44d1306cff3c7b35334ea7/1e53a0bc-3ed1-4637-a559-88c77aabc421.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Document Processing:</strong> The source documents are first divided into smaller, meaningful sections called <strong>chunks</strong>. Chunking makes it easier to retrieve only the most relevant portions of a document.</p>
<p><strong>Embedding Generation:</strong> Each chunk is converted into a numerical representation, known as an <strong>embedding</strong>, which captures its semantic meaning. These embeddings are then stored in a <strong>vector database</strong>.</p>
<p><strong>User Query:</strong> When a user submits a question, the query is also converted into an embedding using the same embedding model.</p>
<p><strong>Retrieval:</strong> The vector database compares the query embedding with the stored document embeddings and retrieves the <strong>most relevant chunks</strong> based on semantic similarity.</p>
<p><strong>Prompt Augmentation:</strong> The retrieved chunks are combined with the user's original query to create an enriched prompt. This provides the LLM with the necessary context to answer the question.</p>
<p><strong>LLM Response:</strong> Finally, the augmented prompt is passed to the language model, which generates a response grounded in the retrieved information</p>
<h3>Common scenarios where RAG works well</h3>
<p>RAG is particularly useful in applications where responses need to be based on external or frequently updated information rather than the LLM's pre-trained knowledge. It is widely used in enterprise knowledge bases to answer questions about company policies, technical documentation, and employee handbooks. Similarly, customer support systems use RAG to retrieve information from product manuals, FAQs, and troubleshooting guides, enabling them to provide more accurate and context-specific responses.</p>
<p>RAG is also effective for document question answering, where users can query reports, research papers, contracts, or PDFs and receive answers grounded in the document content. In domains such as healthcare, legal services, and research, RAG helps retrieve relevant guidelines, regulations, or academic literature, allowing the language model to generate responses that are both context-aware and based on reliable external information.</p>
<h3>Why RAG sometimes gives incorrect answers</h3>
<p>Although RAG enhances the accuracy of LLMs by providing relevant external information, it does not guarantee correct responses. The quality of the generated answer depends on the relevance, completeness, and freshness of the retrieved information, as well as the LLM's ability to interpret it correctly. Issues such as poor retrieval, ineffective chunking, context window limitations, outdated knowledge bases, and model hallucinations can still lead to incorrect or misleading responses, making careful system design and maintenance essential for reliable performance. It also depends on the query of the user if it does not matches with the context LLM will make an answer by itself.</p>
<h3>Limitations of RAG</h3>
<p><strong>1. Poor Retrieval and Missing Context</strong><br />The effectiveness of a RAG system depends heavily on its retrieval component. If the retriever fails to fetch the most relevant documents or omits important information, the language model will generate responses based on incomplete or irrelevant context. As a result, the answer may be inaccurate or fail to fully address the user's query.</p>
<p><strong>2. Poor Chunking and Its Impact on Responses</strong><br />Documents are typically divided into smaller chunks before being stored in a vector database. If the chunks are too small, important contextual information may be lost. Conversely, overly large chunks may contain unrelated information, reducing retrieval precision. Choosing an appropriate chunk size and overlap is therefore essential for generating accurate responses.</p>
<p><strong>3. Context Window Limitations</strong><br />Large language models have a fixed context window that limits the amount of retrieved information they can process in a single request. When too many relevant documents are retrieved, some information may be truncated or excluded, causing the model to overlook important details and produce incomplete answers.</p>
<p><strong>4. Hallucinations Even with RAG</strong><br />Although RAG reduces hallucinations by grounding responses in retrieved documents, it does not eliminate them completely. The model may still generate unsupported or incorrect information, especially when the retrieved context is ambiguous, contradictory, or insufficient to answer the query accurately.</p>
<p><strong>5. Keeping Knowledge Bases Up to Date</strong><br />A RAG system is only as reliable as the knowledge base it retrieves from. If new documents are not regularly added or outdated information is not removed, the system may provide obsolete or inaccurate responses. Maintaining an up-to-date knowledge base requires continuous document ingestion, indexing, and re-embedding, which can be computationally expensive and operationally challenging.</p>
<h3>When RAG is not the right solution</h3>
<p>While Retrieval-Augmented Generation (RAG) is highly effective for applications that rely on external knowledge, it is not the ideal solution for every use case. If the required information is already contained within the model's training data and does not change frequently, a standard Large Language Model (LLM) is often sufficient and avoids the additional complexity of document retrieval. RAG may also be unnecessary for tasks such as creative writing, brainstorming, code generation, or conversational assistance, where responses depend more on reasoning and language generation than on retrieving factual information. Additionally, implementing and maintaining a RAG system involves extra infrastructure, including document preprocessing, vector databases, embedding generation, and regular knowledge base updates. For small-scale applications or domains with limited and static data, these costs may outweigh the benefits, making a standalone LLM a simpler and more practical choice.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding LLMs: From Prompt to Response]]></title><description><![CDATA[What is an LLM?
An LLM (Large Language Model) is a model that has been trained on a very large data so that it can answer our questions effectively based on the data it has been trained on. We can ima]]></description><link>https://gopallalwani09.hashnode.dev/understanding-llms-from-prompt-to-response</link><guid isPermaLink="true">https://gopallalwani09.hashnode.dev/understanding-llms-from-prompt-to-response</guid><dc:creator><![CDATA[Gopal M. Lalwani]]></dc:creator><pubDate>Wed, 01 Jul 2026 13:58:02 GMT</pubDate><content:encoded><![CDATA[<img src="https://cdn.hashnode.com/uploads/covers/6a44d1306cff3c7b35334ea7/d1438b1c-d994-484a-a21f-ccb4110acaa4.jpg" alt="" style="display:block;margin:0 auto" />

<h2>What is an LLM?</h2>
<p>An LLM (Large Language Model) is a model that has been trained on a very large data so that it can answer our questions effectively based on the data it has been trained on. We can imagine it like a student who has read all the chapters of a book and remembers each and every word in it. So now if we ask him any question from that book so he can answer it. It is basically an engine which will give us some output based on the input which we have provided and this input could be in <strong>Natural Language.</strong></p>
<p>Computers do not understand human language, their nuance and context. LLMs act as a bridge between human and computer processing so that computer can process our Natural Language and give effective outputs. They can summarize text, translate languages and solve complex problems. Some of the common applications in daily life are customer service chatbots, grammar checkers, coding copilots for software developers etc.</p>
<p>Some common examples of LLMs</p>
<ul>
<li><p><strong>Gemini:</strong> Developed by Google.</p>
</li>
<li><p><strong>ChatGPT:</strong> Developed by OpenAI</p>
</li>
<li><p><strong>Claude:</strong> Developed by Anthropic.</p>
</li>
</ul>
<h2>What Happens When You Send a Message?</h2>
<p>When we send a message a lot of processes are involved in translating our intent to a response. The message which we type is called prompt and this prompt dictates the context, tone, and specific instructions the model needs to begin its calculations. The LLM does not read our message like a human instead it breaks the entire prompt into pieces which all have a numerical value and then finds the relation between the words to find the true intent of the prompt.</p>
<p>The LLM generates a response word by word ie, one word at a time. It calculates the probability of which word should come next after our prompt and then word by word it generates a sentence. LLM is not a search engine that will query in its database of pre-written answer for response it instead they predict the next word and generate a response from the scratch.</p>
<h2>Why Computers Don't Understand Human Language</h2>
<p>Computers only understand binary language which includes 0s and 1s. On the other hand, humans communicate in abstract concepts, emotions, and words. If we feed a computer the word "Apple," it has no concept of a red, crunchy fruit. To process "Apple," the word must be mapped to a specific number or a complex array of numbers so the computer's processor can perform mathematical operations on it. To convert language into math, AI systems chop text into manageable pieces that can be assigned numerical values. These pieces are known as tokens.</p>
<h2>Tokenization</h2>
<p>Tokens are the fundamental units of data processed by an LLM. We can think of them translation to language which the LLM understands. If an AI attempted to assign a unique number to every single word in every language including misspellings, slang, and emerging terminology its dictionary would be infinitely large. By breaking words down into smaller sub word chunks, the AI requires only a finite vocabulary (typically around 50,000 to 100,000 tokens) to construct any possible word. A token is not always a whole word. The word <code>Hamburger</code> might be split into three tokens: <code>[Ham]</code>, <code>[bur]</code>, <code>[ger]</code>.</p>
<h2>Transformers</h2>
<p>The Transformer is the core technology the "engine" that powers modern LLMs. It was introduced in a famous 2017 Google research paper called <em>"<em>Attention Is All You Need.</em>"</em> Imagine trying to read a long paragraph, but you are forced to look at only one word at a time through a tiny keyhole. By the time you reach the end, you will likely have forgotten how the first sentence started. Older AI models worked exactly like this: they processed text <em>sequentially</em> (one word strictly after another).</p>
<p>Transformers changed everything by processing all the words in a prompt simultaneously (in <em>parallel</em>). Instead of reading word-by-word, a Transformer looks at the entire chunk of text all at once. This made AI exponentially faster to train and gave it a much stronger memory for context. To understand a whole block of text at once, Transformers use a mathematical mechanism called <strong>Self-Attention</strong>.</p>
<p>If you give the AI the sentence: "I went to the bank to deposit money," the AI calculates a high "attention score" between the word <em>bank</em> and the words <em>deposit</em> and <em>money</em>. These high scores tell the AI that in this specific sentence, <em>bank</em> means a financial institution. If the sentence was "The bank of the river," the attention scores would connect <em>bank</em> to <em>river</em>, telling the AI it means a patch of land. By scoring the relationships between every single word in your prompt, the AI perfectly understands the exact context of what you are saying.</p>
]]></content:encoded></item></channel></rss>