Spiking-neural-network substrate — Python bindings for the hebb Rust crate
Project description
Hebb
Pure-Rust spiking-neural-network substrate — embed-anywhere, with Python bindings.
hebb is the simulator substrate underneath the broader Hebb project: a fast, no-I/O-by-default Rust crate that implements the spiking-network primitives — neuron models, synapse models, plasticity, deterministic seed generators, and an optional on-disk format. The desktop app and visualizer consume this crate; you can also embed it directly in your own Rust or Python work.
What is this?
The hebb crate is two things at once:
-
A spiking-neural-network simulator you can drop into existing code. A
SimEnginestate machine youtickforward in time, with built-in neuron models (LIF, Izhikevich, AdEx, Hodgkin–Huxley) and plastic synapses (STDP, dopamine-gated R-STDP). No filesystem, no async runtime, no database — it's pure compute. If you do computational neuroscience, neuromorphic, or SNN research, this is a scriptable spiking substrate you can use today. -
The portable core of the larger Hebb cortex-mechanism project. The same crate is the seed of an event-driven, continually-learning AI substrate where neural networks are modules, not the core — see the umbrella project README.
Don't know what a "cortex" means in this context? Read it as a brain-inspired memory + compute substrate. The simplest useful form is a graph of neurons that learn from a stream of events — which is exactly what
SimEnginegives you.
Who is this for?
| You are… | Use hebb as… |
Start here |
|---|---|---|
| A computational-neuroscience / SNN / neuromorphic researcher | A fast, scriptable spiking-network simulator (Rust crate or import hebb_py from Python) |
Use as a library |
| A Rust developer integrating spiking models into a larger system | A pure-Rust, no-I/O crate that drops cleanly into anything (wasm, FFI, embedded sim, server) | Use as a library |
| A PyTorch / SNN-ML researcher | A fast event-driven runtime for inference / online learning, complementing surrogate-gradient training in snnTorch / Norse / BindsNET / SpikingJelly | Vision |
| A Hebb desktop / visualizer contributor | The substrate the app depends on. New neuron / synapse / format work lands here. | Repository layout |
Features
- Neuron models — LIF, Izhikevich, AdEx, Hodgkin–Huxley (with internal substepping for production
dt). - Plastic synapses — STDP and dopamine-gated R-STDP, with parameters streamable through the on-disk format.
- Deterministic seed generators —
random,ring,small-world,layered. Same seed → same network. - Embed-anywhere — pure-Rust, no I/O, no async runtime, no unsafe. WASM-ready. Filesystem support is opt-in behind the
diskfeature. - Python bindings —
import hebb_py; same engine, same domain types, same on-disk format.
Repository layout
src/— the Rust library (hebbcrate, published on crates.io).python/— PyO3 bindings, built with maturin and published ashebb-pyon PyPI. Python module name ishebb.tests/— integration tests against the public Rust API.SCHEMA.md— on-disk format spec for.cortex/folders (gated behind thediskfeature).
Use as a library
Install:
# Rust
cargo add hebb
# Python
pip install hebb-py
Both the PyPI distribution and the Python module are
hebb-py/hebb_py. The barehebbname on PyPI is taken by an unrelated astronomy package, andimport hebb_pyavoids colliding with it.
Drive the substrate from Python:
import hebb_py
sim = hebb_py.Sim()
a = sim.add_neuron()
b = sim.add_neuron()
sim.add_edge(a, b, weight=0.9)
sim.stimulate(a, current=50.0, duration_ms=30.0)
spikes = sim.run(dt_ms=1.0, n_steps=200) # -> [(neuron_id, t_ms), ...]
…or from Rust:
use hebb::SimEngine;
use uuid::Uuid;
let mut sim = SimEngine::new();
let a = Uuid::new_v4();
let b = Uuid::new_v4();
sim.add_neuron(a);
sim.add_neuron(b);
sim.add_edge(Uuid::new_v4(), a, b, 0.9);
sim.inject(a, 50.0, 30.0);
for _ in 0..200 {
let frame = sim.tick(1.0);
for event in frame.events {
println!("{} spiked at t={}ms", event.node_id, event.t_ms);
}
}
For the on-disk .cortex/ folder format (open the same network you build here in the Hebb desktop app's visualizer), enable the disk feature:
hebb = { version = "0.1", features = ["disk"] }
Vision
The computational-neuroscience and SNN ecosystem is already rich: PyTorch-based ML frameworks (snnTorch, BindsNET, Norse, SpikingJelly, Rockpool) train spiking networks with surrogate gradients; biophysical simulators (NEST, Brian2, NEURON, GeNN, Arbor) model networks down to morphology; neuromorphic platforms (Intel Loihi / Lava, SpiNNaker, BrainChip Akida, SynSense) run trained networks on event-driven hardware. Each of these is excellent in its niche, but they don't talk to each other, and very few of them ship as an embeddable, no-runtime-deps crate you can drop into a larger system.
hebb aims to be a lightweight, interchange-friendly runtime that complements those tools rather than competes with them. The roadmap (loose ordering, contributions welcome):
- PyTorch interop. Round-trip with snnTorch / Norse / SpikingJelly: train weights with surrogate gradients in PyTorch, export to
hebbfor sparse event-driven inference and online plasticity. Inverse path too — initialize ahebbnetwork from a.pthcheckpoint. - Model-description format support. Importers/exporters for NeuroML, SONATA (Allen Brain / BMTK), and (eventually) PyNN models. The goal is that a network defined for NEST or NEURON can run a sparse simulation under
hebbwithout rewriting. - Experimental-data ingestion. Stream NWB files into a stimulator so you can replay recorded spike trains against a learning network.
- Event-camera datasets. First-class support for DVS / N-MNIST / N-Caltech101 / DVS-Gesture so event-driven workloads are easy to wire up.
- Neuromorphic targets. Long-term: emit a
hebbnetwork to Intel Loihi (via Lava IR), SpiNNaker, or Akida. Short-term: keep the data layout and event-loop semantics close enough to those platforms that the mapping is mechanical. - More neuron and plasticity models. Multi-compartment neurons; e-prop / equilibrium-propagation rules; calcium-based plasticity; reward-modulated variants.
- Performance. SIMD-friendly batched ticking; GPU backend for dense-region simulation (likely via
wgpu); deterministic parallel ticking. - WASM. Run
hebbin the browser so the visualizer (and arbitrary educational toys) can simulate without a server.
If you maintain one of the ecosystem tools above and want to talk about interop, please open an issue.
Local development
# Rust
cargo test --features disk
# Python bindings (requires maturin)
pip install maturin
maturin develop --features pyo3/extension-module
python -c "import hebb_py; print(hebb_py.__version__)"
Contributing
CONTRIBUTING.md— workflow basics (coming soon).- PRs are welcome. Keep them small and single-purpose. New neuron models go in
src/domain/, new plasticity rules insrc/domain/synapse_plastic.rs(or a new sibling file).
License
hebb has an Apache 2.0 license, as found in the LICENSE file.
Project details
Release history Release notifications | RSS feed
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 hebb_py-0.1.0.tar.gz.
File metadata
- Download URL: hebb_py-0.1.0.tar.gz
- Upload date:
- Size: 137.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e837f9e0c0d053f5e74437e69e60009efa75b5989df1ae3ecb53969a109a5102
|
|
| MD5 |
dc25970fb1312f3515be7c12cee096cb
|
|
| BLAKE2b-256 |
c44b7b81fb9e9654f16a2d9171986a20d62ef2a3fb0e35afa539316ed5a5051d
|
File details
Details for the file hebb_py-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: hebb_py-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 398.8 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7016c5a2c3dcdcf4d8bbb353b213b9386009ddeecaa47b675ea8d44a4ac8b9
|
|
| MD5 |
bf2aeb2f4b13d2d02240db5581738c41
|
|
| BLAKE2b-256 |
78d70282445b9ec5b3a65a6fb821defbd113a8e843f706e4c852473828ee0e3b
|