Dynamic Engram: Answering from an Exact n-gram Memory Injected at Inference Time

Instead of writing particular memories into a language model (by fine-tuning, model editing or optimized rows of an n-gram table), we train the model once to handle memories in general, and then inject any new memory on demand, with no training, no optimization and no change to the weights. Conditional memory through n-gram lookup (Engram, and the n-gram embeddings of recent open models) adds a cheap knowledge axis to transformers; its tables are learned in pre-training. Here there is no table at all. An unbounded store keeps every injected item as text and recalls the relevant ones by exact n-grams and by meaning; for each question, an exact count memory is built from the recalled items and reaches an off-the-shelf 350M-parameter multilingual model as its own token embeddings, read through Engram-style gates, and as candidates that a pointer copies at the output. The prompt holds the question alone. On memories from a life never seen in training, with the question alone in the prompt, the model answers 95.5% of associative questions correctly in the memories' language; without a memory the same data and steps give 2.7%, and with the memory emptied it answers nothing, so the facts come from the injected memory, not from the weights. The model generalizes to new memories, not yet to new forms of question (other phrasings, other languages). Against retrieval-augmented generation reading the same memories, it gives up about ten points, for a prompt two to four times shorter and an answer 1.5 to 2 times faster on two CPU threads; the gap lies mostly in questions asked in another language, while in the memories' language it is within a few points of RAG (95.5% against 100%). On Qwen3-0.6B-Base the search by meaning improves but reading transfers only in part. The model does not yet abstain when the answer is missing but similar memories are present, a gap we attribute to the training data. This is a demonstration of feasibility on small models; nothing in the method is tied to model size. This record contains the paper (PDF) and the code (library, training, evaluation and analysis scripts). The weights of the 350M model (safetensors, ONNX int8 and int4) are on Hugging Face: tetiai/dynamic-engram-350m. The training data is not distributed; it can be regenerated with the code from public datasets and synthetic memories.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-10-30
DOI
https://doi.org/10.5281/zenodo.23803702
Primary Topic
Topic Modeling
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
preprint

Dynamic Engram: Answering from an Exact n-gram Memory Injected at Inference Time

Lorenzo Nargiso, Marcello Violini
2 links
Zenodo (CERN European Organization for Nuclear Research)
Topic Modeling
preprint

Dynamic Engram: Answering from an Exact n-gram Memory Injected at Inference Time

Lorenzo Nargiso, Marcello Violini
preprint en

Abstract

Instead of writing particular memories into a language model (by fine-tuning, model editing or optimized rows of an n-gram table), we train the model once to handle memories in general, and then inject any new memory on demand, with no training, no optimization and no change to the weights. Conditional memory through n-gram lookup (Engram, and the n-gram embeddings of recent open models) adds a cheap knowledge axis to transformers; its tables are learned in pre-training. Here there is no table at all. An unbounded store keeps every injected item as text and recalls the relevant ones by exact n-grams and by meaning; for each question, an exact count memory is built from the recalled items and reaches an off-the-shelf 350M-parameter multilingual model as its own token embeddings, read through Engram-style gates, and as candidates that a pointer copies at the output. The prompt holds the question alone. On memories from a life never seen in training, with the question alone in the prompt, the model answers 95.5% of associative questions correctly in the memories' language; without a memory the same data and steps give 2.7%, and with the memory emptied it answers nothing, so the facts come from the injected memory, not from the weights. The model generalizes to new memories, not yet to new forms of question (other phrasings, other languages). Against retrieval-augmented generation reading the same memories, it gives up about ten points, for a prompt two to four times shorter and an answer 1.5 to 2 times faster on two CPU threads; the gap lies mostly in questions asked in another language, while in the memories' language it is within a few points of RAG (95.5% against 100%). On Qwen3-0.6B-Base the search by meaning improves but reading transfers only in part. The model does not yet abstain when the answer is missing but similar memories are present, a gap we attribute to the training data. This is a demonstration of feasibility on small models; nothing in the method is tied to model size. This record contains the paper (PDF) and the code (library, training, evaluation and analysis scripts). The weights of the 350M model (safetensors, ONNX int8 and int4) are on Hugging Face: tetiai/dynamic-engram-350m. The training data is not distributed; it can be regenerated with the code from public datasets and synthetic memories.

Zenodo (CERN European Organization for Nuclear Research)
Topic Modeling
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon
Dynamic Engram: Answering from an Exact n-gram Memory Injected at Inference Time — Lorenzo Nargiso, Marcello Violini · Zenodo (CERN European Organization for Nuclear Research) (2026) | TGRS Research Map | TGRS