Technique · 14 studies
Instruction order and placement: where things go in a prompt
Instruction placement is deciding where role, priorities, material, examples and the question sit in a prompt. Research supports a simple layout: critical priorities first, reference material in the middle, the specific task and options last, and the task repeated at the end when the context is long.
Also called: prompt ordering, question at the end, primacy and recency, prompt repetition
What instruction placement is
Instruction placement is the practice of deciding where each part of a prompt goes: role and priorities, reference material, examples, and the actual question. The same words in a different order can produce different answers, because language models read strictly left to right and weigh positions unevenly. Two forces are at work, and the research on placement is mostly about which one wins in a given setup:
- Primacy: what comes first frames everything after it. In the instruction-overload study, models given many simultaneous requirements did not mix them up, they skipped them, and the skipped ones came from the tail of the list.
- Recency and causal reading: what comes last sits next to the point where the answer is generated, and only later tokens can "see" earlier ones. In the positional-failure study, moving the same question from the end of a long context to its middle dropped one model from 96% to 8%.
A workable rule reconciles both: put stable priorities (role, main goal, must-have format) at the top, put material in the middle, and put the specific task, the current data and the answer options at the end. When the context is long, say the task twice.
Why order changes the answer
Decoder models apply a causal mask: each token attends only to what precedes it. The CQO vs QOC study shows what that means in practice. With context, then question, then options, the options are encoded after the model has read the evidence. With question, options, then context, the options are encoded blind. Across 21 decoder-only models on four multiple-choice benchmarks, context-first was 14.7% more accurate on average, and accuracy in the options-first format matched having no context at all. The context's share of the prediction was 79.7% in one order and 33.5% in the other.
The end of the prompt matters for a second reason: proximity to generation. In the positional-failure study, 76% of errors with a mid-context task were answers copied from similar neighbouring examples, not reasoning failures; at the end position such matches were 22%. The model did not lose the ability to solve the task, it lost track of which task was being asked.
Primacy explains the other half. The primacy-bias analysis of 39 models argues that early tokens accumulate attention from every later position, so a requirement stated first keeps pulling even after you revise it in the chat. That is why a corrected value should be restated right before the question, not left "above".
Placement patterns that tested well
- Task last. Put the document first and the instruction after it. The Q-Last study found that when the question opens a multi-turn case, models answer early: more than 55% of answers came within the first two messages. Held back until the question arrived at the end, models fixed wrong hypotheses 10 times more often than they broke right ones. An explicit "don't answer yet" barely helped; structure did.
- Context before options. For any choice task, list criteria and facts first and the options last. If a fixed format forces options first, repeat them after the context (QOCO), which recovered 8.2% in the CQO study.
- Repeat the task or the whole prompt. The Prompt Repetition study sent the query twice and recorded 47 wins out of 70 tests and 0 losses on non-reasoning models; on a find-the-name-in-a-list task, accuracy rose from 21% to 97% with triple repetition. In the positional-failure study a copy of the task at the end restored accuracy to within ±4 points of the ideal for all 9 models at 8K tokens. Related forms: asking the model to restate the question before reasoning (+10.4 points for DeepSeek-R1), asking the question before and after an image, and placing retrieved documents twice so facts are read before reasoning colours them.
- Examples first, or next to the code. The position-effect study reports more stable few-shot answers when examples precede the question. For code, the co-located tests study found doctest examples inside the docstring linked to the function 2.8-4.4 times more strongly than tests at the bottom, with accuracy ranging from 0% to 100% depending only on placement.
- Rank instructions by importance. Since the tail of a long rule list is what gets dropped, order constraints from critical to nice-to-have and keep the list short.
Primacy vs "question last": when each holds
The apparent contradiction. One line of work says "most important first"; another says "question last". They measure different things. Primacy studies look at compliance with many simultaneous constraints and at which version of a fact the model keeps. Recency studies look at whether the model finds and answers the right task among a lot of material. The long-context anatomy study combines them in a sandwich: instruction before the document, key requirements repeated after it.
The details still conflict. The lost-in-the-later study reports that models process the end of a long context worse and recommends instructions first, context after, plus an explicit "cover all parts evenly". The VeriCode study found that instructions in the middle of a list were followed 5-10% worse than those at the start or end, and that adding five style rules cut functional correctness by 6%. So the middle is the weak spot in almost every account; the ends disagree by task.
Where placement matters less:
- Some models barely care. In the positional-failure study DeepSeek-R showed no drop; in the long-context anatomy study Gemini and Deepseek held steady at every position while ChatGPT-5-mini dipped from 100% to 80% at the halfway point.
- Reasoning modes. Prompt repetition gave minimal gains when models already reason step by step.
- Short prompts. Most effects grow with context length and are small on a few paragraphs.
- Model updates. In the co-located tests study Code-LLaMA preferred separate tests, and one model family lost and regained the behaviour across versions. Re-test your order after switching models.
What the studies measured
| Study | Lab score | Finding | Effect |
|---|---|---|---|
| Where the Task Sits in Your Context: Why an LLM Ignores the Question Unless It Comes LastMay 22, 2026 | 92 | Moving the question from the end to the middle of a long context dropped one model from 96% to 8%; repeating it at the end restored accuracy to within ±4 points for all 9 models at 8K. | Helps |
| CQO vs QOC: Why the Order of Prompt Elements Swings Accuracy by 15%Jan 20, 2026 | 85 | Context, question, then options was 14.7% more accurate than question, options, then context across 21 decoder-only models. | Helps |
| Prompt Repetition: Double Your Prompt for Better Accuracy Without ReasoningDec 16, 2025 | 88 | Sending the prompt twice gave 47 wins out of 70 tests and 0 losses on non-reasoning models. | Helps |
| Diagnostic Impatience: An LLM Gives a Worse Answer When the Question Comes FirstApr 6, 2026 | 83 | Withholding the question until the end let models fix wrong answers 10 times more often than they broke right ones. | Helps |
| Co-Located Tests: Placing Examples Next to the Code in the Prompt Sharply Improves Generation QualityApr 20, 2026 | 80 | Examples inside the docstring linked to the function 2.8-4.4 times more strongly than tests at the bottom of the prompt. | Helps |
| The primacy effect: LLMs do what comes first, and the rest falls off the endJul 15, 2025 | 92 | Under instruction overload models skipped requirements rather than mixing them up, and the skipped ones came from the end of the list. | Helps |
| VeriCode: Verifiable Instructions for Evaluating LLM-Generated CodeOct 8, 2025 | 90 | Instructions in the middle of a list were followed 5-10% worse; adding five style rules cut functional correctness by 6%. | Mixed |
| Echo of Prompt (EOP): Repeating the Question as a Built-In Attention Reset for LLMsFeb 6, 2026 | 73 | Asking the model to restate the question before reasoning added 10.4 accuracy points for DeepSeek-R1. | Helps |
| Primacy Bias in LLMs: models cling to the first version and lose the lastFeb 27, 2026 | 74 | Across 39 models, early versions of a requirement kept dominating; restating the current data right before the question counters it. | Helps |
| The Position Effect: Where Your Examples Sit Matters More Than What They AreJul 30, 2025 | 82 | Few-shot examples placed before the question gave more stable answers than examples appended after it. | Helps |
| Prompt Echoing: put your question before AND after the image — the model stops ignoring itJul 17, 2026 | 86 | Writing the question both before and after an image let vision models use it for perception and for answering. | Helps |
| SAKE: Duplicating Information to Shield It from Distortion by ReasoningFeb 10, 2026 | 78 | Placing retrieved documents at the start and again after each reasoning step kept facts from being bent by earlier reasoning. | Helps |
| Lost-in-the-Later: two phrases that cure the model's blindness to the end of a long textJul 7, 2025 | 72 | Models processed the end of a long context worse; instructions first plus a cover-all-parts-evenly command helped. | Mixed |
| The Anatomy of Long Context: Where Models Lose Information and Why "Don't Make It Up" Kills AccuracyJan 5, 2026 | 79 | ChatGPT-5-mini dropped from 100% to 80% at the halfway point of long context while Gemini and Deepseek held steady at every position. | Mixed |
Prompts to copy
Task last, with a reminder when it must sit in the middle
{context_part_1}
{intermediate_instruction}
{context_part_2}
----------------------------------------
Reminder, your task is: {question_or_instruction}
From: Where the Task Sits in Your Context: Why an LLM Ignores the Question Unless It Comes Last
Q-Last for layered analysis
I'll give you the information in parts. Please don't draw a final conclusion until you've seen all the data; I'll ask my question at the end.
[Block 1: {general context / who's involved / what the situation is}]
[Block 2: {details of the situation, history, conditions}]
[Block 3: {specifics, nuances, constraints}]
[Block 4 - key data: {numbers, concrete facts, measurable indicators}]
Now the question: {your main question}
From: Diagnostic Impatience: An LLM Gives a Worse Answer When the Question Comes First
Options after the context (QOCO fallback)
Question: {question}
A. {option_A}
B. {option_B}
C. {option_C}
D. {option_D}
{context}
Choose from: A | B | C | D
Answer:
From: CQO vs QOC: Why the Order of Prompt Elements Swings Accuracy by 15%
Related techniques
Problems it helps with:
Questions people ask
Should the instruction go before or after the document?
For a long document, both. Studies favour the specific question at the end, next to where the answer starts, while overall priorities work best at the top. A sandwich (instruction, document, repeated task) covers both effects.
Does repeating the prompt really help?
In the Google Research study, sending the query twice gave 47 wins and 0 losses across 70 tests on non-reasoning models. Gains were minimal when models already reasoned step by step, and repetition doubles input tokens.
Where should few-shot examples go?
Before the question, not after it; for code, inside the function's docstring rather than in a separate test block at the bottom. Keep similar solved examples away from the task itself, since models copied neighbouring answers.
Why does the model use an outdated requirement from earlier in the chat?
Early tokens keep strong influence. Restate the current version right before your question and say to ignore earlier versions, or start a new chat with a short summary.