Skip to main content

The Synthetic Reasoning Engine for Continual AI Learning

Project description

NeuroSleepNet (V2)

The Synthetic Reasoning Engine for Continual AI Learning

License: MIT Python 3.9+ Security: Passed Build: Passing

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 fastembed support 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:

  1. Introduction: User introduces name, company, project name, and tech stack across 5 turns.
  2. Context Pressure: Middle turns introduce technical bottlenecks (latency, CPU/GPU trade-offs).
  3. 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

neurosleepnet-2.0.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neurosleepnet-2.0.0-py3-none-any.whl (609.4 kB view details)

Uploaded Python 3

File details

Details for the file neurosleepnet-2.0.0.tar.gz.

File metadata

  • Download URL: neurosleepnet-2.0.0.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

Hashes for neurosleepnet-2.0.0.tar.gz
Algorithm Hash digest
SHA256 eaad4286a4740b46bf80fdacc85adab9c92f69655d64cc14cf24bb82df17e46e
MD5 03bbce6680e1ce4fceff3f3da1d9c89a
BLAKE2b-256 cfc16ebc42113ccd968538595b6e79cab9a978ff88fd93ed80a2149802ea4d45

See more details on using hashes here.

Provenance

The following attestation bundles were made for neurosleepnet-2.0.0.tar.gz:

Publisher: publish.yml on avirooppal/NeuroSleepNet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file neurosleepnet-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: neurosleepnet-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 609.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for neurosleepnet-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76207172435779d9d1b5f22340304ab510e28bd336061d9d2209e08890be7e68
MD5 dbd4f251f97f3534b3f62b4f46cfd096
BLAKE2b-256 79e56b56789a45fdd135261a5d9484a81ef216af3399e6215d96c83a04477d67

See more details on using hashes here.

Provenance

The following attestation bundles were made for neurosleepnet-2.0.0-py3-none-any.whl:

Publisher: publish.yml on avirooppal/NeuroSleepNet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page