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.
Metadata
Release files for neurosleepnet 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neurosleepnet-2.0.1.tar.gz | 1.1 MB | With provenance | Details for neurosleepnet-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neurosleepnet-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for neurosleepnet-2.0.1-py3-none-any.whl |
Total release size: 1.7 MB
Release files / neurosleepnet-2.0.1.tar.gz
| Download URL | neurosleepnet-2.0.1.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7868f0236cd42aaf5550c56d858d41843639863054880214205233ceebf6f3db
|
|
BLAKE2b-256 checksum How to use checksums |
ae7c5298de9488bec52f3de84d7a4a815ab6b5852f665d21ced310e071241405
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logRelease files / neurosleepnet-2.0.1-py3-none-any.whl
| Download URL | neurosleepnet-2.0.1-py3-none-any.whl |
|---|---|
| Size | 609.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7f16f3d5bcaa908fd081b9855f44d1ac7d818e0ce5b8859f4f76430f679c8f4
|
|
BLAKE2b-256 checksum How to use checksums |
9e403805cb31b6b744afc25e67850d6eddb7af4e2d9b54396a4d5b84c65e894f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logSecurity for neurosleepnet 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for neurosleepnet-2.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.