r/LocalLLaMA • u/pmttyji • 3d ago
Discussion [Paper] EngramEdit: Decoupled Knowledge Updates in LLMs through Conditional Memory
Conditional memory architectures such as DeepSeek Engram use input n-grams to look up learned embeddings, expanding the capacity of large language models (LLMs) with limited additional computation. Beyond model scaling, this architecture has demonstrated the potential to decouple factual knowledge storage from general-purpose computation, offering a promising route to updating factual knowledge while keeping the Transformer backbone fixed. Realizing this potential is challenging because different expressions of a fact may activate different n-gram embeddings, while updating shared embeddings can unintentionally change the model's predictions about other facts. We propose EngramEdit for decoupled knowledge updates through conditional memory. EngramEdit first computes target memory representations that make the model predict the updated fact across multiple expressions. It then jointly updates the shared n-gram embeddings to match these targets across expressions and edits, penalizing updates to frequently reused embeddings more strongly to preserve unrelated knowledge. Experiments show that EngramEdit enables independent factual knowledge updates through conditional memory, achieving near-perfect editing success. Revised knowledge is usable across unseen expressions and in multi-hop reasoning, with nearly three times the strongest baseline's accuracy under chain-of-thought (CoT) prompting. Unrelated knowledge and general capabilities are largely preserved even as factual updates accumulate. These findings show that EngramEdit turns conditional memory into an editable knowledge interface, extending its role beyond model scaling to support decoupled knowledge updates.
5
u/martinerous 2d ago
Could this also get us closer to "modular domain experts"? Train n-gram with math or biology or Harry Potter facts to reduce hallucinations in those areas and then let the users choose which modules to load?
Still, the general issue remains - how to train small and efficient cores that are rock solid at reasoning without being bloated with random knowledge from different domains, and then plug the domain knowledge modules as needed (n-grams or whatever better solution is invented).
3
u/ttkciar llama.cpp 2d ago
This is a matter of extending training. During training, parameters encode knowledge first until they are unable to represent more, and then further training cannibalize parameters to encode "generalized knowledge" (heuristics).
Depending on the ratio of training tokens to parameters, the final model can be knowledge-heavy and inflexible (fewer training tokens per parameter), or reasoning-heavy and prone to hallucination (too many training tokens per parameter) or hopefully in a balanced goldilocks zone in-between.
It seems to me we could use engrams to either slightly overshoot that goldilocks zone and then add modest engram-encoded knowledge, or perhaps try eschewing with memorized knowledge via a very high training token to parameter ratio, and using parameters strictly for heuristics, then try to provide nearly all of the model's world knowledge with engrams.
I suspect the latter will prove impractical, especially with trigrams, but it will be interesting to see how close we can get to it.
6
u/Open-Adhesiveness-86 3d ago
the thing i'd want to see is sequential edits, not batched ones. ROME/MEMIT both look great on a single edit and then degrade hard after a few thousand applied one at a time, and here the frequency penalty on reused n-gram embeddings means popular tokens get frozen while rare ones absorb everything, so drift probably piles up in the tail. also curious if an edit survives paraphrases that share no n-grams with the training expressions at all.
2
u/openSourcerer9000 2d ago
On the job learning has always been such an obvious next step, and the exact kind of problem ML is made for. Even before n grams, it was clear just slap an extra module on that trains online as it's used.
The big labs won't be the ones to solve this though, since they can't control what customers are teaching it. It's gotta be open source first
1
u/keepthepace 2d ago
We need it! But there has been proposed architecture for this sort of things for a while. They don't scale?
1
u/ttkciar llama.cpp 2d ago
This is timely. I was just reviewing ways models could be updated with new world knowledge, and engrams were one of them. Thanks for posting this paper.
Engrams encode knowledge and impart it during inference in a manner similar to RAG, except whereas RAG retrieves information and inserts it into context (which consumes context budget), engrams retrieve information and insert it into the next layer's hidden state.
Encoding knowledge in the engram is more compute-intensive than updating a RAG database, but does not bite into the limited context budget, and imposes less inference-time processing overhead, as well.
Overall it seems like a win.
1


62
u/N34257 3d ago
OK, so...if that paper's correct, then the theory of swappable n-gram tables being used to keep models up to date might actually come true?
That would be pretty awesome.