How Does DeepSeek's Engram Memory Layer Work?

TL;DR
DeepSeek's Engram adds a third block to the transformer that retrieves stored representations from a huge hashed lookup table using the last two or three tokens as an address. This lets the model instantly recall common multi-token phrases instead of redundantly reconstructing their meaning across layers, introducing conditional memory as a new axis of sparsity alongside mixture-of-experts.
Transcript
When I thought I was finally used to how good DeepSeek is at publishing research, my mind has yet again been blown away with how insanely well-crafted this new paper is. Like, if you want to do good LM architectural research or just good ablazion studies, you should just get my video and straight up read the paper because there's just no way for me... Read More
Key Insights
- Engram is a new third block added to the transformer alongside attention and the feed-forward network, proposed in DeepSeek's paper 'conditional memory via scalable lookup, a new axis of sparsity for LMs.'
- The core problem Engram solves is redundant compute: a vanilla transformer must reconstruct a multi-token phrase's meaning at runtime every time that same pattern appears, since knowledge in the weights is not instantly retrievable.
- Conditional memory differs from conditional compute (mixture of experts): MoE selects which expert weights to run, while Engram selects which piece of stored information to fetch, so DeepSeek treats them as two distinct axes of sparsity.
- Engram uses a hashed lookup table that can be huge yet stays cheap and constant-time, because the phrase is mapped into a few slots rather than storing a one-to-one entry for every possible phrase.
- Engram operates in four steps: watch the token stream's local tail, use that short phrase as an address to pull vectors from memory, apply contextualized gating to filter the retrieved pattern, then fuse the feature back into the main stream.
- The contextualized gating mechanism uses the layer's hidden state to keep the gate open when a retrieved vector consistently helps in context and shut it when the vector is noise or clashes with context.
- Engram is trained end to end, so consistent gradient updates to repeatedly-visited deterministic slots make the stored vectors genuinely meaningful rather than noise at inference time.
- Engram already implements MHC (Multi-Head Contextualization) under the name multi-branch architecture, and the video frames Engram as the second fundamental architectural upgrade after MHC, likely to appear in DeepSeek V4.
Install to Summarize YouTube Videos and Get Transcripts
Explore YouTube Video Summarizer or Get YouTube Transcript Extractor
Questions & Answers
Q: What is DeepSeek's Engram?
Engram is a new component DeepSeek proposed in its paper 'conditional memory via scalable lookup, a new axis of sparsity for LMs.' It is added as a third key block inside the transformer alongside the attention block and the feed-forward network. Instead of reconstructing meaning at runtime, Engram retrieves stored representations from a large hashed lookup table based on the local multi-token pattern, then fuses that representation back into the main information stream so the model can continue as normal.
Q: How does Engram work at the technical level?
Engram repeatedly does four things. First, it watches the token stream and at every position looks at the local tail of the last two and three tokens. Second, it uses that short phrase as an address in a giant memory, hashing it into a few slots and pulling out the vectors sitting there. Third, a contextualized gating mechanism uses the layer's hidden state to check whether the retrieved pattern makes sense in context. Fourth, the feature is fused back into the mainstream and the transformer continues as normal.
Q: Why add a third block to the transformer when attention and feed-forward seem sufficient?
Even when knowledge lives in the weights, a transformer still has to reconstruct its meaning at runtime. When knowledge is spread across a few tokens, like a common phrase, boilerplate syntax, or formatting pattern, the model spends compute building a representation of that multi-token phrase before using it downstream. This process is redundant because the model redoes that feature construction every time the same pattern shows up. Engram lets the model instantly recall that representation instead, skipping the repeated reconstruction effort.
Q: What is the difference between conditional compute and conditional memory?
Conditional compute is short for mixture of experts, where you have a large pool of expert parameters for the feed-forward network and activate only a small subset for any given token. Conditional memory is Engram, where you selectively retrieve stored representations from a big lookup table based on the local multi-token pattern. DeepSeek argues they are different axes of sparsity: conditional compute is about which expert weights you run, while conditional memory is about which piece of stored information you fetch.
Q: How does the model learn to use Engram?
Engram is trained end to end, so the model picks it up based on how commonly certain multi-token patterns recur. Because the lookup is deterministic, the same patterns are repeatedly mapped into the same slots in the table. When those slots receive consistent gradient updates during training, the vectors stored within them start to become genuinely meaningful, so when retrieved during inference they are not complete noise. The gating mechanism similarly learns to open more often when a retrieved vector consistently helps.
Q: What does the contextualized gating mechanism do in Engram?
The gating mechanism takes the hidden state at that layer, which contains contextual information, and uses it as a filter to decide whether the retrieved pattern actually makes sense. If the retrieved vector is useless, or if it is meaningful but does not fit the current context, the gate makes the feature signal very weak. The gate learns a simple but powerful behavior: it opens more often when the retrieved vector consistently helps and learns to shut when the vector is noise or clashes with the context.
Q: Why does Engram matter for how large language models are optimized?
By cleanly separating conditional compute and conditional memory, a new way to optimize models emerges. You no longer have to dump your entire sparse parameter budget into experts and hope they learn everything. Instead you can allocate some of that budget to a memory pathway explicitly designed to handle the static lookup part of language, leaving the experts to fully do the thinking. In that framing Engram looks like a missing component that should always have been there.
Q: How does Engram handle a phrase like 'Diana, Princess of Wales'?
In a vanilla transformer, when the model reaches the token 'Wales' it does not instantly register the full meaning; it gradually composes it through layers of attention and feed-forward transformations, moving from Wales as a country to the actual person. With Engram, when the model gets the token 'Wales' it instantly recognizes it as a common phrase for a famous historical person, directly outputs that representation, and fuses it back into the main information stream, skipping the compute effort of piecing together that the multi-token phrase behaves like a single well-known entity.
Summary & Key Takeaways
-
DeepSeek's paper 'conditional memory via scalable lookup' introduces Engram, a third transformer block beside attention and the feed-forward network. Attention connects semantic meaning across tokens and the feed-forward network turns those relational signals into features, but both must reconstruct multi-token phrase meanings at runtime, which Engram aims to eliminate.
-
Engram distinguishes conditional memory from conditional compute. Mixture of experts activates a small subset of expert weights per token for context-dependent computation like reasoning, while Engram retrieves stored representations from a large hashed lookup table for fast recall of mostly static patterns, letting builders split the sparse parameter budget between thinking and lookup.
-
Technically Engram watches the local tail of two or three tokens, hashes that phrase into slots of a giant memory table, applies a contextualized gate using the layer's hidden state to filter the retrieved vector, then fuses it back. Trained end to end, frequently visited slots receive consistent gradients and become meaningful.
Read in Other Languages (beta)
Share This Summary 📚
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator
Explore More Summaries from bycloud 📚






Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator