From prompt sections to token positions
System instructions, examples, and the current question are useful ways to organize a prompt. In a causal decoder, the serialized tokens at all of these positions pass through successive transformer blocks. Putting an example in the middle of a prompt does not send it to the middle layers. Position in the sequence and depth in the network are different axes.
The architecture determines where information can flow. Learned parameters, the prompt, and decoding determine how the model actually uses it. Start with the architectural boundary before interpreting attention maps or making claims about influence.
A causal boundary at every layer
At position i, causal self-attention can read positions up to and including i. Future positions are masked. Thus a question can read preceding examples, while the earlier example representations cannot read a question that comes later. The original Transformer decoder uses this mask to prevent access to subsequent positions during training.
Select a destination token, step through the blocks, and inspect the heatmap. Removing example positions changes the allowed paths in this explicit toy graph. No language model runs in the figure.
Which prompt tokens can reach this position?
An authored, six-token causal decoder graph. Cells show possible dependencies, not attention weights, measured influence, or model predictions.
Input representations. At layer 0, each position starts with its own token and position information. The diagonal shows this initial dependency.
Position 6 can depend on 1 enabled input position: ?.
- 1. Answer: no path
- 2. briefly: no path
- 3. cat: no path
- 4. animal: no path
- 5. dog: no path
- 6. ?: possible path
Allowed paths are not attention weights
For one attention head, the causal mask enters the attention calculation:
A permitted cell can receive an input-dependent attention weight. A masked cell receives zero weight. The heatmap above only records permission: its ones are not attention probabilities. Actual attention uses learned query, key, value, and output projections, often with many heads.
After attention mixes earlier information, residual connections and positionwise transformations produce the next layer's representations. Residual paths can preserve information while other paths transform it. They do not imply that every instruction remains equally influential, nor that system instructions follow a universal exponential decay curve.
Predicting the next token
In a standard causal decoder, the representation at the final prefix position is projected into vocabulary logits. A decoding rule then selects a token. That token extends the prefix, and subsequent generation can condition on it. With a key/value cache, earlier states can be reused without making them depend on newly appended future tokens.
Role delimiters and chat templates depend on the model. Instruction tuning can teach the model to treat role-marked content differently. Neither the causal mask nor a role label alone guarantees instruction following. There is no universal percentage of the answer attributable to a system message, example, or query.
What would establish influence?
An attention map describes one internal calculation. A large attention weight is not, by itself, a causal explanation of an output: value vectors, other heads, residual paths, and later computations also matter. Jain and Wallace (2019) study limits of attention-based explanations; the details of their experiments do not establish a universal ranking for modern language models.
A causal influence claim needs a defined intervention and outcome. For example, fix a checkpoint, prompt template, and decoding setup; replace one demonstration; then measure the change in the next-token log probability or a held-out task score. Report the replacement, baseline, model revision, tokenization, and uncertainty across examples. Removing text changes both its content and the surrounding sequence, so that experiment must be interpreted carefully.
Applying the distinction to prompt design
Use clear instructions, representative examples, and explicit output requirements because they specify the task. Evaluate alternative prompts on the target model and held-out inputs. If constraints are ignored, inspect ambiguity, conflicting instructions, truncation, and actual evaluation results before attributing the failure to an unmeasured layer mechanism.
The prompt engineering lesson makes these task specifications concrete. It uses authored examples to explain mechanisms; model-specific improvements still require evaluation.
Related concepts
Master prompt engineering for large language models: from basic composition to Chain-of-Thought, few-shot, and advanced techniques.
Follow a query-key distance through ALiBi head slopes, attention logits and normalized weights, then understand the evidence and limits of length extrapolation.
Compare head sharing with explicit projection dimensions and KV-cache bytes. Separate exact memory ratios from measured quality and latency, and see why FlashAttention is an independent choice.
See how preserving initial attention sinks stabilizes a rolling KV cache, why it costs recent slots, and why stable streaming does not mean infinite recall.
See how context capacity, attention masks, and KV caches differ. Move a planted fact through a token sequence to inspect what one query can access.
Trace a target query through source keys, attention weights, and a weighted value mix. Understand cross-attention origins, shapes, masks, and applications.
