<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sofi Technologies</title>
    <description>The latest articles on DEV Community by Sofi Technologies (@sofi_technies).</description>
    <link>https://dev.to/sofi_technies</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272886%2F7cf41d70-e852-46bb-bdd3-2aff9217212a.png</url>
      <title>DEV Community: Sofi Technologies</title>
      <link>https://dev.to/sofi_technies</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sofi_technies"/>
    <language>en</language>
    <item>
      <title>Why your RAG chatbot gives wrong answers (and 4 fixes that actually work)</title>
      <dc:creator>Sofi Technologies</dc:creator>
      <pubDate>Sun, 29 Nov 2026 20:02:10 +0000</pubDate>
      <link>https://dev.to/sofi_technies/why-your-rag-chatbot-gives-wrong-answers-and-4-fixes-that-actually-work-4cp9</link>
      <guid>https://dev.to/sofi_technies/why-your-rag-chatbot-gives-wrong-answers-and-4-fixes-that-actually-work-4cp9</guid>
      <description>&lt;p&gt;Someone asks your support bot: &lt;em&gt;"How much is shipping on a $40 order?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your shipping page says: &lt;strong&gt;$9.95, free over $50.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your bot says: &lt;em&gt;"Shipping costs vary depending on the product. Please contact us for details."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Nobody touched the model. The page is in the knowledge base. So why is the bot wrong?&lt;/p&gt;

&lt;p&gt;From building and testing these bots, I've found that almost every wrong answer comes from one of &lt;strong&gt;four places&lt;/strong&gt;. And swapping to a bigger model fixes none of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Chunking: the bot only sees half a fact
&lt;/h2&gt;

&lt;p&gt;RAG systems split your documents into chunks before searching them. A common default is "every 500 characters".&lt;/p&gt;

&lt;p&gt;Now picture your shipping table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Order total | Shipping |
| Under $50   | $9.95    |
| $50+        | Free     |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A fixed-size splitter can cut that table down the middle. The bot gets one chunk with "Under $50" and another with "$9.95" and "Free", without the headers. It can't put them back together, so it hedges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split by &lt;strong&gt;document structure&lt;/strong&gt; (headings, sections), not character count.&lt;/li&gt;
&lt;li&gt;Keep &lt;strong&gt;tables and lists whole&lt;/strong&gt;, even if the chunk gets bigger.&lt;/li&gt;
&lt;li&gt;Add a small &lt;strong&gt;overlap&lt;/strong&gt; (one or two sentences) between chunks.&lt;/li&gt;
&lt;li&gt;Put the &lt;strong&gt;page title and section heading&lt;/strong&gt; at the top of every chunk, so "Free" always arrives with "Shipping policy → Orders over $50".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Retrieval: the bot finds the wrong page
&lt;/h2&gt;

&lt;p&gt;Pure vector (embedding) search is good at meaning and bad at exact terms. Ask about "XR-200 battery warranty" and it may happily return a general blog post about batteries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;hybrid search&lt;/strong&gt;: keyword (BM25) plus vector, merged together. Keywords catch product names, SKUs and numbers. Vectors catch paraphrases.&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;re-ranker&lt;/strong&gt; on the top 20 results before you take the top 3–5. This is often the single biggest accuracy jump for the cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log what was retrieved&lt;/strong&gt; for every answer. You can't fix retrieval you can't see.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# pseudo-code: hybrid retrieval + rerank&lt;/span&gt;
&lt;span class="n"&gt;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bm25&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;vectors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dedupe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;top&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reranker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Grounding: nothing stops the bot from making things up
&lt;/h2&gt;

&lt;p&gt;If your prompt is &lt;em&gt;"You are a helpful assistant. Use the context below."&lt;/em&gt;, the model treats the context as a suggestion. When the context is thin, it fills the gap with something that sounds plausible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tell it plainly: &lt;em&gt;answer **only&lt;/em&gt;* from the context; if the answer isn't there, say you don't know and offer a human.*&lt;/li&gt;
&lt;li&gt;Ask it to &lt;strong&gt;quote or cite&lt;/strong&gt; the chunk it used. Answers without a source are a red flag you can catch in code.&lt;/li&gt;
&lt;li&gt;For prices, dates and policy numbers, consider &lt;strong&gt;checking the numbers in the answer&lt;/strong&gt; against the retrieved text before showing it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"I don't know, let me connect you with the team" costs you nothing. A wrong refund window can cost you a chargeback.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Testing: the bot was only tested on demo questions
&lt;/h2&gt;

&lt;p&gt;Most bots get tested with questions the builder already knows the answer to: &lt;em&gt;"What are your opening hours?"&lt;/em&gt; They pass, and go live.&lt;/p&gt;

&lt;p&gt;Real customers ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Can I return it if I opened the box?"&lt;/li&gt;
&lt;li&gt;"Do you ship to Qatar?"&lt;/li&gt;
&lt;li&gt;"Is the 2-year warranty on the battery too?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; build a small &lt;strong&gt;test set&lt;/strong&gt; of 20–50 real questions (from support emails, chats and reviews), each with the correct answer from your own pages. Run it after &lt;strong&gt;every&lt;/strong&gt; change: new docs, a new prompt, a new model. Track the score over time.&lt;/p&gt;

&lt;p&gt;This turns "I think it's better" into "it went from 31 of 50 to 44 of 50".&lt;/p&gt;

&lt;h2&gt;
  
  
  How to tell which problem you have
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Answer is about the wrong topic&lt;/td&gt;
&lt;td&gt;Retrieval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer is partly right, but cut off or mixed up&lt;/td&gt;
&lt;td&gt;Chunking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer has numbers or facts that aren't in your docs&lt;/td&gt;
&lt;td&gt;Grounding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bot dodges ("please contact us") when the answer exists&lt;/td&gt;
&lt;td&gt;Retrieval or testing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  A quick way to check your own bot
&lt;/h2&gt;

&lt;p&gt;I built a small free tool for exactly this: &lt;strong&gt;&lt;a href="https://chatbot-score.chatbot-score.workers.dev" rel="noopener noreferrer"&gt;ChatbotScore&lt;/a&gt;&lt;/strong&gt;. Paste a few questions, what your bot answered, and the correct info from your site. It scores each answer, flags made-up or missing facts, and points to the likely cause above. No sign-up.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm a developer at Sofi Technologies. I build RAG assistants that answer from a company's own docs and data, and fix ones that don't. If you'd like help with yours, &lt;a href="https://www.fiverr.com/sofi_technies/build-a-rag-ai-agent-with-langgraph-crewai-or-mcp-that-answers-from-your-data" rel="noopener noreferrer"&gt;here's how to work with me&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>chatbot</category>
      <category>python</category>
    </item>
  </channel>
</rss>
