Manuscript Offprint

arXiv:2610.38356

Encode Once, Answer Many: Internalizing Context via Parametric Flow

Xinhao Zhong, Mengxuan Wu, Chonghua Liao, Linxi Xie, Ruicheng Feng, Yanpei Guo, Hao Tan, Jiaxin Hong, Jason Li, Panpan Zhang, Ziheng Qin, Qinglin Lu, Yuzhang Shang, Tongliang Liu, Damian Borth, Haggai Maron, Yongxiang Hua, Zhixiang Wei, Jian Hu, Yunfei Wu, Xing Sun, Xin Li, Haoyu Cao, Zhangyang Wang, Kai Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Xinhao Zhong†1^{\dagger 1}, Mengxuan Wu†1^{\dagger 1}, Chonghua Liao1^{1}, Linxi Xie2^{2}, Ruicheng Feng1^{1}, Yanpei Guo1^{1}, Hao Tan1^{1}, Jiaxin Hong1^{1}, Jason Li3^{3}, Panpan Zhang4^{4}, Ziheng Qin4^{4}, Qinglin Lu1^{1}, Yuzhang Shang5^{5}, Tongliang Liu6^{6}, Damian Borth7^{7}, Haggai Maron8^{8}, Yongxiang Hua1^{1}, Zhixiang Wei1^{1}, Jian Hu1^{1}, Yunfei Wu1^{1}, Xing Sun1^{1}, Xin Li1^{1}, Haoyu Cao1^{1}, Zhangyang Wang2^{2}, Kai Wang1^{1}

1^{1}Tencent, 2^{2}UT Austin, 3^{3}NTU, 4^{4}NUS, 5^{5}UCF, 6^{6}University of Sydney, 7^{7}University of St. Gallen, 8^{8}Technion Large language models are typically adapted to a task either by placing knowledge in the input context, which keeps it external and re-encodes it on every call, or by fine-tuning, which internalizes it but demands a costly round of optimization per task. We aim to internalize the knowledge carried by a context directly into model parameters, without per-task optimization and without keeping the context in the input at inference time. To this end, we propose CLIK, a context-conditioned parameter generator that maps a given context to LoRA parameters for internalizing knowledge in a single forward pass through a Transformer encoder with cross-attention, requiring no test-time gradient updates. Once the generated LoRA is inserted into a frozen base model, the model answers downstream queries from the query alone, having internalized the context into its weights rather than re-reading it. Because the adapter depends only on the context, it is generated once and reused for every query on the same document, so the cost of reading that document is amortized across queries. On document question answering, CLIK substantially improves over the no-context base model and outperforms existing hypernetwork-based generators, while remaining behind a base model that reads the context directly, and it carries over to multi-turn dialogue without any multi-turn-specific training. Analysis further shows that the context-dependent part of the generated adapter concentrates in a compact and specific substructure.

Github: https://github.com/Cypher-Bruce/CLIK.git

Correspondence: Haoyu Cao, Zhangyang Wang, Kai Wang

1 Introduction

Many uses of large language models (LLMs) require the model to act on a specific body of knowledge that is not in its pretrained weights, such as a set of reference documents, a long task instruction, or the history of an ongoing conversation (Brown et al., 2020; Laban et al., 2026). The standard way to supply this knowledge is to place it in the model's input context, as in in-context learning and retrieval-augmented prompting, where the material is kept as text and read by attention at generation time; this approach is flexible, requires no training, and has become the default as context windows have grown. A second route is to write the knowledge into the weights by fine-tuning, so that the model answers without the context in its input (Ouyang et al., 2022; Zhang et al., 2026): parameter-efficient methods such as LoRA make each update cheap to store (Hu et al., 2022), and context distillation trains the model to reproduce, without the context, the outputs it would have produced with it (Snell et al., 2022; Kujanpää et al., 2025).

Keeping the knowledge in the input runs into two well-documented problems. The first is that quality does not scale with length, because as inputs grow, models increasingly fail to use the relevant information and

† Equal contribution

Figure

Figure 1 Three ways to supply external knowledge to a frozen LLM. Context in Prompt: re-injecting the context as text incurs high token cost. Context in Parameter: fine-tuning each context into a LoRA incurs high computational cost. Context-conditioned Parameter Generator (ours): a generator maps each context to a LoRA in a single forward pass, free of both test-time optimization and context in the input.

their accuracy degrades, an effect reported as lost-in-the-middle behavior, weak long in-context learning, and context rot (Liu et al., 2024; Li et al., 2025a; Hong et al., 2025). The second is that cost grows with length, because self-attention is quadratic in the input and the key-value cache that must be stored and re-read at every decoding step grows linearly with the number of context tokens, so both latency and memory rise with the amount of knowledge supplied (Ge et al., 2024). Prompt- and cache-compression methods relieve this overhead by shortening the input or shrinking the cache (Jiang et al., 2023; Pan et al., 2024; Ge et al., 2024), but the knowledge still lives outside the parameters and must be re-supplied and re-read for every new query, so it is supplied to the model but never internalized by it.

Writing the knowledge into the weights instead internalizes it directly, but each new context needs its own optimization run, which is slow and hyperparameter-sensitive and has to be repeated whenever the knowledge changes. This becomes impractical when contexts are numerous, user-specific, or arrive continually (Li et al., 2025b). Fine-tuning therefore internalizes knowledge but cannot adapt on the fly.

These two routes trade off in opposite directions (Figure 1). Context-based adaptation is instant but never internalizes its knowledge, while fine-tuning internalizes the knowledge but is too costly to update for each new context. Hypernetworks (Ha et al., 2017) offer a way to keep the advantages of both, since one network can emit the weights of another and thus turn an input into an adapter in a single forward pass, with no test-time optimization and nothing left in the context window (Chen et al., 2025; Abdalla et al., 2025; Liang et al., 2025). Recent work brings this idea to LLMs by mapping a task description or a short context to a LoRA adapter (Charakorn et al., 2026; Liu et al., 2026). Turning a long context into a faithful adapter is harder than a naive application of this idea, because the adapter is high-dimensional and existing generators emit its weights in independent fragments that ignore dependencies across layers and modules, so the longer and richer the context, the harder it is to capture in one coherent set of weights.

We propose to directly generate context-conditioned LoRA for internalizing knowledge (CLIK), a parameter generator built for this regime that maps a context directly to LoRA parameters in a single forward pass. CLIK encodes the context with the frozen backbone itself and uses a Transformer that attends from the context to the adapter through cross-attention, generating the full set of LoRA weights jointly rather than fragment by fragment, so that dependencies across layers and modules are modeled as the knowledge is internalized. The generated adapter is inserted into the frozen model, which then answers from the query alone, without further access to the original context.

This design is particularly suited to multi-turn interaction, the setting where existing paradigms struggle most (Laban et al., 2026; Li et al., 2025b). Once a context is internalized into the adapter, it no longer has to occupy the input on later turns, and because the adapter depends only on the context, it is generated once and reused for every subsequent query on the same document, so the cost of reading that document is amortized across queries rather than paid again at each turn. CLIK therefore combines the immediacy of in-context learning with the persistence of parameterized knowledge.

Our main contributions are summarized as follows:

  • A context-to-adapter generator that internalizes knowledge jointly. We propose CLIK, which maps a context to a full LoRA adapter in a single forward pass via cross-attention over the backbone's all-layer representations. Unlike generators that emit weights as independent fragments, it models dependencies across layers and modules, internalizing a rich context into one coherent adapter with no test-time optimization.

  • Strong empirical results. On single-hop and multi-hop document question answering, CLIK substantially outperforms the no-context base model and prior hypernetwork-based generators, while remaining behind a base model with full context access, and it transfers to multi-turn dialogue without multi-turn-specific training.

  • Analysis of how context is internalized. Through intervention and distributional analysis of the generated adapters, we show that the context-dependent part of the adapter concentrates in a compact and specific substructure of the LoRA.

References (66)