Anthropic's current documentation on long-context prompting recommends where to place long documents or data-rich inputs (roughly 20,000+ tokens) relative to the query and instructions. What does it recommend, and what improvement does it cite?
- Place the long documents and other inputs near the top of the prompt, above the query, instructions, and examples; the documentation notes that putting queries at the end can improve response quality by up to 30 percent in tests, especially for complex, multidocument inputs
- Place the long documents at the very end of the prompt, after the query and instructions, because Claude always weighs the last few hundred tokens of a prompt most heavily regardless of content length
- Split the long document into many short, separate API calls of under 500 tokens each, since Claude cannot process more than roughly 20,000 tokens of context in a single request
- Interleave single sentences of the long document between each instruction sentence so that context and instructions alternate line by line throughout the prompt
Why A? And why not the others?
Correct answer: A. Place the long documents and other inputs near the top of the prompt, above the query, instructions, and examples; the documentation notes that putting queries at the end can improve response quality by up to 30 percent in tests, especially for complex, multidocument inputs
Anthropic's documentation recommends putting longform data and documents near the top of the prompt, above the query, instructions, and examples, when working with large or data-rich inputs of roughly 20,000 or more tokens, and it notes that queries placed at the end can improve response quality by up to 30 percent in tests, especially with complex, multidocument inputs, alongside wrapping each document in XML tags with source metadata. The second option is wrong because it recommends the opposite placement of what the documentation states; the guidance is to put documents near the top, not at the end. The third option is wrong because Claude's context window comfortably exceeds 20,000 tokens in a single request, and the tip concerns how to structure one large prompt, not evidence that requests must be split into many small calls. The fourth option is wrong because no sentence-by-sentence interleaving of context and instructions is recommended; the documented structure instead wraps whole documents in dedicated tags kept separate from the instructions.
Source: Anthropic, "Prompting best practices" -- "Long context prompting," platform.claude.com prompt engineering documentation