AtlasKV fits 1B KG triples into an LLM under 20GB; KBLaM passes 40GB at 100K

AtlasKV: Augmenting LLMs with Billion-Scale Knowledge Graphs in 20GB VRAM

Haoyu Huang, Hong Ting Tsang, Jiaxin Bai, Xi Peng, Gong Zhang, Yangqiu Song

ICLR 2026

cs.CL, cs.AI

2025-10-20

AtlasKV encodes each KG triple as a key-value pair, prunes keys in three layers, and fits 1B triples into an LLM under 20GB. KBLaM exceeds 40GB at 100K.

What problem this solves

External knowledge for an LLM is usually retrieval-augmented generation: search, then paste the hits into the prompt. At a billion triples the search is expensive, and the pasted text stretches the context. Adapters such as LoRA skip the retriever, but every new knowledge batch means another training run.

KBLaM encodes a knowledge base as key-value vectors and adds them inside self-attention, so a new base does not require retraining. Two gaps remain. Training needs query-key-value sentences synthesized from documents with a fixed schema, so the questions are repetitive and travel poorly out of domain. Cost also grows linearly with the number of entries, and linear is still too steep once the base is huge.

Method

AtlasKV, from HKUST and Huawei, keeps that injection pattern. The backbone is frozen LLaMA3.1-8B-Instruct. The only trained weights are knowledge-side projections: the query head starts from the model's own WQ, and the key and value heads start at random. A new graph does not touch those heads. Triples are embedded offline and attached later. The attention output mixes two softmaxes, one over the knowledge values and one over the prompt tokens. The mix weights are the share of each side's exponentiated logits, so the model can lean on the graph or on the prompt at each token.

KG2KV turns a triple, head, relation, tail, into a key and a value attention can compare. Mask the head or the tail and treat the masked entity as the value. The other entity, plus the relation rewritten as a noun, is the key. Mask the tail of a because-triple and the relation becomes cause, so the key reads like the cause of followed by the unmasked side. Questions are not hand-written schemas. A prefix such as What is or Tell me is attached to the key, so the model does not memorize one phrasing. Named entities are used more often as keys, event descriptions as values. On Pes2o at 10K triples, without pruning, keeping both gives ACC@1 of 47.3. Named entities alone fall to 9.1, events alone to 3.6. Event strings are long on both sides, so the new heads struggle to learn them. Named strings are easier, and still not enough alone. A sentence encoder compresses the strings. Grounding runs use all-MiniLM-L6-v2, dimension 384. Generation runs use text-embedding-3-large, dimension 3072. Diversity, unique enquiry attributes divided by the number of triples, rises from 0.003% for schema synthesis to 7.864%. Average tokens per triple fall from 349.9 to 165.7. GPT-4o-mini rewrites the relations.

A question needs only a few triples. The rest add noise. HiKVP prunes on that basis. Keys are reduced with UMAP and clustered by a Gaussian mixture into three layers. An upper-layer key is a pool of the keys below it, and each layer uses a cluster size near the cube root of the triple count, so the work is spread out. At inference the GPU holds only the coarsest keys. Attention against the question keeps the top 128, which map to the middle layer. The middle layer keeps 64. The leaf layer keeps 16 values that enter generation. Everything else stays on CPU. Knowledge is injected every 3 attention layers. Injecting every layer, or only every 10, is worse. Time and memory move from linear in the number of triples to proportional to the cube root.

The heads never see a billion triples in training. The set is 20K triples from ATLAS-Wiki, a graph of about 1.492 billion triples, 900 million-plus nodes, and 5.9 billion edges. Training is AdamW for 3,000 steps, batch size 10, learning rate cosine-decayed from 1e-3 to 1e-5. The largest graph in one training step has about 120 triples. Embeddings are precomputed. Runtime only projects them. Nothing is pruned during training, because the heads are not fit on a giant graph.

Results

Total GPU memory is measured from 1 triple to 1 billion. AtlasKV augments the model with 1B triples in under 20GB, only slightly above zero-shot generation. KBLaM exceeds 40GB at 100K triples. In-context learning that pastes the triple text needs more than 48GB past 100 triples, so it does not run on the same 48GB card. All runs are single-GPU bfloat16.

Grounding accuracy is Top-1 and Top-5 of the knowledge-side attention at layer 15 of 32, the layer KBLaM uses to test whether the right entry was selected. AtlasKV is trained for 3,000 steps with all-MiniLM-L6-v2. The KBLaM column is the better of its 3,000-step and 20,000-step runs.

SetScaleAtlasKVNo pruningKBLaM
Enron ACC@110K21.827.39.1
Pes2o ACC@110087.392.725.5
Pes2o ACC@110K16.447.30.0
Pes2o ACC@510K49.067.25.5
CC ACC@110K40.061.83.6

Pes2o has messier questions, and KBLaM falls apart there: 25.5 at 100 triples, 0.0 Top-1 at 10K. AtlasKV still scores 16.4, and 49.0 at Top-5. Pruning is costly on the large set. The same Pes2o cell is 47.3 without it. Enron is easier. At 10K the drop is 27.3 to 21.8.

GPT-4o scores answer relevance from 0 to 1, over 5 seeds and 5 judgments each. In-context learning can clear 0.9, then stops once the triples no longer fit. AtlasKV scores above KBLaM. The paper does not print the exact point values. On questions whose answers exist only in the larger graph, the reported GPTScore moves from 10.8 to 46.4 on ATLAS-CC and from 13.6 to 50.7 on Pes2o, when the graph grows from 100 triples without the answer to 10K triples that contain it.

Why it matters

After one training run, a new graph is an encoding and clustering job. Inference ships keys to the GPU in proportion to the cube root of the graph, with no external retriever and no long retrieved prompt. For a billion-triple store that has to stay near 20GB total, this is a design that actually publishes that memory curve.

The gap versus KBLaM comes from where the questions come from, and from pruning at inference. A bigger encoder does not explain it. On small graphs, in-context learning still writes the more relevant answer. ICL stops fitting at about 100 triples. KBLaM passes 40GB at 100K. Past that point, the run that still sits near 20GB is AtlasKV.

Limitations

Each triple becomes an isolated fact, so multi-hop paths on the graph are gone. Fetching a few entries at each generation step only patches that. Raising the root-layer top-k helps retrieval. Raising it too far in the middle or leaf layer passes noisy keys downward. CPU-GPU transfers have a bill: at 10K triples AtlasKV averages 6.21 seconds, against 2.09 seconds with pruning off. At that scale memory goes down and latency goes up. Transfer cost at 1B triples is not measured.

Accuracy tables stop at 10K. On Pes2o, Top-1 falls from 90.0 at 10 triples to 16.4 at 10K. Nothing says the pointer still works at 1B. The tests are mostly out-of-domain slices of the ATLAS family, plus Enron, not a standard KGQA benchmark. An attention hit and a correct answer are different measurements, and the second one is a GPT-4o score. The only backbone is this 8B model. With text-embedding-3-large and 10K training steps, Enron at 10K triples gives AtlasKV an ACC@1 of 19.0 and KBLaM 20.7. Rewriting every relation across a billion triples is a token bill the paper treats as an accuracy-cost tradeoff. How long UMAP plus clustering takes on a billion keys is not reported.

Terms

Source

What people are saying

Related papers

All paper explainers