StudyVisuallyStart studying
Part 05 · Embeddings + RAG · Card 8 of 14

Answer only from context

Tell the model to answer only from the retrieved text, and to say "I don't know" when the answer isn't there.

Last updated

Analogy

A strict type checker for facts: no source, no claim.

In an agent

This one instruction is a big part of how RAG reduces hallucination.

Practice

Flashcards

  • Interview: why use RAG?It gives the model private, up-to-date knowledge and reduces hallucination, without fine-tuning.
  • Interview: how do you reduce hallucinations?Ground with RAG and tools, allow "I don't know", ask for citations, use low temperature, and test with evals.

Interview questions

  • What is RAG and why use it?
    • Retrieve relevant chunks from your own data and add them to the prompt.
    • The model answers from that context instead of from memory.
    • It gives the model private, up-to-date knowledge and reduces hallucination, without fine-tuning.
  • How do you handle hallucinations?
    • Ground answers with RAG and tools.
    • Instruct the model to say "I don't know" when the context lacks the answer, and ask for citations.
    • Use a low temperature and test with evals.

Questions people ask

How do I stop a RAG chatbot from making things up?

Tell it to answer only from the provided context, and to say it does not know when the answer is not there. Ask it to cite which chunk it used. Keep temperature low. Then check with evals that it really refuses when the context is missing, instead of guessing.

Why should a RAG model be allowed to say I don't know?

Because a confident wrong answer is worse than no answer. If retrieval misses, the honest response is that the docs do not cover it. Giving the model explicit permission to say so is a large part of how RAG reduces hallucination, and it shows you where your documents have gaps.