Paper 105~8 min readDeepSeek · 2026
Paper Breakdown

Engram,
explained.

Ask a model to find one fact buried in a million tokens and attention has to weigh all million to answer — and the longer the haystack, the more the needle gets drowned out. Engram gives the model a different faculty: a memory it can address by key. Write a fact once, look it up in constant time, and it doesn't matter whether the context is a page or a library. Best of all, the model only reaches for it when it needs to.

Video breakdown
The animated walkthrough is in production.
Read the full breakdown below in the meantime ↓
01

The recall wall: attention dilutes

Softmax attention answers a query by spreading a fixed budget of probability across every token it can see. That's fine for a short context. But the needle-in-a-haystack test — hide one crucial fact in a long document and ask for it — exposes the flaw: as the haystack grows, the needle's slice of the attention budget shrinks, and it can get washed out by thousands of irrelevant tokens.

softmax recall: needle's weight ∝ 1 / (competing tokens)  →  grows the haystack, shrinks the signal

Two costs in one: you pay O(n) to scan everything, and the answer quality drops with length. Engram attacks the second one head-on.

02

A memory you address by key

Engram bolts a key-addressed memory onto the model — an associative store. To remember a fact, write it under a key. To recall it, present the key and read the value back in constant time. No scan, no dilution: the lookup cost is O(1), completely independent of how much context has streamed by.

Scan the whole context · or address the memory directly
Query "the code?"
Attention:
score all n tokens
O(n), dilutes
vs
Engram:
lookup(key)
O(1), exact
value
scan cost = n (grows)  ·  keyed lookup = 1 (constant, any n)

The store is the same associative-memory idea behind MemGPT and Titans — an explicit place to put facts so the attention window doesn't have to hold everything itself.

03

Conditional: pay only when you recall

The "conditional" in conditional memory is the second half of the trick. The model doesn't hit the memory on every token — most tokens only need their immediate neighbourhood. A lightweight gate predicts whether the current position actually needs a long-range recall, and only then does a lookup happen.

extra work = Σtokens gate(t)·1  →  local tokens gate=0 (free); recall tokens gate=1 (one O(1) hit)

So the memory adds a capability — perfect long-range recall — without adding a cost to the vast majority of positions that never needed it.

The key idea

Separate the two jobs attention was overloading: local mixing stays with attention; long-range fact retrieval moves to an addressable store that's exact and constant-time. The gate makes sure you only pay for retrieval on the rare tokens that ask for it.

04

Why the needle stops hiding: 84 → 97

Here's the payoff. Because a keyed lookup retrieves by identity, not by out-competing every other token, the needle-in-a-haystack score stops falling off with length. DeepSeek reports NIAH climbing from about 84.2 to 97 with Engram — the recall that softmax attention was quietly losing on long inputs, restored.

And it's why Engram underpins DeepSeek-V4: V4's hybrid attention makes the long context cheap, and Engram makes sure the model can still find things in it. Cheap plus accurate is what a usable million-token window actually requires.

05

Why it matters

Engram is part of a clear shift: stop asking a fixed attention window to be the model's whole memory, and give it an explicit, addressable place to store and fetch facts. It's the architectural cousin of the agent-memory patterns builders already use — MemGPT's tiered paging, Titans' surprise-gated writes, and the agent-memory playbook — but baked into the model instead of bolted on by a harness.

The broader lesson is that "long context" is really two problems wearing one name: the cost of a big window and the reliability of recall inside it. The 2026 frontier is solving them separately — sparse/linear attention for the first, addressable memory for the second — and Engram is the cleanest statement yet of the second half.

Read next

The model it powers: DeepSeek-V4. The surprise-gated cousin: Titans. The OS-style ancestor: MemGPT.

RUN IT YOURSELF

O(1) recall that doesn't care how big the haystack is

Engram's promise is checkable in a few lines. A key-addressed store retrieves a fact in constant time — 1 operation — while a linear scan pays n and grows with the context. Build a memory over a hundred-thousand-token haystack, drop in a needle, and watch the lookup find it at the same cost as if the haystack were empty. Then gate it: only the tokens that actually need a recall touch the memory at all.

CPython · WebAssembly
Frequently asked

Quick answers

What is Engram?

A conditional-memory mechanism (DeepSeek, 2026) that gives a transformer a key-addressed store: write a fact, retrieve it in constant time O(1) regardless of context length — reportedly lifting needle-in-a-haystack recall from ~84 to ~97, and underpinning DeepSeek-V4.

Why "conditional"?

A gate decides whether a position needs a long-range recall; only then is the memory consulted. Local tokens pay nothing, so the capability is added without a blanket cost increase.

Why does it fix long-context recall?

Softmax attention spreads its budget across all tokens, so a needle dilutes as the haystack grows. A keyed lookup retrieves by identity in constant time — recall quality is independent of context size.

How does it relate to V4 and Titans?

Engram makes V4's cheap million-token context also accurate. It's the same explicit-memory family as Titans (surprise-gated) and MemGPT (tiered) — an addressable store so a fixed window need not hold every fact.

Engram · DeepSeek-AI · 2026 · reported figures from the technical report · Vibe Engines · 2026
Finished this one? 0 / 108 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns