Verace Episode
A one-shot episodic memory module for frozen causal language models, with surprise-gated hippocampal storage and phase-aware generation.
- CA3 Hebbian matrix: Stores each sparse code as a rank-1 outer product
- Surprise-gated storage: Writes only when surprise is high at the write phase
- kNN-LM logit biasing: Recalled content biases output logits, not the prompt
Overview
Verace Episode is an episodic memory module designed for any frozen HuggingFace causal language model; it leaves the model's weights unchanged and was tested with open models from other organisations: Qwen 2.5, Llama 3.2, Gemma 3 and SmolLM2. It addresses one question: can a pretrained model store a fact it has seen once and recall it later, with that fact kept outside the prompt? The lab's hard rules require that the base model's weights are never modified, that no sleep consolidation or LoRA adapters are used, that no external services are called, and that all learning is gradient-free and works with any model.
The system reads the hidden state at the middle decoder layer, layer , through a single forward hook. A working memory updates on every token. A hippocampus stores episodes one-shot: a dentate gyrus (DG) stage turns each input into a sparse code, and a CA3 stage stores codes as Hebbian outer products. Writes happen only when token surprise is high and a theta oscillator is near its write phase. Retrieval happens at the read phase. Recalled content reaches the model through a residual injection or through a kNN-LM bias on output logits, so memory text never enters the context.
The research implementation is a pure-PyTorch package. It includes the hippocampus, working memory, surprise and theta gating, a frozen BGE-small cue encoder from BAAI, tiered hot, warm and cold storage, and a two-phase generator for thinking models. Unit and integration tests cover it, with the integration tests running on real Qwen models. In a long-document benchmark the lab recorded recall@1 of 8/8 over a 100 MB arxiv corpus of 625,321 episodes, at about 0.7s per query. On question answering the evaluation records show the opposite: memory injection scored below both the plain model and retrieval in the prompt.
The memory stack, the phase-aware generation track (Track A) and the evaluation suite are implemented and tested. Recorded measurements exist for needle recall and for the MMLU and SciQ comparisons. The reasoning track (Track B) adds predictive-coding settling, conflict-driven depth and a goal stack. It exists as a design specification, together with source copied verbatim from Verace Neocortex, and is built only if de-risking diagnostics and a pre-registered statistical gate pass. A legal variant over federal law is a plan only. The question-answering deficit from memory injection is unresolved.
Status
Experiments. The memory module and phase-aware generation are implemented with unit and integration tests and recorded evaluations; the reasoning track and the legal variant exist only as designs.
Simulator
A row of tokens is read two ways at once: the newest token looks back at every earlier one, and every token is also written into one memory of fixed size that fades.
- looking back: one arc for every earlier token
- fixed memory: how much of each token it still holds
- newest token at the right
- Looking back, this token
- 23 comparisons
- Looking back, whole sequence
- 276 comparisons
- State kept: looking back / fixed
- 24 tokens / 1 state
- Fixed memory: a token is half faded after
- 4.3 tokens
Lengthen the sequence: the arcs multiply, the fixed memory stays one state. Lower the decay and it forgets sooner.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Frozen LM wrapper
FrozenLMwraps a HuggingFace causal model with frozen weights and registers a forward hook at the middle layer. The hook records the hidden state and adds an injection to the last token position.Hippocampus
Holds a frozen random DG sparse projection, a Hebbian CA3 matrix and an episode buffer. Read paths are CA3 pattern completion, attention read over stored values and cosine retrieval.
Working memory
NMDA persistent slots, a Tsodyks-Markram silent trace, a phonological loop and a prospective intentions buffer, combined by a
WorkingMemoryaggregator. All parts are frozen and run without gradients.Surprise and theta gating
Token surprise becomes a norepinephrine-like novelty signal that decides whether an episode is written. A theta oscillator assigns separate phases to writes and reads.
BGE-small cue encoder
A frozen BAAI bge-small-en-v1.5 sentence encoder that produces 384-dimensional normalised embeddings for retrieval. It is the only learned component that affects retrieval semantics, and it is a third-party model.
Tiered episode storage
Hot storage is the CA3 matrix on GPU. Warm storage is a FAISS HNSW index in RAM. Cold storage is sharded JSONL buckets on NVMe, addressed by DG hash.
Phase-aware thinking generator
Track A of the design. During the think phase it injects into hidden states, during the answer phase it applies only a logit bias, and it forces the think phase to close when the token budget runs out.
Auxiliary Verace Neocortex modules
Schema buffer, semantic memory, n-gram chunking, novel-word lexicalisation, claustrum binding, neuromodulator buses and five small hippocampal subsystems: entorhinal fusion, neurogenesis, time cells, retrosplenial rotation and a subiculum gate.
Evaluation suite A to F
Six evaluations run on a shared harness: multi-hop chains, TriviaQA, SciQ, needle-in-a-haystack, MMLU and conversational continuity. Each compares three conditions.
Reasoning track design
Track B specifies predictive-coding settling fused with memory, plus
SelfAssessment, a prefrontal goal stack, OFC value and a reasoning controller. The source modules are copied verbatim from Verace Neocortex.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- DG sparse coding with CA3 Hebbian store
- A frozen random projection followed by top-k selection turns each input into a sparse code. Because sparse codes overlap little, CA3 can store each one as a rank-1 outer product in a single shared Hebbian matrix and complete a pattern from a partial cue.
- Surprise to NE burst write gate
SurpriseTrackerkeeps a running EMA mean and variance of token negative log-likelihood and computes the z-score . A shifted sigmoid gives the novelty signal . The architecture writes an episode only when NE exceeds 0.5 and theta is near .- Theta phase separation
ThetaPhaseadvances by per step, where is the period. Encoding is assigned to phase and retrieval to phase , so reads and writes do not interfere.- kNN-LM logit biasing
MemoryLLMmoves the output distribution toward tokens found in retrieved chunks, so the retrieved text is never placed in the prompt. In thinking models this bias applies only in the answering phase, with a ramp that is re-anchored at the phase boundary.- Multi-probe LSH over DG signatures
DGHashStoreaddresses append-only JSONL buckets by the indices of the top-k active DG dimensions. To widen recall it also reads every bucket that shares of the query's active dimensions. Writes are buffered and files rotate.- Think and answer phase machine
PhaseTrackermoves through the states PRE_THINK, THINKING and ANSWERING by matching marker token-id subsequences, with a fallback scan. It rejects out-of-order markers and validates collisions with the end-of-sequence token. Whenmax_think_tokensis reached it forces a close and deduplicates the suffix.- EMA merge schema store
- The schema buffer either merges a new cue into the most similar slot with an exponential moving average or seeds a new slot. A cached normalised row stack gives O(1) append, vectorised cosine retrieval and in-place eviction of the weakest slot.
- Semantic prototype memory
SemanticMemorystores prototypes through frozen random encode and decode projections. An item whose cosine similarity to an existing prototype is above 0.8 is folded into that prototype as a running mean; otherwise it takes a new slot, subject to capacity eviction.- Two-system chunk formation
ChunkDetectorkeeps a formation counter of candidate n-grams and a recognition lexicon. An n-gram is promoted to the bounded LRU lexicon after it reaches a threshold count, following Miller's account of chunking.- Hebbian neuromodulator buses
- Buses for norepinephrine, acetylcholine and dopamine send signals to subscribers through sigmoid gains. The gains start near zero and are opened by a Hebbian reward rule.
- Claustrum binding buffer
- The claustrum module keeps an exponential moving average of the hidden state of the winning channel. This average serves as the bound, focused state.
- Trace-conditioned re-query
- During thinking, each new reasoning sentence is re-encoded with the BGE encoder. Its results are merged into a capped retrieval pool weighted by recency.
Results
From the lab's own experiments and records. They have not been independently replicated.
Needle recall at 625,321 episodes
In the lab's long-document benchmark on a 100 MB arxiv corpus of 625,321 episodes, recall@1 was 8/8, both in context and out of context, at about 0.7s per query.
Memory injection lowered MMLU accuracy
The evaluation records report MMLU accuracy of 42% with memory, 49.5% with RAG and 59% for the plain model.
Memory injection lowered SciQ accuracy
On SciQ the evaluation records report 35% with memory, 48.5% for the plain model and 51.5% with RAG. Memory scored lowest on both question-answering benchmarks.
Concepts
- Out-of-context memory
- Recall in which the remembered text is never placed in the prompt. It reaches the model only through hidden-state injection or a logit bias.
- Pattern separation
- Mapping similar inputs to sparse, low-overlap codes so that stored memories do not collide. The design contrasts this with dense embeddings in standard retrieval.
- Partial-cue completion
- CA3 auto-association lets an incomplete cue retrieve a whole stored pattern. Standard retrieval-augmented generation (RAG) instead needs a full query.
- Surprise-gated writing
- Only novel input is stored. The design contrasts this with standard RAG pipelines, which index everything.
- Three-way evaluation design
- Every evaluation compares the plain model, retrieved text placed in the prompt (RAG), and out-of-context memory through the kNN-LM bias.
- Track A and Track B
- Track A is phase-aware generation with no settling code and ships first. Track B adds predictive-coding reasoning and is built only after the diagnostics and the gate pass.
- Predictive coding settling
- Iterative, precision-weighted local Bayesian updates between layers, computed analytically without backpropagation. In the design the number of settling steps sets reasoning depth: one step for perception, more steps for reasoning.
- Conflict-driven adaptive depth
SelfAssessmentmeasures conflict as the variance across columns and sets settling steps. The design specifies a ladder of 1, 3, 5 to 7 and 10 steps for fast, standard, deliberative and stuck states.- Memory as a predictive-coding prior
- In the Track B design, the CA3 completion is added as a detached top-down input. Its gain is scaled by OFC coherence.
- Koechlin goal stack
- A four-level prefrontal goal hierarchy whose levels decay at different rates. It adds a top-down bias at each settling step and does not do processing of its own.
- Drift-diffusion decoder
- A Ratcliff-McKoon style decoder that maps 17 internal signals to 6 drift-diffusion parameters. It selects tokens with a collapsing threshold, and the first candidate to cross wins.
- De-risking diagnostics
- B1 tests whether settling refines or destroys the hidden state. B2 tests a conflict proxy against a negative log-likelihood baseline. B3 separates injection mechanics from retrieval quality.
- Pre-registered promotion gate
- Track B is admitted only after pre-registered contrasts, a sample size chosen by power analysis, Holm correction and reasoning-correct scoring.
- Legal memory variant
- A planned offline thinking model, Qwen3-1.7B from an outside developer, that reasons over the US Code, CFR and Supreme Court opinions held in episodic memory. Episodes would carry jurisdiction, citation and effective dates, and a citation verifier would mark each answer as verified, hedge or refuse.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.