Few-Shot Examples & Long-Input Placement
CoreUse few-shot examples, delimiters, and iterative refinement · Difficulty 2/5
Explanation
Few-Shot Examples
Provide one or more worked examples (zero-/one-/multi-shot) to lock in format and style. Examples are often more effective than a paragraph of description -- they show the model the target rather than describing it in prose, which matters most for hard-to-articulate formatting or edge-case behavior.
Placement With Long Inputs
With long inputs, put the most important instructions near the end, right before the response, and clearly delimit sections. Long documents generally go before the instruction or question about them -- the reverse ordering buries the key ask under everything the model processes afterward.
Common exam traps
- Burying the key instruction at the top of a huge document -- with long context, place the ask *after* the material and near the end.
- Assuming more examples always help; if the instruction already fully specifies the desired behavior, extra examples cost tokens without adding benefit.
Key Takeaways
- Worked examples (zero-/one-/multi-shot) often lock in format and style more effectively than a paragraph of description
- With long inputs, place the document first and the key instruction/question after it, near the end
- Clearly delimit sections so the model can tell input material from the instruction
- Burying the key ask at the top of a long document is a common exam trap
Glossary Terms
A prompting technique that supplies concrete (input, output) example pairs to guide Claude’s behavior. With the Claude API the idiomatic approach is to encode examples as alternating `user`/`assistant` turns in the `messages` array rather than cramming them into the system prompt — this mirrors the conversation format Claude is trained on and keeps cached system-prompt content stable.
The observed phenomenon where Claude (and other LLMs) give less attention to content in the middle of a long context window compared to content at the beginning and end. Critical information should be placed at the start (system prompt) or end (most recent user turn) of the context.
Related Concepts