Ground it, or refuse
AI and retrieval
A retrieval system earns trust by answering from supplied documents and saying 'no matching context' when there is none. Everything else — chunking, embeddings, prompts — serves those two behaviours.
Retrieval before generation
Index the corpus, then retrieve the passages that match the question, then answer only from those passages. The model's general knowledge is exactly what you do not want when the question is about your refund policy.
Chunking decides what can be retrieved. Too large and the answer is buried; too small and the passage lacks the context that makes it true.
Citations and refusal
Ask for the source file in brackets beside each claim, and make 'no matching context' an acceptable answer. A system that cannot refuse will invent, and an invented policy is worse than no answer.
Evaluate with cases, not impressions: one question the corpus answers, one it does not. If the second returns a confident guess, the prompt is wrong, not the model.
Commands in this lesson
Every one of these runs in the sandbox — no real account, no real bill.
| Command | Why |
|---|---|
rag index docs | Build the retrievable corpus before any question is asked. |
rag query "refund window" > answer.txt | One question, one answer file — evidence you can inspect. |
rag query "warranty" > no-answer.txt | The out-of-scope case. This is the test most projects skip. |
echo 'You are a support assistant. Use only the supplied context. Cite the source file in brackets.' > prompt.md | Grounding and citation stated as rules, not hopes. |
Now do it
Reading the model makes the first attempt faster. Only the lab makes you able to do it.
- Open the lab
AI: Index a Knowledge Base for RAG
Beginner · 20 min · members
- Open the lab
AI: Evaluate a Retrieval Answer
Intermediate · 25 min · members
- Open the lab
AI: Define an MCP Tool Contract
Intermediate · 25 min · members
AI and retrieval · OphirCloud Academy · all lessons