Metadata-Version: 2.4
Name: synapto-llm
Version: 0.2.0
Summary: Synaptic Weight Eviction engine for dynamic LLM memory consolidation
Home-page: https://github.com/Bodya3101/synapto
Author: Bodya
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0.0
Requires-Dist: transformers>=4.40.0
Requires-Dist: bitsandbytes>=0.43.0
Requires-Dist: safetensors>=0.4.0
Requires-Dist: accelerate>=0.28.0
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Synapto
[![PyPI Version](https://img.shields.io/pypi/v/synapto-llm?style=for-the-badge&color=CB3153)](https://pypi.org/project/synapto-llm/)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](https://lbesson.mit-license.org/)

**Synaptic Weight Eviction (SWE) Engine for Dynamic LLM Memory Consolidation**

`synapto` is a PyTorch-based framework implementing native online memory consolidation for Large Language Models. Instead of relying indefinitely on expanding KV-caches, `synapto` catches evicted token blocks during generation, calculates their surprisal, and consolidates high-value information directly into a unquantized dynamic memory layer (top 10-15% of weights) using micro-backpropagation.

## Key Features

* **Synaptic Weight Eviction (SWE):** Automatically converts evicted context tokens into persistent model weight updates.
* **Plasticity Parameter (P):** Directly controls learning rate and surprisal threshold (-1.0 = Frozen/Inference, 2.0 = High Absorption).
* **Target Loss Masking:** Prevents prompt contamination and preserves standard language capabilities.
* **Replay Buffer Protection:** Mitigates catastrophic forgetting during sequential memory updates.
* **Zero-Trust Security:** Memory profiles are saved exclusively in `.safetensors` format with strict path validation.

## Installation

```bash
pip install synapto-llm
```

## Quick Start

```python
from synapto import SynaptoEngine

# Initialize SWE engine for Qwen 2.5 7B with Plasticity P = 1.5
engine = SynaptoEngine(
    model_id="Qwen/Qwen2.5-7B-Instruct", 
    p_value=1.5, 
    dynamic_layers=4
)

prompt = "Secret passcode for NervOS core:"
completion = " 8821-NERV-PRO."

# Consolidate fact into dynamic weights upon context eviction
engine.consolidate(prompt, completion)

# Generate response purely from updated model weights (no KV-cache used)
response = engine.generate_response(prompt)
print(response)

# Export dynamic memory weights (approx. 200 MB)
engine.save_memory_profile("user_memory.safetensors")
```

## Architecture

* **Static Base (80-90%):** Quantized to 4-bit NF4 to minimize VRAM.
* **Dynamic Memory (10-20%):** Kept in native FP16 to allow real-time micro-backprop.
