Your chatbot keeps inventing product details, getting pricing wrong, or confidently answering questions that aren't in your documents. Before upgrading to a bigger LLM, check what your vector database is actually returning.

I've seen developers spend hours changing system prompts, switching models, and increasing context windows because their RAG chatbot keeps giving incorrect answers.

The interesting part? Sometimes the model isn't the main problem at all.

Imagine your chatbot tells a customer that your basic subscription includes five team members when your actual plan only supports three.

You check the system prompt. Nothing looks wrong.

You switch to a more powerful model. The answer still isn't reliable.

At this point, I'd stop changing the model and inspect the retrieval pipeline.

A large share of RAG failures start before the LLM generates a single token. The system retrieves irrelevant information, misses the correct document, or passes incomplete context to the model.

The model then tries to produce an answer using whatever information it receives.

That's not always a generation problem. Often, it's a retrieval problem.

I wouldn't attach a universal 80% statistic to this claim without a defined benchmark, but retrieval is one of the first places I'd investigate when debugging a RAG application.

Here's the order I'd follow.

1. Inspect the Retrieved Chunks Before Changing Anything

This is the first thing I'd do when a RAG chatbot gives an incorrect answer.

Don't start with the system prompt. Don't switch to another model. Don't immediately increase your top-k value.

Open your retrieval logs and read the exact chunks returned by your vector database.

Let's say a customer asks:

"What is the refund policy for annual subscriptions?"

Your chatbot responds:

"We offer a 30-day money-back guarantee on all annual subscriptions."

But your company actually offers refunds only within seven days.

Before blaming the LLM, inspect the retrieved results.

You might discover that your vector database returned:

  • A general FAQ about subscription cancellations.
  • A footer containing the words "30-day support."
  • A navigation section mentioning annual plans.
  • An unrelated article discussing refund policies for another product.

The search found text with similar words, but it didn't find the actual refund policy.

That's a retrieval failure.

Log the actual search results

I usually want to see the following information for every retrieved chunk:

  • Rank in the search results.
  • Similarity score.
  • Source document.
  • Section or page heading.
  • Actual retrieved text.

A simple Python debugging function could look like this:

def debug_retrieval(query, results): print(f"\nQUERY: {query}") print("=" * 80) for rank, result in enumerate(results, start=1): print(f"\nRank: {rank}") print(f"Score: {result.score:.4f}") print(f"Source: {result.metadata.get('source')}") print(f"Section: {result.metadata.get('section')}") print(f"Chunk ID: {result.metadata.get('chunk_id')}") print("\nRetrieved content:") print(result.page_content[:1200]) print("-" * 80) 

Run this before passing the chunks to your LLM.

You may find that the correct document isn't being retrieved at all. Or perhaps it's present but ranked below several irrelevant chunks.

Those are two different problems, and they need different fixes.

My rule: Never debug the generated answer without first checking the retrieved context.

2. Fix Chunking and Clean Up Your Ingestion Pipeline

Suppose your website contains the correct refund policy, and your vector database has indexed it.

But the chatbot still can't retrieve the complete answer.

Take a look at how the document was divided into chunks.

A common mistake is using fixed character splitting without considering the structure of the content.

For example, imagine this paragraph:

"Annual subscriptions can be refunded within seven days of purchase, provided the customer has not exceeded the usage limit..."

A naive character splitter might produce:

Chunk 1:

"Annual subscriptions can be refunded within seven days of purchase, provided the customer has not"

Chunk 2:

"exceeded the usage limit..."

Now the information is separated from part of its condition.

The problem becomes worse with pricing tables, product specifications, FAQs, and technical documentation.

A model might retrieve the first chunk and confidently explain the refund period without retrieving the condition.

Use structure-aware chunking

Instead of splitting everything after an arbitrary number of characters, consider how the content is organized.

For Markdown documents, use headings as natural boundaries.

For website content, preserve related paragraphs and sections.

For tables, keep the column headers with their corresponding rows.

Practical improvements include:

  • Markdown-aware or semantic splitting.
  • Sentence and paragraph boundary preservation.
  • Small chunk overlap to retain context across boundaries.
  • Metadata containing the document title, URL, and section heading.
  • Separate handling for tables, code blocks, and FAQs.

Overlap helps when useful information sits near a chunk boundary. But don't increase it blindly. Too much overlap creates duplicate content and can fill retrieval results with nearly identical chunks.

Don't embed dirty HTML

This is another issue I frequently recommend checking.

When you crawl website pages, you don't necessarily get only the main article content.

You might also extract:

  • Navigation menus.
  • Footer links.
  • Cookie notices.
  • Sidebar content.
  • Repeated headers.
  • Social sharing buttons.
  • Unrelated promotional text.

Imagine indexing 100 pages where every page contains the same footer.

Your vector database may end up with hundreds of similar chunks containing repeated navigation and footer information.

That noise makes retrieval less useful.

Before generating embeddings, extract the main content and remove unnecessary HTML boilerplate.

Keep useful information such as page titles, headings, product names, and section metadata.

The goal isn't to store as much website text as possible. It's to store information that can actually answer customer questions.

Microsoft's RAG architecture guidance also discusses format-aware chunking, overlap, and semantic coherence as factors that affect retrieval quality.

3. Switch to Hybrid Search and Add Reranking

Your ingestion pipeline now looks better, but another problem remains.

Pure vector search isn't always reliable for exact information.

Imagine a customer asking:

"Does product XR-450 support firmware version 2.8.1?"

Or:

"What does error code AUTH-403 mean?"

These questions contain exact identifiers.

An embedding model may understand the general meaning of the question but fail to rank the exact matching document highly enough.

This happens because semantic similarity and exact keyword matching solve different problems.

Combine BM25 with vector search

This is where hybrid search becomes useful.

You combine two retrieval methods:

Vector search

Uses embeddings to find content with similar meaning.

For example:

"How do I get my money back?"

It might retrieve content titled "Refund and Cancellation Policy."

Keyword search (BM25)

Finds documents containing important matching terms.

For example:

"AUTH-403"

It can locate the exact error code even when semantic similarity isn't particularly strong.

Combining both gives your retrieval pipeline a better chance of finding relevant information.

A practical flow looks like this:

Customer Question | v Normalize Query | +------------------+ | | v v Vector Search BM25 Search | | +--------+---------+ | v Merge Candidate Results (Reciprocal Rank Fusion) | v Cross-Encoder Reranker | v Select Best Chunks | v LLM | v Answer 

Why add a cross-encoder reranker?

Even after hybrid search, your top results might not be in the best order.

A cross-encoder helps solve this.

Unlike a typical bi-encoder search, which independently converts the query and documents into vectors, a cross-encoder examines the query and candidate document together.

It then estimates how relevant that particular document is to the question.

For example, your initial retrieval might return 30 candidate chunks.

A reranker can evaluate those candidates and move the most relevant ones to the top.

You can then pass perhaps the best four or five chunks to the LLM.

This adds some latency and inference cost, so benchmark it against your actual workload rather than enabling it without testing.

Microsoft's retrieval guidance describes this common pattern: retrieve broadly, merge results, rerank candidates, and pass the strongest results to generation.

The improvement can be significant when your document collection contains similar product pages, technical specifications, or large amounts of overlapping content.

4. Give Your Chatbot Permission to Say "I Don't Know"

Here's another mistake that causes problems.

Developers configure retrieval, connect their documents, and then instruct the chatbot to answer every customer question.

That's a bad combination.

Sometimes the correct answer simply isn't available in your knowledge base.

Your chatbot shouldn't invent one.

For example, a customer asks:

"Do you offer a 40% discount for enterprise customers?"

Your documents contain no information about that discount.

A chatbot without proper guardrails might generate a plausible response based on general pricing patterns.

That's exactly what you want to prevent.

Add a strict grounding instruction

I'd start with a system prompt similar to this:

SYSTEM_PROMPT = """ You are a business support assistant. Answer questions using only the information provided in the retrieved documents. Rules: 1. Do not invent prices, policies, or features. 2. Do not use general knowledge as a replacement for missing business information. 3. If the provided documents do not contain enough evidence, respond with: "I don't have enough information in the provided docs to answer that accurately." 4. Do not make assumptions about missing details. 5. Keep answers clear and directly related to the customer's question. """ 

This gives the model clear boundaries.

However, a system prompt alone isn't enough.

You should also implement a retrieval-level confidence check.

For example, if your vector search returns no relevant results, don't send an empty or unrelated context to the model and hope for the best.

You can reject weak retrieval results before generation:

MIN_RETRIEVAL_SCORE = 0.72 # Example only. # Calibrate using evaluation data. if not results or results[0].score < MIN_RETRIEVAL_SCORE: return ( "I don't have enough information in the " "provided docs to answer that accurately." ) 

Don't copy 0.72 into every project.

Similarity scores depend on the embedding model, vector database, distance metric, and document collection. Build a small evaluation dataset with questions whose answers you already know, then determine an appropriate threshold.

Also, don't confuse a cross-encoder's relevance score with a vector similarity score. They're different scoring systems.

For production systems, I'd test the threshold against both answerable and unanswerable questions.

A good chatbot should know when the available evidence isn't sufficient.

5. When Should You Actually Change the AI Model?

After checking retrieval, cleaning ingestion, improving search, and adding proper grounding instructions, you may still have incorrect answers.

Now it's reasonable to investigate the generation layer.

Check whether:

  • The model ignores information in the retrieved context.
  • The prompt contains conflicting instructions.
  • The context is too long or contains contradictory documents.
  • The answer requires reasoning across several retrieved sections.
  • The model struggles with your language or technical terminology.

At this stage, compare models using the same questions, retrieved chunks, and system prompt.

Don't compare two different models with two different retrieval pipelines and assume the difference comes from the model.

Keep the experiment controlled.

And measure more than whether an answer sounds convincing. Check factual accuracy, evidence support, and whether the chatbot correctly abstains when information is missing.

A bigger model can sometimes improve reasoning and instruction following. But it cannot reliably recover information that your retrieval pipeline never supplied.

For businesses looking to implement this kind of system on their websites, custom AI chatbot development by TechHowdy offers an approach that combines RAG, website content, PDFs, and business knowledge to provide more relevant customer responses. Having the right retrieval setup, fallback rules, and testing process is just as important as choosing the AI model.

My RAG Debugging Order of Operations

When my chatbot starts making up product details, pricing tiers, or business policies, this is the sequence I'd follow:

  1. Inspect Chunks: Read the exact top-k results, scores, metadata, and source text. Find out whether the correct information was retrieved.
  2. Clean Ingestion: Remove HTML boilerplate, fix broken content, improve chunk boundaries, and preserve useful document structure.
  3. Improve Search: Combine BM25 with vector search, merge results, and introduce reranking where it improves relevance.
  4. Tune Model and Prompt: Add abstention rules, test grounding instructions, and only consider changing models after retrieval has been validated.

The next time your RAG chatbot gives a completely wrong answer, resist the temptation to upgrade your LLM immediately.

Check what you gave it first.

Sometimes the model isn't making things up because it's too small or not intelligent enough.

It's making things up because your retrieval pipeline never found the answer in the first place.

Fix what goes into the model before paying more for what comes out of it.