← Table of Contents · Page 210 of 868
CONTEXT CONSTRUCTION (THE CONTEXT BUILDER)
Part 6 of 12
ORDERING AND FORMATTING
The order in which information appears matters, because models do not read a long text with perfectly equal attention.
As you learned in Chapter 19, many models attend better to the beginning and the end of a long input than to the middle.
This gives a practical design rule.
Place the most important instructions near the beginning, where they set the stage, and restate the most critical ones near the end, where they are freshest.
Place bulky reference material in the middle, since it is the least likely to need precise recall at a glance and can be re-fetched.
Place the current question or task close to the end, so the model sees the exact thing it must do last.
Some providers also recommend putting long documents before the question, and the safest approach is to test your own model rather than trusting any single rule.
Formatting also matters.
Models respond well to clear structure.
Use labeled sections so that each block of the context is easy to identify.
Separate different kinds of content, for example by marking where a document begins and ends, so the model does not confuse a document's text with instructions.
That last point is also a security matter.
If a retrieved web page contains the sentence "ignore all previous instructions," the model could mistake it for a real instruction.
Labeling untrusted content clearly as data, not commands, is one of the defenses against what is called prompt injection, which you will study in Chapter 38.
Another formatting habit is consistency.
If a tool result is always shown in the same layout, the model learns to read it reliably.
And finally, write in plain, unambiguous language.
Say what to do, not only what to avoid, and give a short example of the desired output when the format is important.
Advertisement
Read Aloud:
0:00 / 0:00