Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why Your RAG Chatbot Gives Wrong Answers (and How to Fix It)

You built a chatbot on your own documents, and it still answers with confident nonsense. Customers get wrong prices, invented policies or a polite "I don't know" when the answer is on your website. This is the most common complaint I hear about RAG chatbot wrong answers , and the good news is that most of the time the model is not the problem. The retrieval and the rules around it are. I build…

You have built a chatbot using your own company’s documents, but sometimes it gives wrong or nonsensical answers. Customers often receive incorrect prices, invented policies, or a polite “I don’t know” when the correct information is available on your website. This is a common complaint about Retrieval-Augmented Generation (RAG) chatbot mistakes, and the good news is that the problem is usually not with the model itself but with the retrieval process and the rules surrounding it.

A RAG chatbot works by searching your content for the most relevant passages related to the user's question, passing those passages along with the question to the language model, and then asking the model to generate an answer using that material. A wrong answer can stem from three different sources: the relevant passage was not found, the retrieved passage was poor or incomplete, or the model ignored or went beyond the provided material.

To fix these issues, first identify which layer is failing. Take 20 to 30 real questions that the bot answered incorrectly and log what was retrieved for each one. If the right answer is not in the retrieved passages, the problem lies with retrieval. If the answer is present in the passages but the bot gives a wrong answer, the issue is with the prompt or generation. If the right answer isn't in your content at all, the problem is with the content itself.

To improve retrieval, split the documents into chunks based on meaning rather than character count. This means splitting on headings, paragraphs, and list boundaries, keeping a little overlap, and storing the page title and section name with each chunk for context. Clean the source content by stripping out navigation menus, cookie banners, repeated footers, and duplicated pages that can pollute search results. Combine keyword and semantic search by using a hybrid approach that merges both techniques.

Retrieving more candidates and then reranking them often improves answer quality without any other changes. When users ask follow-up questions like “what about the cheaper one?”, rewrite those into standalone questions using the conversation so far. Fixing prompt and generation problems involves instructing the model to stick to the supplied passages and to disclose when it cannot provide an answer.

Require citations so users can verify the answers, and use a “no good match” threshold to avoid forcing an answer when the best retrieved passage is only weakly related. Set topic limits and define a persona for the bot to ensure it discusses appropriate topics and speaks in the desired manner.

If the answer isn't in your content, no settings can generate it. Use the questions the bot can't answer as a to-do list for your knowledge base: add pages for frequently asked questions, make pricing, policies, and hours explicit and dated, remove contradictory versions of the same information, and put answers near the questions they belong to.

To ensure the bot remains trustworthy after launch, build a small evaluation set with test questions and their expected answers or source pages. Run this set after every change to chunking, search, or prompts, and compare the results. Additionally, log each question, the retrieved passages, the answer, and any user feedback, reviewing a sample weekly to identify content gaps and retrieval failures.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Concurrent users vs requests per second: the load test mistake that makes results look too good

A requirement lands on your desk: "The system must support 10,000 concurrent users." It sounds precise. It isn't. Depending on what those users do, it means anything from ~670 to ~12,000 requests per…

  • Confusing concurrent users with requests per second is a common load testing mistake.
  • Closed model load tests can make systems appear stable when they're actually struggling.
  • Open model load tests, using real user data, provide a more accurate assessment of system capacity.

Your Drupal node page says 403. Your RSS feed doesn't care

I ran into a bug where private content leaked even though a node access hook was already in place. Opening the node directly returned 403, exactly as intended.

  • Private content leaked through RSS feed
  • Node access hook ineffective
  • Drupal's access systems not synchronized

More from Thursday 22 October →