Introduction
In-context learning (ICL)—the ability of a Large Language Model (LLM) to learn a new task from just a few examples in a prompt—remains one of the most intriguing features of modern AI. While the model's weights are frozen during inference, it behaves as if it has been reprogrammed by the input context. Previous theoretical work suggested that for original "vanilla" Transformers, this behavior could be mathematically re-interpreted as a set of implicit weight updates. However, modern architectures like Gemma and Llama have evolved significantly, incorporating gated MLPs (e.g., SwiGLU), RMSNorm, and bias-free layers. This research investigates whether the "context-as-weight-updates" theory holds for these complex, contemporary architectures.
The Controllability Framework
The authors introduce a framework of "input and output controllability" to bridge the gap between context and weights. This framework posits that context can be "compiled" into rank-1 weight patches and normalization adjustments, effectively turning in-context learning into a form of transient, implicit fine-tuning.
The framework relies on two core properties:
- Input Controllability: The ability to update a layer's weights to "cancel out" a change in input, ensuring the internal activation remains identical.
- Output Controllability: The ability to update weights to absorb any remaining difference in the output, such as differences caused by residual connections.
By applying these properties, the authors derive exact analytical solutions for a Gemma-style block. They show how rank-1 updates to the gate and up-projection matrices ($W_{gate}, W_{up}$), combined with a shift in the RMSNorm scale ($m$), can perfectly replicate the effect of context.
Methodology and Numerical Stability
The research provides an algorithm to propagate these updates layer-by-layer through deep networks. A significant challenge identified is numerical stability. Direct division in weight updates can be unstable in low-precision formats like bfloat16. To address this, the authors developed a robust update method using Lagrange multipliers to invert the RMSNorm operation, termed the "Stable" update.
Validation was performed using instruction-tuned Gemma 3 (1B and 4B) models across diverse tasks, including creative writing (textual context) and image-to-text description (multi-modal context).
Key Results
The experiments demonstrate that the "patched" model—running without the prompt—can produce identical tokens and nearly identical logit distributions compared to the original model running with the prompt.
In float32 precision, the matching is nearly perfect. However, standard bfloat16 implementations proved highly sensitive. While a naive update achieved approximately 87.5% token agreement, the "Stable" update using RMSNorm inversion pushed agreement to 98%, matching the performance of higher-precision float32. This success across both text and image modalities suggests the principle is fundamental to the Transformer architecture rather than specific to a single data type.
Discussion and Future Work
This work provides a concrete mechanistic lens for understanding ICL: instead of viewing the model as "processing" a prompt, the prompt can be viewed as a set of instructions that "transmute" the model's weights into a task-specific state.
Currently, these weight patches are "transient," meaning they must be recomputed for every generated token. This limits the method's current utility to a descriptive tool for interpretability rather than a replacement for the KV cache. Future research aims to find "global" updates—a single set of weight changes that can absorb an entire prompt for all future queries. The authors suggest "thought patches" as a potential bridge toward this goal.
Summary updated