Why your RAG chatbot gives wrong answers (and 4 fixes that actually work)

2026-11-30来源 dev.toEnglish

Someone asks your support bot: "How much is shipping on a $40 order?"

Your shipping page says: $9.95, free over $50.

Your bot says: "Shipping costs vary depending on the product. Please contact us for details."

Nobody touched the model. The page is in the knowledge base. So why is the bot wrong?

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

1. Chunking: the bot only sees half a fact

RAG systems split your documents into chunks before searching them. A common default is "every 500 characters".

Now picture your shipping table:

| Order total | Shipping | | Under $50 | $9.95 | | $50+ | Free | 

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.

Fix:

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

2. Retrieval: the bot finds the wrong page

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.

Fix:

  • Use hybrid search: keyword (BM25) plus vector, merged together. Keywords catch product names, SKUs and numbers. Vectors catch paraphrases.
  • Add a re-ranker on the top 20 results before you take the top 3–5. This is often the single biggest accuracy jump for the cost.
  • Log what was retrieved for every answer. You can't fix retrieval you can't see.
# pseudo-code: hybrid retrieval + rerank candidates = bm25.search(q, k=20) + vectors.search(q, k=20) candidates = dedupe(candidates) top = reranker.rank(q, candidates)[:5] answer = llm(prompt(q, top)) log(q, [c.id for c in top], answer) 

3. Grounding: nothing stops the bot from making things up

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

Fix:

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

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

4. Testing: the bot was only tested on demo questions

Most bots get tested with questions the builder already knows the answer to: "What are your opening hours?" They pass, and go live.

Real customers ask:

  • "Can I return it if I opened the box?"
  • "Do you ship to Qatar?"
  • "Is the 2-year warranty on the battery too?"

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

This turns "I think it's better" into "it went from 31 of 50 to 44 of 50".

How to tell which problem you have

Symptom Likely cause
Answer is about the wrong topic Retrieval
Answer is partly right, but cut off or mixed up Chunking
Answer has numbers or facts that aren't in your docs Grounding
Bot dodges ("please contact us") when the answer exists Retrieval or testing

A quick way to check your own bot

I built a small free tool for exactly this: ChatbotScore. 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.

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, here's how to work with me.

原文:https://www.a8q9.cn/en/article/why-your-rag-chatbot-gives-wrong-answers-and-4-fixes-that-actually-work-be4774.html

相关文章