TL;DR / Quick Summary: Every ai answer produced by a modern system is the output of a pipeline: embed the question, retrieve semantically similar passages, assemble a bounded context, and generate strictly from it. When any step is skipped or fails silently, the model fills the gap with fluent invention. This is the technical breakdown of how answer engines work, where they break, and what to measure to keep them honest.
Search engines give you links; ai answer engines give you the answer. That shift is small in the interface and large in the engineering, because the moment a system commits to a single response, it also owns being wrong.
The 4-Step Pipeline Behind Every AI Answer
Behind the chat box sits an architecture whose job is to turn unstructured documents into a bounded, checkable context for the model.
- 1Embed the questionThe query becomes a high-dimensional vector using the same model that embedded your documents.
- 2Retrieve by meaningThe vector store returns the closest passages by cosine distance, filtered to the right tenant and collection.
- 3Build the contextTop-ranked passages are assembled into a bounded prompt region, labelled as source material.
- 4Generate under constraintThe model answers from that context only, and declines when the context does not contain the answer.
// A minimal RAG query pipeline
const queryVector = await embeddings.create({ input: userQuestion });
const relevantDocs = await vectorDb.query({
vector: queryVector,
topK: 5,
similarityThreshold: 0.82,
});
if (relevantDocs.length === 0) {
return "I could not find this in the documentation.";
}
const response = await llm.generate({
systemPrompt: [
'Answer ONLY using the provided facts.',
'Cite the source of each claim.',
"If the facts are insufficient, say you cannot find the information.",
].join('\n'),
context: relevantDocs.map((d) => d.text).join('\n\n'),
userQuery: userQuestion,
});The threshold and the empty-result branch are the two lines that separate a grounded answer engine from a confident guesser.
Why AI Answers Hallucinate
“Hallucination” bundles together several distinct failures with different fixes. Separating them is the first step to fixing any of them.
| Failure | What it looks like | Actual cause | Fix |
|---|---|---|---|
| Empty-retrieval invention | Fluent answer about a feature you do not have | No relevant passages, generation ran anyway | Similarity floor plus a refusal path |
| Stale grounding | Correct citation, outdated number | Index behind the published source | Event-driven re-indexing |
| Chunk-boundary error | Half a procedure, presented as the whole | Fixed-size splitting cut through a section | Heading-aware chunking with overlap |
| Conflation | Two plans' limits merged into one answer | Near-identical chunks, no disambiguation | Heading path in the chunk, reranking |
| Citation drift | Right answer, wrong link | Citations attached after generation | Bind citations to the passages actually used |
The pattern is worth stating plainly: most hallucinations in a retrieval system are retrieval problems. Rewriting the system prompt is the cheapest thing to try and the least likely to help.
What Grounding Does and Does Not Fix
- It fixes invented product facts, wrong pricing, imaginary API parameters, and answers about competitors you never documented.
- It does not fix a corpus that is wrong, contradictory or out of date — grounding faithfully reproduces bad documentation.
- It does not fix ambiguity. If two plans both have a “limit” section, retrieval needs help distinguishing them.
- It does not fix questions with no documented answer. What it does is make refusing them possible.
Retrieval Quality Is the Whole Ballgame
Four adjustments account for most of the difference between an answer engine people trust and one they stop using.
- Chunk on structure. Split along headings so a retrieved passage is a complete thought, and prefix the heading path so the embedding carries context.
- Combine keyword and vector search. Pure semantic search is weak on exact identifiers — error codes, SKUs, flag names — where lexical matching is exactly right.
- Rerank the shortlist. Retrieve twenty candidates cheaply, then use a cross-encoder to pick the best five. This is usually the single biggest quality gain per unit of effort.
- Set a floor and honour it. Below the similarity threshold, refuse. An assistant that says “I cannot find that” keeps its credibility for the answers it does give.
Citations Are the Part Users Actually Check
A citation is not decoration; it is the mechanism by which a reader can verify you without asking a human. It has to point at the passage that produced the claim, not at the document that happened to rank first.
What is the rate limit on the search endpoint?
600 requests per minute per API key on Scale, and 60 on Starter. Bursts above the limit return 429 with a Retry-After header.
And on the legacy v1 endpoint?
I could not find a documented rate limit for the v1 endpoint. I can route this to a human who can confirm it.
Answer Engines vs Search Engines
Search results
- Returns ten candidate documents
- The reader performs the synthesis
- Being wrong is diffuse - a bad result among good ones
- No opinion about which answer is correct
Answer engine
- Returns one composed answer
- The system performs the synthesis
- Being wrong is concentrated and quotable
- Must be able to decline when the corpus is silent
How to Evaluate an Answer Engine
Accuracy on a set of easy questions tells you nothing useful. Four measures do.
- Groundedness — the share of claims traceable to a retrieved passage. This is the headline number.
- Citation precision — how often the cited passage actually contains the claim it is attached to.
- Refusal correctness — how often the system declines exactly when the answer is genuinely absent, scored in both directions.
- Retrieval recall@k — whether the passage that could have answered the question was in the top k at all. When this is low, nothing downstream can save you.
An answer engine you can put in front of customers
- Heading-aware chunking with overlap and a heading-path prefix
- Hybrid keyword plus vector retrieval
- Cross-encoder reranking over a wider candidate set
- Similarity floor with an explicit, tested refusal path
- Citations bound to the passages actually used
- Tenant and collection filters enforced server-side
- Event-driven re-indexing so the corpus is never stale
- Evaluation set covering answerable, unanswerable and ambiguous questions
- Groundedness and citation precision tracked over time
For the ingestion side of this pipeline, see how CustomerGPT indexes your documentation; for the adversarial side, securing AI support guardrails.
Build Your Own Factual AI Answer Engine
Integrate CustomerGPT into your application to deliver instant, grounded, source-cited AI answers backed by your own documentation.
