Lesson 4.1

Prompting with retrieved context

Passages pasted into one block become indistinguishable.

9mAdvanced4k students

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

Previous Lesson
Next Lesson
Prompting with retrieved context — Retrieval-Augmented Generation in Practice — Vertex