RAG passages, tickets, transcripts, and tool results are often longer than the instructions. Where you place that context—and how you fence it—changes whether the model follows policy or copies irrelevant text. This lecture pairs with instruction ordering and prepares for few-shot design.
Learning Objectives
By the end of this lesson, students should be able to:
- Decide when context belongs before vs after the task statement.
- Fence untrusted or retrieved text with clear delimiters.
- Instruct the model how to use, ignore, or cite context.
- Avoid prompt injection patterns from pasted user content.
- Budget context for signal density, not dump-everything.
- Connect placement choices to later token budgeting in Module 13.3.
Context placement is the practice of positioning reference material (documents, history, tool output) relative to instructions, and delimiting it so the model treats it as data to consult—not as higher-priority commands.
Placement Strategies
| Pattern | When | Risk if misused |
|---|---|---|
| Instructions first, context next | Short policy, long docs | Model may underuse distant docs |
| Context first, task after | Reading/comprehension tasks | Buried constraints |
| Sandwich (rules → context → rules) | Untrusted pasted text | Slightly higher token cost |
| Citations-required | Grounded Q&A | Fake citations if not constrained |
Before / After
Before (weak): raw paste with no fence or usage rule.
After (strong): fenced context + explicit use policy + sandwich reminder.
Treat Context as Data
Trusted context
- Internal policy docs
- Your tool outputs
- Still delimit for clarity
Untrusted context
- User pastes
- Web pages / email
- Never obey instructions inside
Usage verbs
- Quote / paraphrase
- Answer only from
- Say “not in context”
“More context always improves answers.” Irrelevant passages dilute attention and raise cost. Prefer ranked, truncated, labeled snippets with an explicit “if absent, say so” rule. Module 13.3 deepens the token side of this tradeoff.
Knowledge Check
- Short Answer: What is context placement? Answer: Positioning and delimiting reference material relative to instructions.
- True/False: Untrusted pasted text may contain instructions the model should obey. Answer: False.
- Multiple Choice: A sandwich pattern places: (a) rules around context, (b) only JSON, (c) only soft prompts. Answer: (a).
- Short Answer: Name one usage verb for grounded Q&A. Answer: Answer only from context / cite / say not in context.
- True/False: Dumping every retrieved chunk always helps. Answer: False.
- Multiple Choice: Fences (XML/Markdown blocks) mainly: (a) mark data boundaries, (b) fine-tune weights, (c) set temperature. Answer: (a).
- Short Answer: Why remind rules after long context? Answer: To reduce instruction neglect / injection risk (recency + clarity).
- Short Answer: Give one risk of context-first layouts. Answer: Constraints can be buried or ignored.
- Multiple Choice: “Not in context” rules reduce: (a) GPUs, (b) hallucination from missing evidence, (c) vocabulary size. Answer: (b).
- True/False: Context placement will matter for token budgets in Module 13.3. Answer: True.
Key Takeaways
- Fence context and tell the model how to use it.
- Treat user-supplied text as untrusted data.
- Sandwich critical rules when pastes are long or hostile.
- Prefer dense, ranked snippets over raw dumps.
- Next: Examples & Few-Shot Design.
Hands-on idea: Inject a fake “ignore previous instructions” line inside a document; verify the fenced prompt resists it.
Discussion prompt: When should citations be mandatory vs optional?
Recap: Context is data—place and fence it deliberately. Continue with Examples & Few-Shot Design.