Manuscript Offprint

arXiv:2610.24107

Cache2LoRA: Understanding and Improving Context Internalization

Yi Fang, Gaurav Srivastava, Zhenyu Bi, Sirui Ding, Xuan Wang

Abstract

Context-to-LoRA methods encode documents as low-rank parameter updates, allowing language models to answer without retaining the source text in their decoding context. How reliably do these updates preserve facts and support their use under different instructions? Controlled diagnosis of existing context-to-LoRA methods separates fact discrimination, target retention, and response adaptation. Competing sources influence answers, while target-only construction and memory-state optimization improve recovery at fixed update size. Recovering facts also does not ensure that answers follow response instructions. We introduce Cache2LoRA, which uses each query to aggregate evidence from a reusable frozen document cache before generating LoRA updates. Trainable encoding operates only on the query and memory-token suffix, and multistyle supervision teaches both evidence preservation and answer expression. Across 17 tasks, Cache2LoRA improves on existing context-to-LoRA methods and achieves macro F1 of 0.663, approaching full-context in-context learning at 0.671. For 32K documents and 256-token outputs at batch size 16, its decoding throughput is 5.9×5.9 \times that of full-context ICL. At matched memory size, generated LoRA preserves answer accuracy more reliably than the learned-KV variant under long, diverse intervening text and combines more effectively with retained document KV, yielding higher hybrid F1 and EM.

1 Introduction

Parameter memory represents document information as weight updates rather than additional tokens in the answering context. Recent writers generate LoRA updates in a forward pass, avoiding per-document gradient optimization (Charakorn et al., 2026; Liu et al., 2026). This offers a way to carry document information into the model's computation without attending to document positions during decoding. Can these generated updates preserve the right facts and support their use under different response instructions?

We diagnose D2L and SHINE along three dimensions: fact discrimination, target retention, and response adaptation. Our source-substitution experiments link borrowed answers to competing facts. When we restrict writing to the passage relevant to the question, factual recovery improves without increasing the update size. Optimizing the writer's memory states also improves recovery at fixed output size. These controls suggest that the difficulty lies partly in determining which information to write, beyond how much the update can hold. We also find that D2L can recover reference content without adopting the requested answer form. Effective internalization requires selecting relevant facts and learning to express them as instructed.

For fact selection, the query supplies information that document-only writers lack: what the reader needs from the document. This motivates using the query during writing, but the resulting construction cost must be paid for every question. Within parameter memory, Doc-to-Atom enables query routing but requires semantic decomposition and compilation into LoRA units beforehand (Diao et al., 2026). AAG first generates a synthetic document and uses it with the query to produce adapters, coupling parameter construction to an additional context-generation stage (Liao et al., 2025). Activation-based compressors instead produce compact embeddings or KV states. OSCAR, QGC, and ATA-Compressor jointly encode document content with each query, repeating document encoding when another question concerns the same source (Louis et al., 2025; Cao et al., 2024; Li et al., 2025a).

We propose Cache2LoRA, which generates query-specific LoRA directly from a reusable cache of the supplied document. A frozen backbone prefills the document once, without semantic atom-

∗^{*}Corresponding author: xuanw@vt.edu.

ization or synthetic-context generation. For each question, trainable encoding acts only on the query and appended memory tokens, aggregating relevant information without re-encoding the document. A generation head converts these states into LoRA updates for the answerer. Multi-style teacher supervision supports both factual recovery and varied response instructions, while a retention objective limits interference on unrelated inputs. New documents and queries require no gradient optimization.

Across 17 tasks, Cache2LoRA reaches macro F1 of 0.663, approaching full-context ICL's 0.671, and improves on released D2L, Cache2LoRA-TF, and further-trained D2L. Cached construction avoids repeated document encoding. For 32K documents and 256-token outputs at batch size 16, decoding throughput reaches 5.9×5.9\times that of full-context ICL. Generated LoRA also shows two advantages over directly using the learned memory tokens as KV states at matched memory size. First, it preserves answer accuracy more reliably under long, diverse intervening text, keeping query-specific document memory usable after construction. Second, it complements retained document KV more effectively, yielding higher hybrid F1 and EM across both selectors and all tested budgets.

References (92)