The Synthetic Reasoning Engine for Continual AI Learning
Project description
NeuroSleepNet (V2)
The Synthetic Reasoning Engine for Continual AI Learning
NeuroSleepNet is a sleep-inspired memory layer designed to transform stateless LLMs into persistent, evolving agents. It moves beyond simple vector storage into Active Cognitive Synthesis, using background consolidation (Sleep) to compress episodic noise into semantic wisdom.
The 2-Line Magic
NeuroSleepNet is designed for zero-friction integration. You don't need to change your agent's logic.
import nsn
# Wrap any LLM function (Ollama, OpenAI, LangChain, etc.)
# nsn handles adaptive retrieval, storage, and re-ranking automatically.
agent = nsn.wrap(your_chat_function)
# Use your agent as normal — it now has "infinite" persistent memory.
response = agent("Remember that project I mentioned last week?")
V2: The Synthetic Reasoning Engine
V2 is a massive architectural upgrade focusing on high-fidelity memory and O(1) performance.
High-Performance Architecture
- ANN Matrix Cache: O(1) retrieval scaling using an in-memory embedding matrix. No more database bottlenecks for dense vector search.
- LRU Embedding Cache: 16,000x speedup for repeated/boilerplate content via MD5-keyed caching.
- Zero-Dependency Local Embeddings: Built-in
fastembedsupport for air-gapped, zero-ops deployments.
Advanced Cognitive Features
- Graph-Linked Expansion: Retrieval automatically explores semantic links created during synthesis, surfacing contextually related "Golden Facts" even when direct similarity is low.
- Greedy Centroid Synthesis: episodic memories are clustered by embedding similarity and synthesized into compressed, multi-fact Semantic nodes.
- Stage-2 Re-ranking: A secondary cross-scoring pass filters out keyword noise, ensuring only high-fidelity memories reach the model.
- Diminishing Returns Logic: Prevents "burst" accesses from artificially saturating memory importance, ensuring long-term stable recall.
Installation
pip install neurosleepnet
For full local-first (zero-ops) support:
pip install "neurosleepnet[local]"
Developer Guide
Initialization
import nsn
nsn.init(
project="coding-assistant",
mode="local", # local-first storage
synthesis_mode=True, # enable background cognitive synthesis
debug=False
)
Manual Memory Control
While wrap() is recommended, you can manage memory explicitly:
# Store a specific fact
nsn.remember("The user prefers FastAPI over Flask", importance=1.0)
# Retrieve with manual controls
mems = nsn.recall("Which framework does the user like?", top_k=3, min_score=0.5)
# Pin critical info (protects it from synthesis/pruning)
nsn.pin("API Key is XYZ-123", label="SENSITIVE")
The Sleep Cycle
NeuroSleepNet runs a background thread that consolidates memory. You can also trigger it manually:
# This runs clustering, Jaccard-dedup synthesis, and graph linking.
stats = nsn.sleep()
print(f"Consolidated {stats['summarized']} memories into semantic nodes.")
Performance Benchmarks
12-Turn Developer Onboarding Test
We conducted a rigorous multi-round comparison using llama3.2:1b (via Ollama). The test simulated a developer ("Priya") introducing a complex project ("DevMind") over several turns, followed by "trap" questions designed to test long-term recall.
The Test Methodology:
- Introduction: User introduces name, company, project name, and tech stack across 5 turns.
- Context Pressure: Middle turns introduce technical bottlenecks (latency, CPU/GPU trade-offs).
- Recall Check: Turns 6, 7, 8, 10, and 12 ask for specific facts buried in earlier turns.
Results:
| Metric | Without NSN | With NSN | Delta |
|---|---|---|---|
| Keyword Recall Rate | 18% | 43% | +25% |
| Latency Overhead | Baseline | -2.01s/avg | Optimization |
| Memory Accuracy | Hallucinated | Grounded | Significant |
Note: The negative latency overhead observed during testing is attributed to improved model focus and reduced token search space during generation.
Governance & Security
- Local-First Architecture: Your data never leaves your infrastructure unless you explicitly configure a remote provider.
- Project Scoping: Strict isolation between different agent identities or user projects.
- Immutability: Pinned memories are protected from the synthesis engine.
License
Distributed under the MIT License. See LICENSE for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neurosleepnet-2.0.1.tar.gz.
File metadata
- Download URL: neurosleepnet-2.0.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7868f0236cd42aaf5550c56d858d41843639863054880214205233ceebf6f3db
|
|
| MD5 |
b09e02e5c0dbd83f38988bc9da9b9ca6
|
|
| BLAKE2b-256 |
ae7c5298de9488bec52f3de84d7a4a815ab6b5852f665d21ced310e071241405
|
Provenance
The following attestation bundles were made for neurosleepnet-2.0.1.tar.gz:
Publisher:
publish.yml on avirooppal/NeuroSleepNet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neurosleepnet-2.0.1.tar.gz -
Subject digest:
7868f0236cd42aaf5550c56d858d41843639863054880214205233ceebf6f3db - Sigstore transparency entry: 1484959903
- Sigstore integration time:
-
Permalink:
avirooppal/NeuroSleepNet@7fd9cdc7fdb66bd0c7f9afee482cb9de0a63adf7 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/avirooppal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fd9cdc7fdb66bd0c7f9afee482cb9de0a63adf7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file neurosleepnet-2.0.1-py3-none-any.whl.
File metadata
- Download URL: neurosleepnet-2.0.1-py3-none-any.whl
- Upload date:
- Size: 609.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7f16f3d5bcaa908fd081b9855f44d1ac7d818e0ce5b8859f4f76430f679c8f4
|
|
| MD5 |
1f7b932b5393b3e2b7d7ae9de2044b83
|
|
| BLAKE2b-256 |
9e403805cb31b6b744afc25e67850d6eddb7af4e2d9b54396a4d5b84c65e894f
|
Provenance
The following attestation bundles were made for neurosleepnet-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on avirooppal/NeuroSleepNet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neurosleepnet-2.0.1-py3-none-any.whl -
Subject digest:
b7f16f3d5bcaa908fd081b9855f44d1ac7d818e0ce5b8859f4f76430f679c8f4 - Sigstore transparency entry: 1484959911
- Sigstore integration time:
-
Permalink:
avirooppal/NeuroSleepNet@7fd9cdc7fdb66bd0c7f9afee482cb9de0a63adf7 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/avirooppal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fd9cdc7fdb66bd0c7f9afee482cb9de0a63adf7 -
Trigger Event:
push
-
Statement type: