Ask the Kitebox help center
Kitebox is a made-up file-sharing product with 11 help articles. The bot answers only from them, cites the excerpt behind every sentence, and says so when the answer isn’t there. Switch to Side by side to see the same question go through a typical first-version pipeline.
Two pipelines, same documents, same model
The naive pipeline is wired the way most first versions are. The fixed one changes the six places where RAG bots usually go wrong. Every difference below is something the Eval tab measures.
Naive
- ChunkingRaw file cut every 1,000 characters. Front matter lands in chunks; table rows get split from their header row.
- RetrievalDense vectors only, top 4. Error codes like KB-412 and KB-204 embed almost identically.
- Follow-upsRetrieves on the latest message only, so “And Business?” searches for “Business”.
- RelevanceNo floor. Something is always retrieved, so something is always answered.
- Prompt“Use the context to answer.” Nothing about what to do when the context is silent.
- ChecksNone. Whatever the model writes is shown.
Fixed
- ChunkingSplit on headings, each chunk starts with its breadcrumb (“Plans and pricing › Price per user”), table rows rewritten as self-describing lines.
- RetrievalHybrid: BM25 + dense, fused with reciprocal rank fusion, plus an exact-match boost for error codes. Top 5.
- Follow-upsThe model rewrites the message into a standalone question first (“How much is Business per user on annual billing?”).
- RelevanceA gate before the model: an error code no article mentions, or nothing above the similarity floor, returns “not found” without an LLM call.
- PromptCite-or-refuse: every sentence carries [n]; contradict false premises; prefer the newer article when two disagree.
- ChecksEvery citation must point at a retrieved excerpt and every number must appear in a cited one. One retry with the failure explained, then refuse rather than show an unverified answer.
Stack
- LangChain retrievers (
BaseRetriever), LCEL chains,MarkdownHeaderTextSplitter,ChatOpenAIagainst any OpenAI-compatible endpoint (OpenAI, Gemini, Groq, Claude) - Embeddings bge-small-en-v1.5 as int8 ONNX, run on CPU inside the function. The same model embeds the documents at build time and the question at query time.
- Index In-memory vectors + BM25, built at deploy. The retriever interface is the same one a Pinecone, pgvector, Chroma or Qdrant retriever implements, so swapping stores doesn’t touch the chain.
- API FastAPI on Vercel:
POST /api/chat,/api/eval,/api/meta, docs at /api/docs. Per-visitor rate limit, input length caps. - Tests pytest for the chunker, code matching, the gate and the grounding checks, plus the 33-question eval.