Topic 2 of 5 · 5 min read
Saying no answer was found
Goal: Set a rule for when the system must answer not found and rewrite a confident unsupported answer into an honest one.
A RAG system must be able to say "I could not find that in the documents", and the decision should be made by a rule you control, not left to the model's mood. Without a not-found path, every question gets an answer, and some of those answers come from nowhere.
Check yourself · 1 of 3
A user asks about a topic the knowledge base never covers. The vector search still returns five chunks. Why?
Why it matters
Vector search always returns something. Ask an HR bot about parental leave in a company whose handbook never mentions it, and it still returns the five nearest chunks, perhaps about annual leave. The model reads them and writes a smooth answer that mixes in what it knows from the internet. The user hears confidence and cannot see that the handbook had nothing.
How to do it
- Check retrieval before generating. If no chunk passes a relevance threshold, skip the model and return the not-found message. Pick the threshold from labelled questions: collect some that have answers and some that do not, and look at where the scores separate.
- Remember scores are relative to your setup. A similarity of 0.62 means different things for different embedding models. Tune it on your data and re-tune it when the model changes.
- Give the model a way out. In the prompt, define the outcome: "If the sources do not contain the answer, say so and stop." Make it a field in structured output, such as
status: "not_found", so code can route it. - Separate "nothing found" from "partly found". If the sources answer half the question, answer that half, say what is missing and do not fill the gap.
- Write the refusal to help. Say what was searched, what was not found and what the user can do next: rephrase, name a document, or contact a person.
Before and after
User asks: "Does the plan cover dental implants?" The retrieved chunks are about routine dental cleanings.
Weak:
Yes, the plan covers dental implants at 50% after the deductible.
Nothing retrieved says this. Better:
I could not find dental implants in the plan documents I searched (Benefits Guide 2026, Dental Schedule). They list cleanings and fillings only. Please check with Member Services before booking.
What goes wrong
- Threshold too low. Weak matches pass, and the model builds an answer on tangential text.
- Threshold too high. Real answers are refused, and users stop trusting or using the tool. Track the refusal rate and review a sample of refusals.
- Refusal without a reason. "I don't know" gives the user nowhere to go.
- Hidden fallback to training data. A prompt that says "otherwise use your own knowledge" turns every gap into an unverifiable answer. Offer general knowledge only when it is labelled as such.
Examples
A gate before the model
hits = search(question, k=8)
strong = [h for h in hits if h.score >= 0.55]
if not strong:
return {"status": "not_found", "searched": [h.doc_title for h in hits[:3]]}
answer = generate(question, strong)
The 0.55 value is an example. Choose yours from questions you know have no answer in the corpus.
Partial coverage
Question: "What is the notice period and the severance for contractors?" The sources give a 30-day notice period and say nothing about severance. A good answer states the 30 days with its citation, then says: "The documents I searched do not mention severance for contractors."
Key points
- Retrieval always returns something, so a relevance rule must decide when the answer is not found.
- Tune the threshold on labelled questions, including ones with no answer, and re-tune it when the embedding model changes.
- Make not_found an explicit output status so code can route it, not a mood in the prose.
- When sources answer only part of a question, answer that part and name what is missing.
- A good refusal says what was searched and what the user can do next.
Common mistakes
- Always sending the top-k chunks to the model, even when none is relevant.
- Letting the prompt say "use your own knowledge if the documents do not help" without labelling it.
- Setting a threshold once from a few examples and never measuring refusals again.
- Refusing with a bare "I don't know" and no suggestion for what to try.
Check yourself · 2 of 3
Your bot refuses 40 percent of questions that do have answers in the documents. Which change is most likely to help?
Check yourself · 3 of 3
The sources state a 30-day notice period and say nothing about severance. The user asked about both. Which answer is best?
Practice items, not counted towards your mastery.
Start here
- Citations (Claude API docs) (opens in a new tab)DocsFree
How to pass documents with citations enabled and read back cited text with character, page or block locations.
- Enabling Large Language Models to Generate Text with Citations (ALCE) (opens in a new tab)PaperFree
A benchmark that scores answers on fluency, correctness and citation quality, and shows where models still fail.
- Lost in the Middle: How Language Models Use Long Contexts (opens in a new tab)PaperFree
Shows models use evidence at the start and end of a long context better than evidence in the middle.
More for this topic
- Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection (opens in a new tab)PaperFree
A method where the model decides when to retrieve and critiques whether its output is supported by the passages.
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (opens in a new tab)PaperFree
The original RAG paper: why pairing a generator with retrieved passages helps and what provenance it offers.