🧠 CRAM-Net: Conversational Reasoning & Memory Network
“The Conversation is the Network” Part of the Memory-Native Neural Network Family
Origin of code: Base code written by Claude Sonnet; edited and tested by me.
🎯 Overview
CRAM-Net is a specialized evolution of the Memory-Native (MN) philosophy. While standard models treat conversation history as external text (KV cache), CRAM-Net treats the conversation as a physical catalyst for synaptic change.
In this architecture, remembering what was said is not about querying a database — it is about the network literally rewiring itself in real time through dual-track synaptic plasticity.
🧬 Unique Architecture: Dual-Track Plasti…
🧠 CRAM-Net: Conversational Reasoning & Memory Network
“The Conversation is the Network” Part of the Memory-Native Neural Network Family
Origin of code: Base code written by Claude Sonnet; edited and tested by me.
🎯 Overview
CRAM-Net is a specialized evolution of the Memory-Native (MN) philosophy. While standard models treat conversation history as external text (KV cache), CRAM-Net treats the conversation as a physical catalyst for synaptic change.
In this architecture, remembering what was said is not about querying a database — it is about the network literally rewiring itself in real time through dual-track synaptic plasticity.
🧬 Unique Architecture: Dual-Track Plasticity
CRAM-Net satisfies the MN Condition by using two distinct internal memory tracks.
🔹 Track 1: Rapid Plasticity (Chat Memory)
- Uses Hebbian Trace Neurons
- Updates weights (
dW) based on correlation between current and previous states - Allows the model to feel conversational context within its neurons
🔹 Track 2: Structural Plasticity (Reasoning)
- Uses Differentiable Logic Manifolds
- Identifies and hardens logical rules discovered during interaction
- Enables persistent reasoning structures beyond surface memory
🧠 Global Workspace Bottleneck
- Forces the high-dimensional hidden state through a narrow bottleneck
- Produces a compressed Thought Vector
- Encourages abstraction, reasoning, and memory efficiency
1. The Multi-Scale Memory Design
The CRAM-Net architecture is split into two parallel memory tracks that operate at different time scales, similar to how the human brain separates short-term working memory from long-term structural memory.
Track 1: Rapid Synaptic Plasticity (The “Chat” Layer)
Mechanism: Hebbian Trace Neurons
Logic: During conversation, the hidden state ( h_t ) correlates with the previous state ( h_{t-1} ). The synaptic weights update instantly based on this correlation.
Function: This track allows the network to remember:
- Your name
- The current topic
- Recent conversational context
All without relying on a traditional context window. Memory is stored directly in the synaptic tension of the weights.
Track 2: Structural Plasticity (The “Reasoning” Layer)
Mechanism: Differentiable Logic Manifolds
Logic: This track updates much more slowly and searches for mathematical invariants — patterns that remain stable regardless of topic changes.
Function: It builds a persistent logic map. When the system learns a rule such as:
A implies B
That relationship is hardened into the manifold and reused for future reasoning.
2. The Cognitive Bottleneck (Global Workspace)
A defining feature of CRAM-Net is that the hidden state does not flow directly to the output. All information must pass through a Global Workspace Bottleneck.
Compression
-
Observed compression ratio: 12.5%
-
Example:
-
64 neurons of raw thought
-
Compressed into 8 neurons of essential thought
Reasoning via Pressure
This forced compression creates cognitive pressure.
- The network must decide what information is essential
- This pressure activates the reasoning track
- Logical structure is required to fit complex data through a narrow channel
In short: compression triggers reasoning
3. The Mathematical Engine (cram-net.c)
The C backend enforces the Memory-Native (MN) Condition using a weight-update rule executed for every processed token.
[ W_{\text{new}} = W_{\text{old}} + \eta (h_t \otimes h_{t-1}) - \lambda W_{\text{old}} ]
Association Step
[ \eta (h_t \otimes h_{t-1}) ]
- Links the current thought to the previous thought
- Responsible for contextual continuity and memory formation
Decay Step
[ -\lambda W_{\text{old}} ]
- Prevents runaway memory accumulation
- Gradually removes old, irrelevant conversational noise
- Ensures long-term stability
4. Workflow of a Single “Turn”
When a user sends a message to CRAM-Net, the following pipeline executes:
Encoding The input message is converted into a vector representation. 1.
Resonance The vector interacts with the current weights. Since the weights were modified by previous messages, the network resonates with context. 1.
Plastic Update
The cram-net.c engine computes ( dW ) and rewires synapses in real time.
1.
Reasoning Loop The state cycles through the Logic Manifold until its internal energy stabilizes. 1.
Decoding The compressed Thought Vector is expanded back into a natural-language response.
🛠️ Performance & Evidence
Based on internal testing (see logs):
🔁 Self-Modification Rule
[ dW = \eta \cdot (h_t \cdot h_{t-1}^T - \lambda W) ]
⚖️ Dynamic Load Balancing
-
Automatically shifts:
-
~80% Chat Memory for simple conversation
-
~45% Reasoning for complex tasks
💾 Memory Efficiency
- High context retention with sparse weight updates
- Approximately 25–30% active synapses per interaction
🚀 Getting Started
1️⃣ Compile the C Backend
The core engine is written in C for maximum performance and direct memory manipulation.
# Windows
gcc -shared -o cram-net.dll cram-net.c -lm -O3 -fopenmp -static-libgcc -static
# Linux
gcc -shared -fPIC -o cram-net.so cram-net.c -lm -O3 -fopenmp
2️⃣ Use the CRAMNet Python Class
The CRAMNet class in cram-net.py is the primary interface. It handles the low-level pointer management for the C library while providing a high-level API for chatting and reasoning.
📂 Repository Structure
cram-net.c
High-performance C implementation of dual-track plasticity and weight-update logic.
cram-net.py
Python API and demonstration suite for chatting, reasoning, and thought compression.
LICENSE
GNU General Public License v3.0 (GPL-3.0)
USAGE.pdf
USAGE of cram-net.py, generated by Gemini.
🔗 The MN Family
CRAM-Net is a sibling project to the main Memory-Native Neural Network repository.
The main repository explores the following architectures:
- AMRC
- PMRC
- AMN
These models primarily focus on general sequence modeling.
In contrast, CRAM-Net is specifically optimized for:
- State-based conversational reasoning
- Live synaptic adaptation during dialogue
🧪 Experimental Architecture
Designed by: hejhdiss
If you found this interesting — ⭐ star the repository!