Skip to content
mentoor

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?

Choose one answer

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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?

Choose one answer

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?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic