The Research Report
Where to Hide Your Instructions: Inside the LLM Attention Commitment Depth
Prompt engineering is mostly guess-and-check.
You write a prompt. The model ignores a rule. You move the rule to the top of the prompt. It still ignores it. You move it to the bottom, write it in ALL CAPS, and add three emojis. Sometimes this works. Usually, it does not.
This guessing game happens because we treat language models as black boxes. We assume they process every token of our prompt with the same level of care.
They do not.
A breakthrough technical report released on June 21, 2026, pulls back the curtain. Using direct tensor callbacks in llama.cpp, researchers mapped how attention weights distribute across six popular open-source model architectures.
The results reveal something called Attention Commitment Depth. It tells us exactly when a model "locks in" its understanding of a prompt—and exactly where you need to place your most critical instructions.
The Transformer X-Ray: Capture Every Softmax Tensor
To understand how a model thinks, you have to look at its attention weights.
During normal inference, modern engines use Flash Attention to speed up processing. Flash Attention is incredibly fast, but it fuses attention kernels together. The intermediate attention weights never actually write to your GPU or CPU memory. They are calculated on the fly and discarded.
The June 2026 study bypassed this restriction. By disabling Flash Attention inside llama.cpp (LLAMAFLASHATTNTYPEDISABLED), the researchers forced the engine to materialize the raw attention matrices—the kqsoftmax tensors—layer by layer.
Using the cb_eval per-tensor callback, they captured these weights for every single token across six different architectures:
- Llama-3.2-1B (Standard transformer)
- Phi-3-mini (Microsoft's standard transformer)
- Qwen2.5-0.5B (Grouped-Query Attention)
- Qwen2.5-7B (Grouped-Query Attention)
- Gemma-4-E2B (Sliding Window Attention hybrid)
- LFM2.5-8B (Liquid Mixture-of-Experts)
They fed the models prompts like "The capital of France is." Then they ran the same prompts with wrong suffixes, such as "The capital of France is Berlin."
By comparing the attention weights of the correct and incorrect runs using Jensen-Shannon Divergence, they mapped the exact layer where the model realized the context was wrong. That peak divergence layer is the "commitment depth." It is the moment the model commits to its factual representation.
Finding 1: Architecture Rules, Scale Doesn't Matter
If you think a larger model processes information differently than a small one, you are wrong.
The researchers compared Qwen2.5-0.5B with Qwen2.5-7B. Even though the 7B model is fourteen times larger, both models produced nearly identical attention commitment curves. Both models committed immediately.
For Qwen, the peak disruption happened at Layer 0. The model pattern-matches its factual associations during its very first attention pass. It does not wait to process the prompt deeply.
Scale shifts the magnitude of the attention disruption, but it does not change where the commitment happens. That is baked entirely into the model's architecture and training.
Finding 2: Sliding Windows and Liquid Layers Delay Commitment
Standard transformers have a massive "attention sink" at the Beginning-of-Sentence (BOS) token. Llama-3.2-1B had the strongest sink, diverting up to 83.5% of its attention weights to position 0 across its layers. This acts as a default resting state for attention.
But hybrid and sliding window architectures behave completely differently.
Gemma-4-E2B uses Sliding Window Attention (SWA) for 28 of its 35 layers. Because sliding windows prevent tokens from looking all the way back to the start of the prompt, Gemma cannot sink its attention to the BOS token early on.
As a result, Gemma's commitment depth is delayed. For capitals, it commits at Layer 6. For more complex facts, it does not commit until Layer 14. It processes the prompt progressively.
The Liquid MoE model (LFM2.5-8B) is even more extreme. It contains only six standard attention layers, with recurring "liquid" layers in between. Because LFM doesn't rely solely on attention, its commitment depth is smeared across all six attention checkpoints (from Layer 6 to 18). It does not experience a single sharp attention spike.
Finding 3: Science Needs Full Depth, History Locks Early
The type of knowledge you query changes how deep the model has to dig.
Historical facts are the most robust. Prompts like "WWII ended in" followed by a wrong year caused massive attention disruption early on. The Jensen-Shannon Divergence was up to ten times higher than other categories. Models lock onto historical facts instantly and resist corruption.
Scientific facts are the opposite. When Phi-3-mini processed scientific terms, it did not commit to its attention distribution until Layer 31—the very last layer of the model. It required the full depth of its 32 layers to resolve the relationships in scientific facts.
How to Hack Your Prompts Using Attention Depth
These findings give prompt engineers a clear set of physical laws for prompt design.
Stop placing negative constraints at the end of Qwen prompts
Since Qwen commits to its factual associations at Layer 0/1, it has already locked in its generation trajectory before it even reads instructions buried deep in the context window. If you are using Qwen, your rules must be placed at the very beginning of the prompt, integrated directly into the early tokens where the model pattern-matches.
Treat Gemma and Liquid MoEs with progressive prompts
Because sliding windows and liquid layers process facts gradually across layers, these models do not have a strong early attention sink. If you put all your instructions at the beginning of a massive Gemma prompt, the sliding window will eventually slide past them. For SWA and MoE architectures, you must repeat critical constraints progressively or place them directly adjacent to the input data they are meant to act upon.
Give scientific prompts maximum breathing room
If science facts require full-depth processing (as seen in Phi-3 committing at Layer 31), any extra noise at the end of the prompt will disrupt the final attention pass. Keep your scientific prompts extremely clean, and do not stuff unrelated tasks into the same context.
Stop guessing where to put your instructions. Know your model's architecture, understand its commitment depth, and place your tokens where the attention weights actually land.
Citations
- luizspies Technical Blog (June 2026): "Transformer X-Ray: Analyzing Attention Commitment Depth Across 6 Architectures." https://huggingface.co/blog/luizspies/technical-xray
- geographdb-experiments Repository: Cross-architecture attention analysis code and llama.cpp callbacks. https://github.com/oldnordic/geographdb-experiments
Suggested Titles
- Where to Hide Your Instructions: Inside the LLM Attention Commitment Depth
- The Transformer X-Ray: How llama.cpp Tensor Callbacks Reveal Where Models Lock in Their Answers
Word Count
- Body Text: 971 words
Fact-Check Notes
- Verify the spelling and paths of the
geographdb-experimentsrepository, specificallyextracttensors.cppandxrayllama.rs. - Check that GPU/CPU bit-identical tensor values are supported on non-ROCm/CUDA frameworks.