<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Haricharan Kamireddy on Medium]]></title>
        <description><![CDATA[Stories by Haricharan Kamireddy on Medium]]></description>
        <link>https://medium.com/@Haricharan-Kamireddy?source=rss-ccfdbbbba8eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8qwb9ClcB2qcjNTA134qTQ.png</url>
            <title>Stories by Haricharan Kamireddy on Medium</title>
            <link>https://medium.com/@Haricharan-Kamireddy?source=rss-ccfdbbbba8eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:07:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Haricharan-Kamireddy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Fix the “Type Vector Does Not Exist” Error in PGVector (Docker)]]></title>
            <link>https://medium.com/@Haricharan-Kamireddy/how-to-fix-the-type-vector-does-not-exist-error-in-pgvector-docker-1d694a5f2de7?source=rss-ccfdbbbba8eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d694a5f2de7</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[postgresql-pgvector]]></category>
            <dc:creator><![CDATA[Haricharan Kamireddy]]></dc:creator>
            <pubDate>Wed, 20 May 2026 16:35:08 GMT</pubDate>
            <atom:updated>2026-05-20T16:35:08.891Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xuOws71trMlwndqgZQhD7w.png" /><figcaption>Type Vector Does Not Exists</figcaption></figure><p><strong>Quick Answer (TL;DR) : </strong>To fix this, enable the extension inside your new database by running: CREATE EXTENSION IF NOT EXISTS vector;. PostgreSQL won&#39;t recognize the VECTOR(1536) data type until this command activates the pgvector extension within that specific database context. Run it before creating your table.</p><p>If you are working with PostgreSQL and Docker to build AI-driven applications, large language models (LLMs), or Retrieval-Augmented Generation (RAG) pipelines, you’ve likely turned to <strong>pgvector</strong> to handle vector embeddings.</p><p>However, a very common stumbling block for beginners and advanced developers alike happens right after spinning up a brand new database. You write your standard SQL script to create a table with a VECTOR(1536) column (perfect for OpenAI embeddings), click execute, and get hit with this frustrating message:</p><blockquote><strong><em>ERROR: type “vector” does not exist</em></strong></blockquote><p>In this quick tutorial, we will look at exactly why this error happens and the simple SQL command you need to run to fix it permanently.</p><h3>Why Does This Error Happen?</h3><p>When you pull and run a Docker image for pgvector, the extension is installed on the PostgreSQL instance, but <strong>it is not automatically activated for every new database you create</strong>.</p><p>Every time you create a fresh database instance (for example, creating a database named AI_Code_with_Haritha), PostgreSQL sets it up with standard data types. It doesn’t automatically assume you want to use vector extensions. Because the extension isn&#39;t enabled inside that specific database context, PostgreSQL has no idea what a VECTOR data type is.</p><h3>Step-by-Step Guide to Fix the Error</h3><p>Follow these quick steps using your favorite database management tool (like pgAdmin) to resolve the issue:</p><h3>Step 1: Connect to Your Database and Open the Query Tool</h3><ol><li>Open your database management tool connected to your Docker pgvector instance.</li><li>Select your newly created database.</li><li>Right-click on the database name and select <strong>Query Tool</strong> to open a new SQL editor.</li></ol><h3>Step 2: Enable the Vector Extension</h3><p>Before trying to create any tables that use vectors, you must enable the pgvector extension within this database. Copy and run the following command:</p><pre>CREATE EXTENSION IF NOT EXISTS vector;</pre><p>Execute this command. You should see a success message indicating that the extension has been successfully created.</p><h3>Step 3: Create Your Vector Table</h3><p>Now that PostgreSQL recognizes the vector data type, you can safely run your table creation script without any issues. For example:</p><pre>CREATE TABLE documents (<br>    id SERIAL PRIMARY KEY,<br>    content TEXT,<br>    embedding VECTOR(1536)<br>);</pre><p>Click execute, and your table will be created flawlessly! You can verify this by checking your database schemas under the <strong>Tables</strong> folder, where your new documents table will now be listed.</p><h3>Conclusion &amp; Next Steps</h3><p>The critical takeaway is simple: <strong>Whenever you create a new database in a Docker pgvector instance, you must explicitly enable the extension using </strong><strong>CREATE EXTENSION IF NOT EXISTS vector; before defining vector columns..</strong></p><h3>🎁 Bonus Resources for SQL Learners</h3><p>If you are looking to master SQL from beginner to advanced levels, or preparing for backend and data engineering interviews:</p><ul><li>Check out my blog for <strong>250+ free SQL practice questions</strong>.</li><li>Test your skills with our interactive SQL quizzes.</li><li>Score <strong>80% or higher</strong> on the quiz to unlock a <strong>free downloadable PDF</strong> containing the top 25 most-asked real-time scenario interview questions!</li></ul><p><em>Want to watch this fix in action? Check out the full step-by-step video guide on my YouTube channel:</em> <a href="https://www.youtube.com/watch?v=c47CxKaKg6I">Fix “Type Vector Does Not Exist” &amp; Create VECTOR(1536) Tables</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d694a5f2de7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fix “Vector Does Not Exist” in PostgreSQL pgvector (VECTOR1536)]]></title>
            <link>https://medium.com/@Haricharan-Kamireddy/how-to-fix-vector-does-not-exist-in-postgresql-pgvector-vector1536-bc0e12a297b6?source=rss-ccfdbbbba8eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0e12a297b6</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[pgvector]]></category>
            <dc:creator><![CDATA[Haricharan Kamireddy]]></dc:creator>
            <pubDate>Mon, 11 May 2026 18:57:41 GMT</pubDate>
            <atom:updated>2026-05-19T06:04:35.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62AKRfIk9r98oOgXrlwWyg.jpeg" /></figure><p>A beginner-friendly production guide for fixing SQL State 42704, enabling pgvector correctly, and building scalable semantic search systems with PostgreSQL.</p><p>Imagine this. You’ve spent hours building your AI application. Your OpenAI API key works perfectly, your embeddings are generating successfully, and your Python script finally connects to PostgreSQL.</p><p>Everything looks ready. You run the project expecting semantic search magic… and suddenly your terminal crashes with:</p><p>text</p><pre>ERROR: type &quot;vector&quot; does not exist (SQL State 42704)</pre><p>If you are new to AI engineering, this error feels incredibly confusing at first. I still remember the first time I saw it while building a Retrieval-Augmented Generation (RAG) pipeline. My PostgreSQL server was running fine, the database connection worked, and the SQL syntax looked correct.</p><p>But PostgreSQL completely failed when it saw: VECTOR(1536)</p><p>So what exactly is happening here? Let’s break it down step by step in the simplest way possible.</p><p>Why PostgreSQL Does Not Understand VECTOR(1536)</p><p>PostgreSQL is a traditional relational database. Out of the box, it understands text, numbers, dates, JSON, and standard relational tables.</p><p>But AI embeddings are different. An embedding is basically a very large list of numbers representing the semantic meaning of text. PostgreSQL cannot naturally understand this format unless we extend its capabilities.</p><p>Think of it like this: Trying to use VECTOR(1536) without pgvector is similar to trying to open a Photoshop file on a computer that has no image editing software installed. The computer itself works perfectly. It simply does not recognize the format.</p><p>That is exactly why PostgreSQL throws this error.</p><p>The Real Reason SQL State 42704 Happens</p><p>This is the part many beginners misunderstand. Most developers think: <em>“I installed pgvector on the server, so everything should work now.”</em></p><p>Unfortunately, PostgreSQL extensions do not work globally by default. They are database-scoped. This means:</p><ul><li>pgvector may exist on the server hardware.</li><li>Your specific database instance still does not know what VECTOR means.</li></ul><p>So when PostgreSQL compiles this line:</p><p>sql</p><pre>embedding VECTOR(1536)</pre><p>It responds with:</p><p>text</p><pre>ERROR: type &quot;vector&quot; does not exist<br>SQL State: 42704</pre><p>This happens because the extension has not been explicitly activated inside your active database connection.</p><p>Step 1 — Create Your Database</p><p>First, create a dedicated database for your AI project.</p><p>sql</p><pre>CREATE DATABASE ai_project;</pre><p>After creating it, make sure to take these actions:</p><ol><li>Disconnect from your default connection.</li><li>Reconnect directly to the new ai_project database.</li><li>Continue the setup process there.</li></ol><p>This step is important because pgvector must be enabled inside the exact database where your tables live.</p><p>Step 2 — Enable the pgvector Extension</p><p>Now we teach PostgreSQL how to understand vectors. Run this command:</p><p>sql</p><pre>CREATE EXTENSION IF NOT EXISTS vector;</pre><p>This single line activates pgvector inside your current database context. Once this works successfully:</p><ul><li>VECTOR becomes a valid, recognized datatype.</li><li>Distance similarity operators become available.</li><li>PostgreSQL officially becomes AI-ready.</li></ul><p>Step 3 — Create Your VECTOR(1536) Table</p><p>Now we can safely create an embedding table. For OpenAI models such as text-embedding-3-small or text-embedding-ada-002, the standard embedding size is exactly 1536 dimensions.</p><p>Use this schema layout:</p><p>sql</p><pre>CREATE TABLE documents (<br>    id SERIAL PRIMARY KEY,<br>    content TEXT,<br>    embedding VECTOR(1536)<br>);</pre><p>Let’s quickly break down this table structure:</p><ul><li>id: A unique serial identifier for each row.</li><li>content: The original raw text data or document chunk.</li><li>embedding: The semantic meaning stored cleanly as a high-dimensional vector.</li></ul><p>This core structure is what powers your semantic search query engines, RAG context retrieval, AI chatbots, and recommendation algorithms.</p><p>Step 4 — Why Performance Becomes Slow</p><p>At this point, your code works correctly. But another challenge appears very quickly: Performance scale.</p><p>Without indexing, PostgreSQL scans every embedding row one by one via a sequential scan. That may feel instant with 100 or 1,000 rows. But once your production datasets grow larger:</p><ul><li>50,000 vectors</li><li>100,000 vectors</li><li>Millions of embedded strings</li></ul><p>Your semantic search execution times will spike painfully. This is why vector indexing is non-negotiable.</p><p>Step 5 — Understanding HNSW vs IVFFlat</p><p>The pgvector extension supports multiple approximate nearest neighbor (ANN) indexing strategies. The two most popular choices are IVFFlat and HNSW.</p><p>IVFFlat</p><p>IVFFlat groups embeddings into distinct bucket lists.</p><ul><li>Advantages: Lower operational RAM usage, faster index creation times, simpler internal overhead.</li><li>Disadvantages: Lower overall search recall accuracy, drops in speed at massive scale, requires regular index rebuilding as data changes.</li></ul><p>HNSW (Hierarchical Navigable Small World)</p><p>HNSW builds multi-layered, graph-like relationships connecting similar vectors together.</p><ul><li>Advantages: Extremely fast query retrieval speeds, exceptionally high recall accuracy, robust under heavy production loads.</li><li>Disadvantages: Higher memory consumption footprint, longer initial index build times.</li></ul><p>For most real-world production RAG configurations, HNSW is the standard industry choice.</p><p>Step 6 — Create a Production HNSW Index</p><p>Now let’s optimize your database for production scale. Run this command:</p><p>sql</p><pre>CREATE INDEX ON documents<br>USING hnsw (embedding vector_cosine_ops);</pre><p>This allows PostgreSQL to perform lightning-fast cosine similarity searches across your vector spaces. Instead of scanning every database row manually, the execution engine jumps along graph layers directly toward the most semantically relevant matches.</p><p>Why Developers Love pgvector</p><p>The primary reason pgvector has exploded in popularity is architectural simplicity. Instead of managing:</p><ol><li>A relational database separately.</li><li>A standalone specialized vector database separately.</li><li>Complex synchronization workers to keep metadata aligned.</li></ol><p>Everything stays unified inside PostgreSQL. This provides simpler infrastructure, easier point-in-time backups, reliable ACID transactions, and fewer moving parts to break in production.</p><p>Final Thoughts</p><p>The “vector does not exist” error looks intimidating at first, but once you understand how extension scoping operates inside PostgreSQL, the fix is straightforward.</p><p>The primary takeaways are clear:</p><ul><li>Enable pgvector inside the specific database instance you are querying.</li><li>Ensure your VECTOR column dimension constraints match your embedding model output.</li><li>Implement ANN indexing (HNSW) early to preserve query performance.</li></ul><p>Modern AI systems are no longer just about picking the right LLM. The real power often comes down to the efficiency of your retrieval systems and database engineering underneath.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0e12a297b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Critical Lessons I Learned Building a Production RAG System in Python]]></title>
            <link>https://medium.com/@Haricharan-Kamireddy/5-critical-lessons-i-learned-building-a-production-rag-system-in-python-84d475ae3c2b?source=rss-ccfdbbbba8eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/84d475ae3c2b</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nnl]]></category>
            <dc:creator><![CDATA[Haricharan Kamireddy]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 18:46:21 GMT</pubDate>
            <atom:updated>2026-04-22T18:46:21.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJ4OEJ00KaMIxfOX-PV_Pw.png" /><figcaption>Why RAG System Fails in Production</figcaption></figure><h3>Introduction</h3><p>Most Retrieval-Augmented Generation (RAG) systems look perfectly fine when you run them locally. In testing, everything feels smooth — responses are fast, results look relevant, and the pipeline appears stable.</p><p>That’s exactly what happened when I first built my own RAG system using Python, OpenAI embeddings, and Pinecone vector database.</p><p>But things changed the moment I moved it into a real production setup.</p><p>I started noticing real <strong>RAG system production issues</strong> that never showed up in local testing:</p><ul><li>sometimes answers were slightly off</li><li>sometimes retrieval felt random</li><li>sometimes the system returned results that looked correct but were actually misleading</li></ul><p>At first, I assumed something was wrong with the model or OpenAI embeddings. So I kept experimenting — tuning prompts, adjusting embedding parameters, and modifying vector search settings in Pinecone.</p><p>Nothing really fixed it.</p><p>After weeks of debugging, I finally understood something important about <strong>why RAG system fails in production</strong>.</p><p>The issue wasn’t the model — it was the retrieval pipeline design.</p><p>Most of these problems were actually <strong>embedding based search issues</strong>, caused by chunking strategy, retrieval logic, and ranking inconsistencies.</p><p>Once I realized that, everything started making sense.</p><p>Here are the <strong>5 critical issues I faced while building a production RAG system in Python</strong>.</p><h3>1. Retrieval failures instead of model failures (real example)</h3><p>The first thing I realized was that the model was not the problem.</p><p>The LLM and OpenAI embeddings were working correctly — but the system was consistently passing the wrong context due to poor retrieval logic.</p><p>Most wrong answers were actually caused <strong>before the model even generated a response</strong>.</p><h3>Real production issue I faced</h3><p>I remember one specific case clearly.</p><p>I had a document stored in Pinecone about: <em>“How to optimize chunk size in a RAG pipeline”</em></p><p>A user query came in: <em>“What is the best way to improve RAG accuracy?”</em></p><p>Now, in my head, this should have retrieved the chunk about chunking and retrieval tuning.</p><p>But what actually happened was unexpected.</p><h3><em>What the system retrieved</em></h3><p>Instead of the correct chunk, the vector search returned a section about:</p><ul><li>“RAG system architecture overview”</li><li>general introduction to embeddings</li><li>unrelated context about LLM basics</li></ul><p>So the context passed to the model looked like this:</p><p>“RAG is a technique that combines retrieval and generation using embeddings…”</p><p>Then the model generated a <strong>generic answer</strong>, which looked correct — but was not useful or specific.</p><h3>What was actually happening</h3><p>At first, I thought:</p><ul><li>“Maybe OpenAI embeddings are not capturing intent properly”</li><li>“Maybe Pinecone similarity search is broken”</li></ul><p>But after logging the retrieval scores, I noticed something important:</p><ul><li>The correct chunk was actually present</li><li>It had a slightly lower similarity score</li><li>So it was being filtered out or ranked lower</li></ul><h3>The real root cause</h3><p>The issue was NOT the model.</p><p>It was:</p><ul><li>poor chunk boundaries (mixed concepts in one embedding)</li><li>incorrect Top-K selection</li><li>no score threshold filtering logic</li></ul><p>So the system was technically doing exactly what I told it to do — but the instructions were wrong.</p><h3>Key insight</h3><p>That’s when I understood something important:</p><p>The model only answers based on what you retrieve. If retrieval is wrong, even a perfect LLM will produce a wrong answer.</p><p>This is why many <strong>RAG system production issues</strong> are actually retrieval failures — not AI failures.</p><h3>2. Chunking issues broke retrieval quality</h3><p>I underestimated chunking at the beginning. I treated it as a simple preprocessing step and assumed it wouldn’t have a major impact on the system.</p><p>But once I moved to production, I started noticing inconsistent retrieval behavior that I couldn’t explain at first.</p><p>Some queries were returning overly broad answers, while others were missing key context even though the information clearly existed in the dataset.</p><p>After debugging, I traced it back to how the data was being split before embedding.</p><p>In my setup, large chunks were combining multiple concepts into a single embedding. This made retrieval less precise, because the vector represented mixed information instead of a clear idea. As a result, the system often returned vague but “technically related” answers.</p><p>On the other hand, when chunks were too small, the system lost important context. The retrieved results looked relevant individually, but they didn’t carry enough information for the model to generate a complete answer.</p><p>The most problematic case was inconsistent chunking. Some documents were split differently depending on structure, which led to unstable retrieval results for similar queries. The same question would sometimes return a good answer and sometimes miss the correct context entirely.</p><p>What made this harder to debug was that everything looked fine in testing. The issue only became visible when real user queries started interacting with different parts of the dataset.</p><p>This is when I realized chunking was not just a preprocessing step — it directly controlled retrieval quality in the entire RAG pipeline. Poor chunking was one of the main reasons behind the RAG system production issues I was facing.</p><h3>3. Vector database returned “similar but wrong” results</h3><p>Using Pinecone felt powerful in the beginning, especially because the retrieval was fast and the setup was straightforward. But once I started testing with real queries, I noticed a consistent problem that was hard to ignore.</p><p>The system was not returning random results. It was returning results that looked correct on the surface but were actually not aligned with the user’s intent.</p><p>This is when I understood an important limitation: the vector database does not understand meaning. It only performs similarity search based on embeddings.</p><p>In practice, this created embedding based search issues where:</p><ul><li>results were semantically close</li><li>but contextually incorrect</li><li>or partially relevant but misleading</li></ul><h3>What was happening in production</h3><p>A query would often match text that “felt related” in embedding space, even if it was not the correct answer to the question.</p><p>For example, a user asking about improving RAG accuracy could retrieve content about general RAG architecture, simply because both shared overlapping terms like “RAG”, “retrieval”, and “embeddings”.</p><p>The system treated similarity as correctness, which is not always true in real applications.</p><h3>Flow of what actually happened</h3><p>Query<br> → OpenAI embeddings<br> → Pinecone vector search<br> → Top similar vectors (not always correct context)<br> → LLM generates answer based on imperfect context<br> → Final response looks valid but is partially wrong</p><p>This pipeline made it clear that the vector database was not failing technically. It was behaving exactly as designed, but the design itself had limitations when applied to real production queries.</p><p>Once I saw this pattern repeatedly, I realized that retrieval quality depends not just on similarity scores, but on how well the data is structured and how contextually clean the embeddings are.</p><h3>4. Top-K retrieval created noise in production</h3><p>I initially treated Top-K as a simple parameter. I assumed increasing it would just give the model more context and improve answers.</p><p>But in production, I started seeing unstable behavior that didn’t make sense at first.</p><p>For some queries, the system worked perfectly. For others, it either missed important information or returned too much irrelevant context. The inconsistency became obvious once real users started interacting with the system.</p><h3>What I observed in real usage</h3><p>When Top-K was set too low, the system often missed critical context.</p><p>For example, a user asked:</p><p>“What are common RAG production issues?”</p><p>The correct answer existed across multiple chunks — one about retrieval problems and another about chunking issues. But with Top-K set to 2, only one of those chunks was retrieved. The model generated a partial answer, which looked correct but was incomplete.</p><p>When I increased Top-K to a higher value, a different problem appeared.</p><p>The system started pulling in loosely related chunks. For the same query, it began retrieving:</p><ul><li>general RAG introduction content</li><li>unrelated embedding explanations</li><li>partially relevant sections</li></ul><p>Now the model had too much mixed context, and the final answer became noisy and less precise.</p><h3>Where it became unpredictable</h3><p>The most confusing part was inconsistency.</p><p>For similar queries:</p><ul><li>one would return clean and accurate results</li><li>another would include irrelevant context</li></ul><p>Even though the intent was almost the same.</p><p>This made the system difficult to trust in production, because behavior was not stable.</p><h3>What was actually happening</h3><p>Top-K was directly controlling how much information the model received, but without any filtering or ranking refinement.</p><p>Low Top-K reduced recall.<br>High Top-K increased noise.</p><p>Without balancing this properly, the retrieval layer became unstable.</p><h3>Key insight</h3><p>I realized that Top-K is not just a tuning parameter — it directly affects how reliable your system is.</p><p>It needs to be combined with:</p><ul><li>proper chunking</li><li>similarity score filtering</li><li>consistent retrieval logic</li></ul><p>Otherwise, even a well-built RAG system can produce unpredictable results in production.</p><h3>5. Lack of filtering caused hallucination-like outputs</h3><p>One major issue I faced early on was passing all retrieved results directly to the LLM without any filtering.</p><p>At the time, I assumed more context would help the model generate better answers. In reality, it had the opposite effect.</p><p>The system was not hallucinating on its own — it was being given weak and partially relevant context, and then trying to make sense of it.</p><h3>What I saw in real usage</h3><p>For certain queries, the vector search returned a mix of:</p><ul><li>strong matches (clearly relevant)</li><li>weak matches (loosely related)</li></ul><p>Since I wasn’t filtering anything, both were sent to the model.</p><p>For example, a user asked:</p><p>“How to improve retrieval accuracy in a RAG system?”</p><p>The top results included:</p><ul><li>a good chunk about similarity score tuning</li><li>another chunk that only mentioned “accuracy” in a different context</li></ul><p>The second chunk wasn’t completely wrong, but it wasn’t useful either.</p><p>When both were passed together, the model combined them and produced an answer that sounded reasonable — but was slightly off and less precise.</p><h3>Why it looked like hallucination</h3><p>The output didn’t look obviously wrong. It looked confident and structured.</p><p>But when I compared it with the actual source content, I realized:</p><ul><li>important details were diluted</li><li>irrelevant context influenced the answer</li><li>the response was less accurate than it should have been</li></ul><p>This is what made it feel like a hallucination, even though the root cause was retrieval quality.</p><h3>What fixed it</h3><p>I introduced a simple similarity score threshold in the retrieval step.</p><p>Any result below a certain score was ignored instead of being passed to the model.</p><p>After adding this filter, I immediately noticed:</p><ul><li>cleaner context being sent to the LLM</li><li>fewer irrelevant influences in the response</li><li>more consistent and accurate answers</li></ul><h3>Key insight</h3><p>The model can only be as accurate as the context it receives.</p><p>If weak matches are included, the model will try to use them — even if they reduce answer quality.</p><p>Filtering low-confidence results turned out to be one of the simplest but most effective fixes in my production RAG pipeline.</p><h3>Final takeaway</h3><p>Building a production-ready RAG system taught me one clear lesson: the hardest part is not the model — it’s the retrieval design.</p><p>In my early iterations, I kept trying to improve results by tweaking prompts and experimenting with embeddings. But the real improvements only came when I focused on how data was structured, how chunks were retrieved, and what context was actually passed to the model.</p><p>If you’re building your own RAG pipeline, it’s worth spending time understanding how vector databases behave in real scenarios. The documentation from Pinecone helped me better understand similarity search and retrieval patterns at scale. I also found the embeddings guide from OpenAI useful for understanding how different embedding strategies impact search quality.</p><p>For a full breakdown of my implementation, including code examples and debugging insights, Full implementation, code, and debugging details:</p><p><a href="https://aicodewithharitha.com/rag-production-pitfalls-python-fixes/">https://aicodewithharitha.com/rag-production-pitfalls-python-fixes/</a></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84d475ae3c2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>