- All Courses
- Retrieval-Augmented Generation in Practice
- Grounded Generation
- Prompting with retrieved context
Prompting with retrieved context
Passages pasted into one block become indistinguishable.
Overview
Structure beats concatenation
Passages pasted into one block become indistinguishable. Wrapping each in a delimiter with its source id lets the model attribute claims and lets you check that it did.
State the grounding rule explicitly: answer only from the provided context, and say when the context does not contain the answer. Without that instruction the model falls back on training knowledge and you cannot tell which sentence came from where.
Position matters. Models attend most reliably to the beginning and end of a long context, so put the strongest passages at the edges rather than burying them in the middle.
In this lesson you will:
- Structure the prompt so sources are distinguishable
- Instruct the model to answer only from context
- Order passages deliberately
Resources
Notes are not saved yet — they clear when you leave this page.
Measuring retrieval with recall@k
7m
Citations and attribution
7m