Skip to main content

A bio-inspired Spiking Neural Network engine with Hugging Face-like pipeline APIs (CPU-only, Backprop-free).

Project description

SARA Engine

SARA (Spiking Architecture for Reasoning and Adaptation) Engine is a cutting-edge AI framework that bridges the gap between biological intelligence and modern artificial neural networks.

It provides a highly efficient, event-driven Spiking Neural Network (SNN) core accelerated by Rust, combined with an intuitive PyTorch-like API. SARA goes beyond standard deep learning by natively supporting biological mechanisms such as NeuroFEM, Predictive Coding, and Hippocampal-inspired memory systems.

🧠 Key Features

  • High-Performance Event-Driven Core: Rust-based SNN simulation engine that minimizes computational overhead and maximizes simulation speed.
  • PyTorch-like API (sara_engine.nn): Build, train, and deploy complex spiking networks using familiar, modular, and declarative syntax.
  • Advanced Biologically-Plausible Mechanisms: * Hippocampal Memory System: Long-Term (LTM) and Short-Term (STM) memory supporting Million-Token contexts and SDR (Sparse Distributed Representations).
    • Synaptic Plasticity: Native support for STDP (Spike-Timing-Dependent Plasticity) and Reward-Modulated STDP (R-STDP).
  • Spiking LLMs & Transformers: Innovative spike-based attention mechanisms and fully operational Spiking Language Models.
  • Function Calling (Agentic SARA): Capable of emitting specific spikes (e.g., <CALC>) to trigger and integrate external Python tools.

🚀 Installation

Ensure you have Python 3.10 or higher and a working Rust toolchain installed.

# Clone the repository
git clone [https://github.com/matsushibadenki/sara-engine-project.git\](https://github.com/matsushibadenki/sara-engine-project.git)
cd sara-engine-project

# Install the package in editable mode (compiles the Rust core automatically)
pip install -e .

(Note: If changes to the core are not reflecting, ensure you re-run pip install -e . to rebuild the Rust extensions.)

💬 CLI Tools & Instruction Tuning

SARA comes with built-in CLI tools to easily interact with and train the engine on custom dialogue data without heavy GPU resources.

Interactive Chat

Start an interactive chat session using the distilled SNN model:

sara-chat --model models/distilled_sara_llm.msgpack

Instruction Tuning (Training)

You can easily fine-tune or override SARA's personality and knowledge using a simple JSONL file.

sara-train data/chat_data.jsonl --model models/distilled_sara_llm.msgpack

JSONL Data Format Example (chat_data.jsonl):

Each line should be a JSON object containing user and sara (or assistant) keys.

{"user": "こんにちは", "sara": "こんにちは!SARAです。何かお手伝いしましょうか?"}
{"user": "SARAって何?", "sara": "私はスパイキングニューラルネットワークで動くローカルAIエンジンです。"}

🌐 Integration Examples

SARA's lightweight CPU inference makes it perfect for integrating into modern web frameworks and bots.

1. FastAPI Integration

Serve SARA via a REST API:

from fastapi import FastAPI
from pydantic import BaseModel
from sara_engine.inference import SaraInference

app = FastAPI()
sara = SaraInference(model_path="models/distilled_sara_llm.msgpack")

class ChatRequest(BaseModel):
message: str

@app.post("/chat")
def chat_endpoint(req: ChatRequest):
sara.reset_buffer()
prompt = f"You: {req.message}\nSARA:"
response = sara.generate(prompt, max_length=100, temperature=0.1)
return {"response": response.strip()}

2. Discord Bot Integration

Build a fast, local Discord bot:

import discord
import os
from sara_engine.inference import SaraInference

intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
sara = SaraInference(model_path="models/distilled_sara_llm.msgpack")

@client.event
async def on_message(message):
if message.author == client.user:
return

sara.reset\_buffer()  
prompt \= f"You: {message.content}\\nSARA:"  
response \= sara.generate(prompt, max\_length=100, temperature=0.1)  
await message.channel.send(response.strip())

client.run(os.getenv('DISCORD_TOKEN'))

🛠️ Architecture & Modules

  • sara_engine.core: The fundamental building blocks, interfacing with the Rust backend.
  • sara_engine.nn: High-level PyTorch-like API for model construction.
  • sara_engine.models: Pre-built architectures (e.g., SpikingCausalLM, BioTransformer).
  • sara_engine.memory: Implementations of SDR, Hippocampus, and Vector Stores.
  • sara_engine.agent: Agentic frameworks for MoE and Function Calling.

🗺️ Roadmap & Documentation

To understand the future direction and deep theoretical background of the SARA Engine, check the following documents:

  • doc/ROADMAP.md - Short-term development goals.
  • doc/RELEASE_CHECKLIST.md - Pre-release validation and packaging checklist.
  • doc/RELEASE_NOTES.md - Current pre-release reliability and compatibility notes.
  • doc/SARA_EVOLUTION_ROADMAP.md - Long-term evolutionary roadmap.
  • doc/stateful_snn_theory.md - Theoretical background on Stateful SNNs and NeuroFEM.

📄 License

This project is licensed under the MIT License.

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

sara_engine-0.4.6.tar.gz (46.4 MB view details)

Uploaded Source

Built Distribution

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

sara_engine-0.4.6-cp310-cp310-macosx_11_0_arm64.whl (569.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file sara_engine-0.4.6.tar.gz.

File metadata

  • Download URL: sara_engine-0.4.6.tar.gz
  • Upload date:
  • Size: 46.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for sara_engine-0.4.6.tar.gz
Algorithm Hash digest
SHA256 98e4c4827cbc87211f7dea43a07bd72506c07b38fbe4cc85bdfa6f4eb968a492
MD5 6fd35caf908d8258175cba1e221736d3
BLAKE2b-256 62521a7da0589d38021d42360e5c90f259b2a133c99ce1ddbdc188225e1dfad4

See more details on using hashes here.

File details

Details for the file sara_engine-0.4.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sara_engine-0.4.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3e451eb6995008d325ae61b04e2ae9842110bcd617755cbf692c9e9632807cd
MD5 7b088def211a61508ed0a10a6a10dafc
BLAKE2b-256 fdd7078d48c8d8150bb9353e141993a7c3b686c3f73486c0657906cd07f59982

See more details on using hashes here.

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