Papers
Topics
Authors
Recent
Search
2000 character limit reached

Doc2Atom: Compositional Memory for LLMs

Updated 4 July 2026
  • Doc2Atom is a compositional parametric memory framework that decomposes long documents into semantically typed knowledge atoms.
  • It compiles each atomic unit into micro-LoRA adapters using an end-to-end multi-objective distillation framework for efficient and selective query-based memory injection.
  • Doc2Atom enhances long-context processing by reducing GPU memory usage by 44% while mitigating irrelevant-query interference compared to monolithic document-level adapters.

Searching arXiv for the specified paper and the cited prior work to ground the article in the current literature. arXiv query: (Diao et al., 10 Jun 2026) Doc-to-Atom, abbreviated Doc2Atom, is a compositional parametric memory framework for long-context inference in LLMs. It is designed for settings in which long input sequences are central to document understanding and multi-step reasoning, but where the quadratic cost of attention makes inference memory-intensive and slow. The framework decomposes each document into semantically typed knowledge atoms, compiles each atom into an independent micro-LoRA adapter and a provenance retrieval key, and at inference time uses a lightweight query router to assemble a query-specific adapter that is injected into a frozen base model. The system is trained end-to-end through a multi-objective distillation framework and is presented in "Doc-to-Atom: Learning to Compile and Compose Memory Atoms" (Diao et al., 10 Jun 2026).

1. Position within context distillation

Doc2Atom is situated within the line of work on context distillation, in which long contexts are "written" into model parameters so that a frozen LLM can answer as if it had seen the full text at inference time. Standard context distillation requires expensive per-prompt fine-tuning. Doc-to-LoRA amortizes this procedure through a hypernetwork that maps any document DD to one low-rank adapter ΔWD\Delta W_D in a single forward pass, after which ΔWD\Delta W_D is applied to all queries about DD (Diao et al., 10 Jun 2026).

The central claim of Doc2Atom is that the monolithic structure of a single document-level adapter creates three specific limitations: irrelevant-query interference, limited compositional recall, and poor scalability. In the formulation given for Doc-to-LoRA, ΔWD\Delta W_D perturbs hidden states even for queries unrelated to DD; a single low-rank adapter cannot flexibly surface distinct facts; and ΔWD\Delta W_D has fixed rank rr regardless of ∣D∣|D|, so longer documents cannot be fully internalized. Doc2Atom addresses these constraints by replacing the monolithic adapter with a set of composable atomic memories.

This design reframes document internalization as selective composition rather than single-shot compression. A plausible implication is that the framework treats long-document reasoning less as a one-time summarization problem and more as a retrieval-and-assembly problem in parameter space.

2. Knowledge atoms and semantic factorization

The foundational object in Doc2Atom is the knowledge atom. Given an input document DD, the system first uses an LLM-driven annotation to factor ΔWD\Delta W_D0 into

ΔWD\Delta W_D1

where each atom ΔWD\Delta W_D2 is a minimal, self-contained semantic unit of information. The paper specifies five atom types: fact_claim, entity_attribute, event_relation, process_step, and evidence_fragment (Diao et al., 10 Jun 2026).

Formally, the decomposition is written as

ΔWD\Delta W_D3

where ΔWD\Delta W_D4 is the source span, and ΔWD\Delta W_D5 is the text of that span plus any necessary qualifiers. Each atom is also annotated with retrieval_text_i, a normalized anchor for retrieval, together with is_answer_bearing_i \in \{0,1\}, abstraction_level_i \in \{\text{abstract}, \text{evidence}, \text{hybrid}\}, conflict_group_i, confidence_i \in [0,1], and relations to other atoms.

These annotations give the atom a dual status: it is both a semantic unit for memory compilation and a typed retrieval object with provenance. The explicit inclusion of confidence, conflict grouping, and answer-bearing labels indicates that the atomization process is not merely segmentation. It is a structured representation intended to support routing, abstention, and controlled composition.

3. Memory compilation into micro-LoRA adapters

After decomposition, Doc2Atom compiles each atom independently. The framework shares the first ΔWD\Delta W_D6 layers of the frozen base LLM as an AtomEncoder ΔWD\Delta W_D7. For an atom ΔWD\Delta W_D8,

ΔWD\Delta W_D9

A MemoryCompiler consisting of an MLP trunk and four parallel heads then processes this embedding. With

ΔWD\Delta W_D0

the provenance key head produces

ΔWD\Delta W_D1

For memory injection, the micro-LoRA heads generate adapter factors for each target module ΔWD\Delta W_D2 in q_proj, v_proj, o_proj, and down_proj, and for each designated layer ΔWD\Delta W_D3:

ΔWD\Delta W_D4

These are produced by two linear heads,

ΔWD\Delta W_D5

ΔWD\Delta W_D6

with ΔWD\Delta W_D7 initialized to zero so that initially ΔWD\Delta W_D8. The atomic weight update is then

ΔWD\Delta W_D9

The framework also includes optional micro-KV prototypes for each atom, intended for prefix injection, and optional per-DD0 logits that yield a sigmoid gate DD1 (Diao et al., 10 Jun 2026).

The key architectural property is independence at compile time. Each atom yields its own retrieval key and low-rank perturbation, allowing subsequent query-conditioned composition. This differs materially from a document-level adapter because the atomic updates are designed to remain separable until routing.

4. Query routing, adapter composition, and end-to-end objectives

At inference time, Doc2Atom uses the same encoder to represent the query. Given query DD2,

DD3

and the query key is

DD4

The router scores all atoms by cosine similarity plus metadata bias:

DD5

where DD6 is a learned scalar bias for atom DD7 based on semantic type, confidence, answer-bearing flag, conflict group, and related metadata. Retrieval proceeds in two stages: first, the top-DD8 atoms by maximum inner-product search; second, an optional reranking of those DD9 atoms with a frozen cross-encoder to produce refined scores ΔWD\Delta W_D0. The final top-ΔWD\Delta W_D1 selected atoms ΔWD\Delta W_D2 receive normalized routing weights

ΔWD\Delta W_D3

(Diao et al., 10 Jun 2026).

Composition is performed separately for each layer ΔWD\Delta W_D4 and module ΔWD\Delta W_D5:

ΔWD\Delta W_D6

With element-wise gating,

ΔWD\Delta W_D7

where

ΔWD\Delta W_D8

the composed update is

ΔWD\Delta W_D9

This query-specific DD0 is then injected into the frozen base model.

Training is end-to-end and multi-objective. If DD1 denotes logits from feeding DD2 into the frozen LLM, and DD3 denotes logits from feeding only DD4 plus the composed DD5, the optimization includes:

  • language modeling,

DD6

  • distillation,

DD7

  • routing supervision with gold mask DD8 and higher DD9 for distractors,
  • irrelevant-query suppression,

ΔWD\Delta W_D0

  • knowledge protection,

ΔWD\Delta W_D1

  • sparse regularization with target density ΔWD\Delta W_D2,

ΔWD\Delta W_D3

  • composition consistency using a gold-atom set,

ΔWD\Delta W_D4

The full loss is

ΔWD\Delta W_D5

and optimization uses AdamW with cosine-decay, warm-up, and gradient clipping. A four-stage curriculum gradually increases ΔWD\Delta W_D6 and activates losses in dependency order: single-atom, multi-atom, robustness, and full.

5. Implementation profile and efficiency characteristics

The reported implementation details are given for a Gemma-2-2B-It run. The key hyperparameters are atom embedding dimension ΔWD\Delta W_D7, LoRA rank ΔWD\Delta W_D8, and ΔWD\Delta W_D9. The encoder uses rr0 layers, and memory is injected in the last rr1 decoder layers, specifically rr2–rr3. The router uses rr4, final rr5, and routing temperature rr6. Training uses batch size rr7, learning rate rr8, and rr9 (Diao et al., 10 Jun 2026).

For per-document internalization, the paper reports the following empirical compile-step resource usage on Gemma-2-2B-It:

Method GPU memory Compile time
Doc-to-LoRA ∣D∣|D|0 ∣D∣|D|1
Doc2Atom ∣D∣|D|2 ∣D∣|D|3

The stated scaling property is that memory scales with ∣D∣|D|4 rather than ∣D∣|D|5, so Doc2Atom reduces peak GPU memory by ∣D∣|D|6 at the cost of higher offline compile latency. This trade-off is important for interpreting the system correctly: it is not presented as an unconditional speedup. Rather, it exchanges slower offline compilation for lower peak memory during document internalization and more selective inference behavior.

6. Benchmarks, comparative results, and interpretive distinctions

The empirical evaluation compares five systems: Base+ctx, defined as a frozen LLM with full document in context and treated as an ICL upper bound; D2L_ckpt, the official Doc-to-LoRA checkpoint; D2L_raw, Doc-to-LoRA retrained on the reported datasets; D2L_atom, Doc-to-LoRA trained on atomized documents; and Doc2Atom (Diao et al., 10 Jun 2026).

The reported overall F1 scores on Gemma-2-2B-It and Qwen3-4B-Instruct are:

Model Gemma-2-2B-It F1 Qwen3-4B F1
Base+ctx 48.79 52.22
D2L_ckpt 37.93 18.70
D2L_raw 28.55 28.85
D2L_atom 29.41 29.30
Doc2Atom 37.99 35.72

Relative to the best D2L_atom baseline, Doc2Atom improves by ∣D∣|D|7 F1 on Gemma and ∣D∣|D|8 F1 on Qwen3. On the five in-domain QA sets—2WikiMultiHopQA, DROP, QASPER, ROPES, and SQuAD—Doc2Atom is described as competitive with full ICL and consistently above all D2L variants. In zero-shot generalization to eight LongBench subsets, it narrows the gap to ICL by up to ∣D∣|D|9 over D2L_raw and reliably refuses irrelevant queries, with refusal F1 DD0, whereas D2L fails to abstain.

Two distinctions are especially important for interpretation. First, atomization alone does not reproduce the reported gains: the D2L_atom baseline remains substantially below Doc2Atom on both backbone families. This suggests that the principal effect comes from query-conditioned retrieval and composition of micro-adapters, not merely from preprocessing the document into smaller units. Second, the refusal result directly addresses the irrelevant-query interference identified in the motivation. The framework is explicitly trained with an irrelevant-query suppression objective, so abstention is part of the design rather than an incidental by-product.

7. Conceptual significance and scope

Taken together, Doc2Atom advances parametric context distillation by introducing fine-grained, semantically typed atoms and by transforming document internalization into a compositional memory system that is selective, scalable, and trainable end-to-end (Diao et al., 10 Jun 2026). Its internal representation couples semantic decomposition, provenance-aware retrieval, and low-rank parameter injection, making it a hybrid of structured memory compilation and adapter-based conditioning.

Within the terms reported for the method, Doc2Atom is best understood neither as ordinary retrieval-augmented generation nor as a standard single-adapter distillation system. It does not simply retrieve source text into the prompt, because inference proceeds by composing atom-level parameter updates into DD1. Nor is it equivalent to a monolithic document adapter, because only a small subset of atoms is selected and assembled for a given query. A plausible implication is that the framework occupies an intermediate point between non-parametric retrieval and full parametric internalization, with provenance keys and atom composition providing the operative mechanism.

The reported limitations are also integral to its scope. The compile step is slower offline than Doc-to-LoRA, and the framework introduces a more elaborate decomposition, routing, and supervision pipeline. At the same time, the results indicate that this additional structure is associated with reduced peak GPU memory during internalization, stronger performance relative to Doc-to-LoRA baselines, and markedly better handling of irrelevant queries.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Doc-to-Atom (Doc2Atom).