Metadata-Version: 2.4
Name: nssn
Version: 1.5.1
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: fastapi
Requires-Dist: httpx
Requires-Dist: httpx2
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: zstandard
Summary: Neuromorphic Symbolic Spiking Network
Keywords: 
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# NSSN: Neuromorphic Symbolic Spiking Network

[![PyPI version](https://img.shields.io/pypi/v/nssn.svg)](https://pypi.org/project/nssn/)
[![Python versions](https://img.shields.io/pypi/pyversions/nssn.svg)](https://pypi.org/project/nssn/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Rust](https://img.shields.io/badge/Rust-2024_Edition-orange.svg?logo=rust)](https://www.rust-lang.org)
[![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey.svg)]()

**NSSN** (*Neuromorphic Symbolic Spiking Network*) is a high-performance, backpropagation-free neuromorphic learning and symbolic reasoning library.

Developed at the **CIAD Laboratory** (*Laboratoire Connaissance et Intelligence Artificielle Distribuées*), NSSN constructs an evolving, interpretable directed graph of neurons and synapses in real time using biological Spike-Timing-Dependent Plasticity (**STDP**) and asynchronous event-driven dynamics.

## Installation

Install the pre-compiled binary wheel directly from PyPI (requires Python $\ge 3.10$):

```bash
pip install nssn
```

## Quick Start

### 1. Basic Training & Graph Evolution

```python
from nssn import NssnModel, TrainingStrategy

# Initialize model instance
model = NssnModel("LanguageModel")

# Train on a text sequence (tokens create input and composite fusion neurons)
model.train("knowledge discovery in distributed systems", strategy=TrainingStrategy.STANDARD)

print(f"Total neurons: {model.size}")
print(f"Total synapses: {len(model.link_strength)}")

# Inspect a specific concept neuron
idx = model.get_neuron_index("knowledge")
if idx is not None:
    print(f"Label: {model.labels[idx]}, Rank: {model.ranks[idx]}, Fires: {model.fire_counts[idx]}")
```

### 2. Excited State Training Strategy

The `EXCITED_STATE` strategy activates a subnetwork around active concepts, reinforcing contextual associations:

```python
from nssn import NssnModel, TrainingStrategy

model = NssnModel("ExcitedModel")

# Restrict learning to a specific vocabulary set
vocabulary = {"autonomous", "agent", "planning", "decision"}
model.train(
    "autonomous agent planning decision",
    strategy=TrainingStrategy.EXCITED_STATE,
    token_set=vocabulary,
)
```

### 3. Topological Reasoning & Shortest Paths

Navigate semantic paths between concepts using built-in graph algorithms:

```python
from nssn import NssnModel
from nssn.model.tools import graph_tool

model = NssnModel("PathModel")
model.train("robot moves forward then turns right and reaches target")

# Find shortest path between source and destination
path = graph_tool.get_shortest_paths_str(model, "robot", "target")
print("Shortest path:", " -> ".join(path) if path else "No path found")
```

### 4. Fast Compressed Serialization (`.arcz`)

Save and reload large topologies in milliseconds using native Zstandard compression:

```python
from nssn import NssnModel

model = NssnModel("MyModel")
model.train("data to preserve")

# Save compressed binary model
model.save_zstd("model.arcz")

# Reload instantly into a new instance
loaded_model = NssnModel.load_zstd("model.arcz")
assert loaded_model.size == model.size
```

### 5. Synaptic Pruning & Memory Consolidation

Prune inactive or low-strength synapses to keep the network sparse and optimized:

```python
from nssn import NssnModel

model = NssnModel("PrunableModel")
# ... train on streams ...

# Prune inactive neurons and compact memory
removed_count = model.pruner().prune_inactive_neurons()
print(f"Pruned {removed_count} inactive neurons.")
```


## Affiliation

**NSSN** is researched and developed at the **CIAD Laboratory** (*Laboratoire Connaissance et Intelligence Artificielle Distribuées*), **Université Bourgogne Europe**, France.


## License

This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.

