RAG (Retrieval-Augmented Generation)
Retrieving source material before generating an answer
What is RAG (Retrieval-Augmented Generation)?
Retrieval-augmented generation supplies relevant external material to a model before it answers. The retrieval step can use keywords, vectors, filters, or a combination. RAG can support grounded answers, but poor retrieval or incorrect interpretation can still produce errors.
How it works
Refund policy · section 2
You can request a refund within 14 days of purchase. Include your order number with your request.
Answer
You have 14 days from the purchase date to request a refund. [1]
Key takeaways
-
Keep sources current and access-controlled.
-
Include unsupported questions and contradictory sources in evaluation.
Illustrative example
In a hypothetical policy assistant, retrieve the currently approved refund policy, pass the relevant clause to the model, and link the answer to that clause. If no applicable clause exists, report that the source does not answer the question.
Build and check the retrieval path
Index the policy with its effective date and keep a record of the passages supplied for each answer. Suppose a reader asks how long they have to request a refund. If retrieval returned last year’s policy, check the version filter. If the model received the current clause but cited the deadline for a different product, the mistake happened after retrieval. Keeping the passage alongside the answer makes those failures distinguishable.
RAG, prompting, and fine-tuning
Scroll the table to see every column.
| Approach | What changes | A suitable need |
|---|---|---|
| Prompting | Instructions and examples in the request | Clarify the task, format, or source-use rule |
| RAG | Evidence retrieved for an answer | Use current or attributable documents |
| Fine-tuning | Model parameters through further training | Improve repeatable behavior under measured evaluation |
| Combined system | Different parts of the application | These methods can be used together |