Preprint
Large Language Models

Doc-to-LoRA

Rujikorn Charakorn, Edoardo Cetin, Shinnosuke Uesaka, R. Lange
February 13, 2026arXiv.org27 citations

27

Citations

3

Influential Citations

arXiv.org

Venue

2026

Year

Abstract

Long input sequences are central to in-context learning, document understanding, and multi-step reasoning of Large Language Models (LLMs). However, the quadratic attention cost of Transformers makes inference memory-intensive and slow. While context distillation (CD) can transfer information into model parameters, per-prompt distillation is impractical due to training costs and latency. To address these limitations, we propose Doc-to-LoRA (D2L), a lightweight hypernetwork that meta-learns to perform approximate CD within a single forward pass. Given an unseen prompt, D2L generates a LoRA adapter for a target LLM, enabling subsequent queries to be answered without re-consuming the original context, reducing latency and KV-cache memory consumption during inference of the target LLM. On a long-context needle-in-a-haystack task, D2L successfully learns to map contexts into adapters that store the needle information, achieving near-perfect zero-shot accuracy at sequence lengths exceeding the target LLM's native context window by more than 4x. On real-world QA datasets with limited compute, D2L outperforms standard CD while significantly reducing peak memory consumption and update latency. We envision that D2L can facilitate rapid adaptation of LLMs, opening up the possibility of frequent knowledge updates and personalized chat behavior.

Analysis

Why This Paper Matters

Long-context processing remains a critical bottleneck for LLMs due to quadratic attention costs, making inference memory-intensive and slow. While context distillation (CD) offers a way to compress context into model parameters, per-prompt distillation is impractical because of high training costs and latency. Doc-to-LoRA (D2L) addresses this by introducing a hypernetwork that meta-learns to perform approximate CD in a single forward pass, generating a LoRA adapter for any given prompt. This is a significant step toward making context distillation practical for real-time applications.

The paper's approach is particularly relevant as LLMs are increasingly used for tasks requiring long inputs, such as document understanding and multi-step reasoning. By enabling rapid adaptation without retraining, D2L could reduce the memory footprint and latency of long-context inference, making it feasible to deploy LLMs in resource-constrained environments. The ability to generate adapters on-the-fly also opens up possibilities for personalized chat behavior and frequent knowledge updates, which are currently challenging due to the cost of fine-tuning.

Technical Contributions

  • Hypernetwork-based adapter generation: D2L uses a lightweight hypernetwork that takes an unseen prompt as input and outputs a LoRA adapter for a frozen target LLM. This avoids the need for per-prompt gradient-based optimization, enabling single-pass adaptation.
  • Meta-learning for approximate context distillation: The hypernetwork is trained to mimic the effect of context distillation, learning to compress the input context into adapter weights that store relevant information (e.g., needle in haystack).
  • Inference efficiency: By generating adapters that encode the context, D2L allows subsequent queries to be answered without re-consuming the original context, reducing KV-cache memory and inference latency.
  • Scalability beyond native context window: D2L demonstrates that generated adapters can store information from sequences longer than the target LLM's native context window, effectively extending its usable context length.

Results

On a long-context needle-in-a-haystack task, D2L achieves near-perfect zero-shot accuracy even when the sequence length exceeds the target LLM's native context window by more than 4x. This indicates that the hypernetwork successfully learns to map contexts into adapters that retain critical information. On real-world QA datasets, D2L outperforms standard context distillation while significantly reducing peak memory consumption and update latency. These results suggest that D2L is not only more efficient but also more effective than traditional CD, especially under limited compute budgets.

The paper does not provide exact numerical metrics in the abstract, but the qualitative claims are strong: near-perfect accuracy at 4x context length and superior performance on QA datasets. The reduction in memory and latency is highlighted as a key advantage, making D2L practical for deployment.

Significance

D2L represents a novel approach to context distillation that could transform how LLMs handle long inputs. By making per-prompt adaptation feasible, it enables frequent knowledge updates and personalized behavior without the overhead of full fine-tuning. This could lead to more responsive and context-aware AI systems, particularly in applications like chatbots, document analysis, and real-time decision support.

The broader impact extends to reducing the computational cost of long-context inference, which is a major barrier to scaling LLMs. If D2L proves robust across diverse tasks, it could become a standard component in LLM serving pipelines, enabling efficient handling of arbitrarily long contexts. The paper opens up new research directions in hypernetwork-based adaptation and meta-learning for efficient inference, potentially inspiring further innovations in model compression and on-the-fly personalization.