Generative Adapter: Contextualizing Language Models in Parameters with A Single Forward Pass

Tong Chen, Hao Fang, Patrick Xia, Xiaodong Liu, Benjamin Van Durme, Luke Zettlemoyer, Jianfeng Gao, Hao Cheng

Introduction

Large Language Models (LLMs) typically adapt to new information via computationally expensive fine-tuning or memory-intensive prompting. To make LLMs useful for specific applications, they must be adapted to new contexts—such as a company's internal documents, a specific user's chat history, or novel task instructions. Currently, the field relies on two main paradigms, both of which face severe scaling bottlenecks:

  1. Prompting (e.g., In-Context Learning, RAG): Context is pasted directly into the prompt. While flexible, this is expensive at inference time. Because attention scales quadratically, long contexts consume massive amounts of compute and memory via the KV cache.
  2. Fine-tuning: The model's weights are updated using gradient descent. This bakes knowledge into the model for cheaper inference, but training requires computationally heavy backward passes and is notoriously data-inefficient for learning new facts.

This paper introduces Generative Adapter, a method that uses a lightweight generator network to instantly convert text context into parameter updates (adapters) for a frozen LLM using just a single forward pass. This allows the model to "memorize" long contexts on the fly, drastically reducing inference overhead compared to standard prompting while avoiding the training costs of fine-tuning.

The Generative Adapter Approach

Drawing inspiration from the classic neural network concept of "fast weights"—where a slow network generates weights for a fast network—the authors propose a dynamic adaptation architecture.

Test-Time Contextualization Architecture

A frozen base LLM (such as Mistral-7B) is augmented with a lightweight "adapter generator" network. As a stream of context arrives, the base LLM encodes it into hidden states. The generator takes the outer product of these hidden states to instantly compute additive weight updates ($\Delta W$) for the LLM's linear projection layers. Crucially, no backpropagation is required.

Because the weight generation relies on a running sum of outer products, the model can ingest infinite streaming context chunk-by-chunk. It updates a running memory matrix without needing to store all past hidden states. To address the numerical instability of naive outer products, the authors apply Singular Value Decomposition (SVD) normalization. This stabilizes the generated weights and naturally produces low-rank matrices, making the updates parameter-efficient (similar to LoRA). The generator is trained end-to-end on web text using self-supervised next-token prediction tasks, resulting in a general-purpose adapter.

Experimental Setup

The adapter generator was pretrained on a 1-billion-token subset of SlimPajama (web text) and instruction-tuned on a mixture of QA and instruction-following datasets (e.g., COQA, DROP, NarrativeQA). The authors evaluated the method across several domains:

  • Document QA: SQuAD and StreamingQA (testing contexts up to 32K tokens).
  • In-Context Learning: MetaICL (a benchmark of 26 diverse tasks).
  • Personalization: Multi-Session Conversation (MSC), testing the model's ability to remember user details across long chat histories.

Computational Efficiency and Key Insights

A major advantage of Generative Adapter is its ability to scale to modern LLMs while maintaining an $O(1)$ memory footprint for streaming context. Because the generator updates a fixed-size state matrix as new context chunks arrive, the memory footprint remains constant, unlike the KV cache which grows linearly with sequence length.

Computational and Storage Efficiency
  • Fast Weights Scale: Dynamically generating weights on the fly is highly viable for billion-parameter transformers, providing a strong alternative to the standard KV-cache memory bottleneck.
  • Self-Supervision is Sufficient: Complex, task-specific meta-learning loops are unnecessary. Simple self-supervised objectives (compressing context into weights to predict the next word) are enough to train a capable, general-purpose adapter generator.
  • SVD Normalization: Normalizing the singular values is the crucial engineering trick that makes this architecture stable and allows it to mimic the efficiency of LoRA.

Key Results

  • Knowledge Injection: On StreamingQA with massive 32K-token contexts, Generative Adapter achieved a 63.5% F1 improvement over supervised fine-tuning (jumping from 19.5 to 31.5). It outperformed continual pretraining (CPT) while requiring orders of magnitude less compute.
  • Personalization Efficiency: On the MSC dataset, Generative Adapter matched the performance of prompting the model with the full conversation history, but achieved a 4x reduction in inference computation and memory costs (0.505 TFLOPS vs 2.059 TFLOPS).
  • In-Context Learning: On MetaICL, the method achieved an average accuracy of 44.9 across 26 tasks, outperforming standard few-shot prompting of the base model.
  • Synergy with RAG: Generative Adapter stacks effectively with Retrieval-Augmented Generation. Using the adapter alongside just 100 retrieved tokens achieved a 63.6 F1 on StreamingQA, rivaling a standard RAG setup that required 1,000 tokens in the prompt.

Limitations and Future Work

Due to computational constraints, the authors only applied the generated adapters to the output projection layers of the attention mechanism. While ablations showed that updating the feed-forward networks yields better performance, it incurs higher compute costs. Additionally, the adapter generator adds roughly 500 million parameters to the model—a non-zero memory footprint, though still much smaller than storing massive KV caches for long contexts.

Future work will explore scaling the generator to integrate adapters into additional transformer layers and investigating more selective update rules to prevent the adapter from overwriting important older information as context grows infinitely long.

Summary updated

BibTeX
@inproceedings{chen2025generative,
  author = {Tong Chen and Hao Fang and Patrick Xia and Xiaodong Liu and Benjamin Van Durme and Luke Zettlemoyer and Jianfeng Gao and Hao Cheng},
  title = {{Generative Adapter: Contextualizing Language Models in Parameters with A Single Forward Pass}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=bc3sUsS6ck},
}
Figure