Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Doc-to-LoRA: Learning to Instantly Internalize Contexts

About

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.

Rujikorn Charakorn, Edoardo Cetin, Shinnosuke Uesaka, Robert Tjarko Lange• 2026

Related benchmarks

TaskDatasetResultRank
Question AnsweringQASPER Long-doc
Gen-F127.03
26
Long-document and Multi-hop Question Answering2WikiMultihopQA
F1 Score50.39
10
Long-context UnderstandingLongBench 2WikiMQA
F1 Score36.48
10
Long-context UnderstandingLongBench TriviaQA
F1 Score85.99
10
Short-context Reading ComprehensionDROP
F1 Score30.66
10
Short-context Reading ComprehensionROPES
F1 Score65.9
10
Short-context Reading ComprehensionSQuAD
F1 Score73.2
10
Long-context UnderstandingLongBench HotpotQA
F1 Score26.79
10
Long-context UnderstandingLongBench MFQA-en
F1 Score26.69
10
Question Answering (Aggregate)Overall
F1 Score37.93
10
Showing 10 of 31 rows

Other info

Follow for update