Hippocampal System
Relevant source files
The following files were used as context for generating this wiki page:
The Hippocampal System is the core cognitive engine of CORTEX, modeled after the mammalian hippocampal-cortical circuit. It manages how AI agents encode, differentiate, and retrieve memories by transforming dense vector embeddings into biologically-inspired sparse representations. This system prevents memory interference (pattern separation), detects new information (novelty detection), and completes partial queries into full memory patterns (pattern completion).
Sources: README.md, paper/drafts/cortex-v2-4-technical-note.md:16-25
Architecture Overview
The system consists of three primary sub-regions that map to specific neuroscience functions: the Dentate Gyrus (DG), CA1, and CA3. These components work together during both memory ingestion and retrieval to ensure high-fidelity memory management.
The diagram shows the dual pathways for memory ingestion (encoding/gating) and retrieval (pattern completion).
Sources: README.md, paper/drafts/cortex-v2-4-technical-note.md:43-69
Dentate Gyrus (Pattern Separation)
The Dentate Gyrus (DG) performs pattern separation by remapping similar inputs into nearly orthogonal sparse codes. This prevents the "every Tuesday meeting looks the same" problem by expanding the dimensionality of the input.
- Mechanism: It projects a 1024-dimensional dense embedding into a 4096-dimensional space using a deterministic random matrix.
- Sparsity: It applies k-winners-take-all (kWTA) rectification, resulting in 5% sparsity (~205 active indices per memory).
- Output: A
SparseCodeobject containing active indices and their values.
Sources: src/hippocampus/dentate-gyrus.ts, REFERENCES.md:9-16, paper/drafts/cortex-v2-4-technical-note.md:47-54
CA1 (Novelty Detection)
The CA1 region acts as a predictive-coding comparator. It scores every new sparse code against the existing memory store to determine surprise.
- Novelty Scoring: It compares the current sparse code against the most similar existing codes.
- Resonance Gating: High novelty scores increase the resonance floor, causing the memory to be stored at a higher priority.
- Efficiency: Redundant inputs (low novelty) are stored at reduced strength rather than being blocked entirely.
Sources: src/hippocampus/ca1-novelty.ts, REFERENCES.md:25-28, paper/drafts/cortex-v2-4-technical-note.md:56-61
CA3 (Pattern Completion)
The CA3 region provides autoassociative recall. When a query is partially matched, CA3 spreads activation through the memory synapse graph to retrieve the full pattern.
- Initial Activation: Pulls a top-20 set of memories based on sparse overlap with the query.
- Recurrent Spread: Performs two iterations of activation spreading through
memory_synapses. - Blended Search: The final activation vector is blended into the hybrid search score (weighted at 0.3).
Sources: src/hippocampus/ca3-pattern-completion.ts, REFERENCES.md:32-40, paper/drafts/cortex-v2-4-technical-note.md:63-69
Hippocampal Technical Specifications
| Component | Function | Dimension | Parameters |
|---|---|---|---|
| Dentate Gyrus | Pattern Separation | 4096-dim expansion | 5% sparsity (K=205) |
| CA1 | Novelty Detection | N/A | Surprise-gated priority |
| CA3 | Pattern Completion | N/A | 2 iterations, β=0.3 |
Sources: paper/drafts/cortex-v2-4-technical-note.md:47-69, README.md
Core Functions
The following functions in src/hippocampus/index.ts coordinate the system:
hippocampalEncode
This function executes the ingestion pipeline. It takes an agent ID, a dense embedding, and a base priority. It returns the generated SparseCode and the NoveltyResult which includes the adjusted priority and resonance score.
Sources: src/hippocampus/index.ts:35-75
sparseOverlap
Calculates the similarity between two SparseCode objects by measuring the intersection of their active indices.
Sources: src/hippocampus/index.ts:108-125
// Example of the SparseCode structure used across the system
export interface SparseCode {
indices: number[]; // Active neuron indices (0-4095)
values: number[]; // Activation strengths
dim: number; // Total dimension (4096)
}
Sources: src/hippocampus/index.ts:10-14
Conclusion
The Hippocampal System differentiates CORTEX from standard RAG pipelines by implementing biological memory principles. By using Dentate Gyrus expansion and CA1 novelty gating, the system ensures that AI agents can distinguish between similar events and prioritize new information, while CA3 pattern completion allows for intuitive, associative retrieval that goes beyond simple vector similarity.