Zekun WangSelf-Consolidating Language Models
Writing context into model weights at test time
Zekun Wang, Anant Gupta, Zihan Dong, Christopher J. MacLellan. Georgia Institute of Technology.
Three contexts arrive one at a time: Lina puts the key in a blue box. Omar carries the blue box to the study. The study is upstairs. Each context is consolidated into a few of the 28 layers of the model. The contexts are then removed from the prompt. Asked whether the key is upstairs or downstairs, the model answers upstairs.- Context 1 is in the prompt. The model selects layers and consolidates the context into them with a LoRA update.
- Context 2 arrives at the updated model and is consolidated in the same way.
- Context 3 is consolidated.
- The contexts are removed from the prompt. The weights keep the three updates.
- The question needs all three contexts. The model answers from its weights.
Language models increasingly receive information as streams of passages, conversations, and long-context workflows. A longer context window exposes more evidence, but it does not ensure that the information is preserved and reused. We study continual context consolidation: writing each incoming context into the model weights while limiting forgetting of previously consolidated contexts.
In SCoL, the model generates a layer selection for each context, which names the Transformer layers that receive a LoRA update. We train the model with meta-reinforcement learning on a reward of acquisition minus forgetting.
On a stream of 100 SQuAD passages with Qwen2.5-7B-Instruct, SCoL reaches 40.7% immediate accuracy and 31.0% retention and outperforms every evaluated baseline on both metrics. The same holds on Llama-3.1-8B-Instruct, on Qwen3.8-27B, and on an out-of-distribution stream of New York Times paragraphs. On LongBench v2, SCoL is meta-trained on short contexts only and reaches 41.9% on short contexts and 38.0% on long contexts.
Long-context inference as a continual learning problem
Language models increasingly operate over streaming context: multi-turn conversations, tool-using agents, and document workflows. The model must answer from the current prompt and also preserve earlier information for later use. Longer context windows help, but models underuse distant evidence and degrade as the context grows.1
Retrieval, compression, and external memory manage access to the context.23 They depend on retrieval quality, auxiliary modules, or lossy compression, and they process the stored context again at inference time.
We study a complementary direction: using the model weights as memory. In theories of memory consolidation, experience is integrated into long-term representations instead of being kept as transient context.45 We ask whether a context can be written into the weights so that it remains available after the context is gone.
Continual context consolidation
The model receives a stream of contexts, one at a time. A context can be a text passage, a multi-turn interaction history, or a long-context window. At step t, the model consolidates the current context c into its weights θ with an update at the selected layers a.
θt=θt−1⊕Adapt(θt−1,ct,at)
The weights carry all consolidated contexts. No retrieval index or external memory is kept, and at question time the contexts are not in the prompt. This turns long-context inference into a continual learning problem: each consolidation must preserve the previously consolidated contexts.
Sequential updates cause forgetting
Sequential updates to a neural network are prone to catastrophic interference. An update for a new context changes weights that store previously consolidated contexts.6
Context 1 is consolidated into three layers. When Context 2 is consolidated into the same layers, it overwrites part of the update for Context 1. When Context 2 is consolidated into different layers, the update for Context 1 is not overwritten.- Context 1 is consolidated into three layers.
- Context 2 is consolidated into the same layers. It overwrites part of the update for Context 1.
- Context 2 is consolidated into different layers. The update for Context 1 is not overwritten.
We measure two quantities on a stream. Immediate accuracy is the accuracy on the questions of a context right after it is consolidated. Retention is the accuracy on the questions of past contexts after the whole stream is consolidated.
Classical continual learning methods reduce interference by estimating parameter importance, for example with Fisher-based regularization.67 Reliable Fisher estimation is costly at the scale of a language model.8 We ask whether the model itself can determine where the update should occur.
The model selects the layers to update
For each context, SCoL prompts the current model to generate a layer selection, a list of Transformer layer indices. The update budget limits its length. In the main experiments the model is Qwen2.5-7B-Instruct and a layer selection contains up to 10 of its 28 layers.
at∼πθt−1(⋅∣ct)
We attach LoRA adapters to the selected layers and train them on the context with the language-modeling objective.9 The committed update becomes part of the weights. The LoRA hyperparameters are fixed, so the learned decision is where to update, not how strongly.
SCoL builds on SEAL, which trains a model to generate its own update instructions.10 SCoL restricts the instruction to the layer selection. Each committed update also changes the model that generates the next layer selection, so the model is trained over its own evolving weights.
Training with meta-reinforcement learning
For each context during training, the current model samples K = 10 candidate layer selections. Each candidate receives the same LoRA update from the same current weights, at its own selected layers. We score each candidate with the reward.
rt=acquisitionut−λforgettingft
For one context, the current model samples 10 candidate layer selections. Each candidate receives the same LoRA update from the same weights. Each candidate is scored with the reward, acquisition minus λ times forgetting. The candidate with the highest reward is committed. The preference pairs between candidates train the round-start model.- The current model samples 10 candidate layer selections for the same context.
- Each candidate receives the same LoRA update, from the same weights, at its own selected layers.
- Each candidate is scored with the reward: acquisition of the current context minus λ times forgetting of past contexts.
- The candidate with the highest reward is committed, and the stream continues from the updated weights.
- After the stream, the preference pairs between higher-reward and lower-reward candidates train the round-start model.
The candidate with the highest reward is committed, and the stream continues from the updated weights. For each context, every pair of a higher-reward and a lower-reward candidate is kept as a preference pair.
After the stream, the preference pairs train the round-start model, not the model at the end of the stream, with Identity Preference Optimisation (IPO).11 The next round starts from the updated round-start model. This is the meta-learning step: the round-start model is trained so that its own sequence of updates produces better layer selections.
On SQuAD, the reward uses held-out questions. Acquisition is the accuracy on the questions of the current passage, and forgetting is the accuracy drop on the questions of past passages.12 On LongBench v2, the reward needs no labels. Acquisition is the gain in log-likelihood of the current segment, and forgetting is the relative drop in log-likelihood of past segments.13
Results on SQuAD and LongBench v2
On a stream of 100 SQuAD passages with Qwen2.5-7B-Instruct, SCoL reaches 40.66% immediate accuracy and 31.00% retention. SCoL (λ = 0), which removes the forgetting term from the reward, reaches 39.53% and 25.14%. SEAL (continual), which applies SEAL to the same stream, reaches 28.41% and 21.36%.
On a stream of 100 SQuAD passages, SCoL reaches 40.7% immediate accuracy and 31.0% retention and alone forms the Pareto frontier between the two. On LongBench v2, SCoL reaches 41.9% on short contexts and 38.0% on long contexts, where Batch TTT reaches 39.5%.
Last-10, Middle-10, and Random-10 update the last 10 layers, the middle 10 layers, or 10 random layers. Under the same update budget, all three stay below SCoL on both metrics. Last-10 reaches 35.07% and 26.98%, and Random-10 reaches 37.83% and 23.81%. SCoL outperforms every evaluated baseline on both metrics, so it alone forms the Pareto frontier between immediate accuracy and retention. It is also the only method whose retention exceeds the accuracy of Prompting-only, 28.17%.
On LongBench v2, each example is a long context with a question. The model consolidates the long context as a stream of 2,048-token segments and answers the question after the last segment. We meta-train on short contexts of 16k to 32k tokens and evaluate on short contexts and on long contexts of 32k to 64k tokens. SCoL reaches 41.9% on short contexts, the highest accuracy, and 38.0% on long contexts. Sequential FT reaches 34.2% and 27.2%. On long contexts SCoL outperforms Full Context (35.5%) and Summarization (36.3%), which keep the context or its summary in the prompt. Batch TTT, which trains one LoRA adapter on the full context, reaches the highest accuracy on long contexts, 39.5%.
SCoL outperforms the baselines on other models, update budgets, and an out-of-distribution stream
We repeat the SQuAD experiment on Llama-3.1-8B-Instruct, which has 32 layers, and on Qwen3.8-27B, which has 64. On both models SCoL outperforms every evaluated baseline on both metrics. It reaches 54.47% immediate accuracy and 34.57% retention on Llama-3.1-8B-Instruct, and 50.16% and 43.94% on Qwen3.8-27B.
On Llama-3.1-8B-Instruct, SCoL reaches 54.5% immediate accuracy and 34.6% retention. On Qwen3.8-27B it reaches 50.2% and 43.9%, and at update budgets of 5, 10, and 20 layers it outperforms updating the last layers or random layers. On 100 New York Times paragraphs it reaches 29.7% and 20.5%. After the stream of 100 SQuAD passages its 5-shot MMLU accuracy is 73.6%, against 74.2% before any update.
On Qwen3.8-27B we also meta-train SCoL at update budgets of 5, 10, and 20 layers and compare it with updating the last layers or random layers under the same budget. SCoL outperforms both on both metrics at every update budget.
For an out-of-distribution stream, we take the Qwen2.5-7B-Instruct meta-trained on SQuAD and, without retraining, consolidate 100 New York Times paragraphs from SQuADShifts.14 SCoL reaches 29.65% immediate accuracy and 20.47% retention and outperforms every baseline on both metrics.
We also test whether consolidation degrades general ability. On 5-shot MMLU, Qwen2.5-7B-Instruct scores 74.19% before any update.15 After the stream of 100 SQuAD passages, SCoL scores 73.56%, SCoL (λ = 0) scores 70.67%, and the baselines score between 70.61% and 71.75%.
Every method updates on passage text and is evaluated on questions. To test whether supplying the question format changes the comparison, we add QA replay to Batch TTT, SEAL (continual), and SCoL: question and answer examples from held-out passages, given in the prompt or through a separate adapter that is applied only at evaluation. With the adapter, the retention of SEAL (continual) rises from 21.36% to 28.13%. SCoL retains 31.00% without replay and 32.56% with the same replay.
Selected layers align with high Fisher information
We compare the layer selections with layerwise Fisher information, measured on the running model for each passage before the passage is consolidated.8 Fisher information measures where the loss on the current passage is most sensitive.
recall@k(c)=k∣S(c)∩Topk(F(c))∣,k=∣S(c)∣
For three SQuAD passages, the layerwise Fisher information and the layers that SCoL selected. Over 100 SQuAD passages, recall@k is 42.9% for SCoL, 37.6% for SCoL (λ = 0), and 35.7% for a random selection.
Over 100 SQuAD passages, recall@k is 42.9% for SCoL, 37.6% for SCoL (λ = 0), and 35.7% for a random selection of 10 of the 28 layers. The two variants differ only in the forgetting term of the reward, so the alignment with Fisher information is learned from this term. Fisher information is never given to the model.
SCoL updates the layers that are most sensitive to the current passage and leaves most layers unchanged. This selective plasticity matches continual learning methods that reduce interference by restricting updates to sparse, task-specific parameters.7
Limitations and future work
SCoL learns where to update at the granularity of Transformer layers. Selecting individual projection matrices underperforms layer selection, because the model must generate long structured outputs. The finest granularity is individual weights, and recent work has a language model edit a network at this level, though not for continual learning.16 Future work could study stronger models that select updates at the level of individual weights.
Meta-training on longer streams, or adapting the weight λ of the forgetting term to the context length, could further improve the consolidation of long contexts.