An AI chatbot that never hallucinates
The #1 reason businesses hesitate to put an AI chatbot in front of customers is confident hallucination: invented prices, nonexistent policies, made-up deadlines. Here is why vanilla LLMs do that and how to build a grounded bot that answers strictly from your documents, cites the exact source section, and honestly says "I don't know" when an answer is missing.
Why a plain LLM makes things up
A language model does not store your company policies or live catalog — it predicts plausible next tokens. Ask it about your refund policy or pricing tier without grounding, and it will generate a convincing-sounding guess. That is fine for brainstorming, but disastrous in customer support where you are accountable for every promised number.
The fix: RAG — retrieve first, answer second
Retrieval-augmented generation (RAG) flips the flow. Instead of answering from memory, on every question the bot first retrieves relevant passages from your knowledge base, and only then formulates an answer strictly from those passages. Three pillars make this reliable:
- Search over your actual docs. Your SOPs, FAQs, catalog, and guides. Update a document and the bot's answer updates immediately — no model fine-tuning needed.
- Strict grounding + source citation. The model receives only retrieved chunks with a hard constraint to cite the document and section so anyone can verify the answer in one click.
- An honest "I don't know" gate. If no chunk passes the relevance and coverage thresholds, the LLM is not even called — the bot immediately says the answer is not in the knowledge base.
Documents
Your SOPs, FAQs, PDFs, docs, and ticket history.
Index
Chunked and indexed; updates as your docs change.
Retrieval
Finds top chunks; if below threshold → honest refusal.
Answer + source
LLM answers strictly from retrieved passages.
groundedWhy skipping the LLM on low relevance is the real guardrail
Most chatbot demos hide refusals by letting the LLM improvise when search comes up empty. A production RAG engine enforces a hard retrieval gate before calling the model: if relevance or query term coverage is below threshold, it returns a deterministic fallback and offers to forward the question to a human.
"What is your office address in Paris?" → "There is no answer to this in our knowledge base. The bot answers strictly from uploaded documents and does not guess."
→ Want a grounded chatbot over your own docs? Try the live bot and inspect open code on the case page →
Lexical search vs. semantic embeddings
Lexical search (BM25) is fast, deterministic, and great for exact terminology, SKU codes, and transparent scoring. Its ceiling is paraphrasing: when a customer uses different words than your document. Semantic search (embeddings + pgvector/Qdrant) matches meaning across paraphrases. In production we combine both (hybrid retrieval).
Which LLM generates the answer
Because knowledge lives in the index rather than model weights, the LLM is swappable via config:
- Cloud APIs — Claude (Anthropic), GPT (OpenAI), Gemini (Google): highest answer quality.
- Self-hosted / on-prem — Llama, Qwen, DeepSeek, Mistral on your own server (vLLM / Ollama): data never leaves your perimeter and zero per-token API bills.
Common pitfalls we avoid
- Oversized chunks. Dumping whole documents into context dilutes precision; clean heading-based chunking keeps citations sharp.
- No off-topic gate. Matching a single common word without coverage thresholds leads to irrelevant answers.
- No log of unanswered questions. Unanswered queries are your prioritized roadmap for what to add to the knowledge base next.
Try the live RAG bot right now
Open the RAG knowledge-base chatbot case to test the live bot in your browser and inspect the open-source engine, or check out the turnkey Telegram bot case.