Skip to content

Ciprian-LocalPulse/nsaif

Repository files navigation

NSAIF

Neuro-Symbolic Adaptive Intelligence Framework

License: MIT Python Status

NSAIF is an open-source research framework for composing neural representations, symbolic rules, causal graphs, adaptive model topology, and multiple forms of memory behind one inspectable Python API.

Important: NSAIF is an early research prototype. Mathematical claims and benchmark results must be independently reviewed and reproduced before they are treated as established scientific results.

Architecture

Input -> Perception -> Cognitive Bridge -> Reasoning -> Action
             |              |                |
             +------ Adaptive Topology ------+
                            |
          Episodic + Semantic + Procedural Memory

The implementation contains:

  • nsaif.core: fuzzy operators, symbolic tensors, and gradient routing.
  • nsaif.reasoning: knowledge graphs, causal interventions, modal facts, and metacognitive confidence checks.
  • nsaif.topology: auditable MDL-inspired grow/prune policies.
  • nsaif.memory: episodic, semantic, and procedural stores with unified recall.
  • nsaif.perception: lightweight vision, language, and multimodal adapters.
  • nsaif.training: hybrid losses, curriculum scheduling, and a generic trainer.

Quickstart

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
python -m pip install -e ".[dev]"
python -m pytest
from nsaif import NSAIFConfig, NSAIFModel

config = NSAIFConfig.from_preset("nsaif-small")
model = NSAIFModel.from_config(config)

output = model.reason(
    "If all mammals breathe air, and dolphins are mammals, "
    "do dolphins breathe air?",
    return_proof=True,
)

print(output.answer)       # Yes
print(output.proof_trace)  # Auditable logical steps
print(output.confidence)   # Confidence estimate

The same API accepts explicit facts and rules:

model.learn_fact("dolphin", "is_a", "mammal")
model.learn_rule("mammal", "breathes", "air")
result = model.query("dolphin", "breathes", "air")

Repository layout

nsaif/
|-- README.md
|-- LICENSE
|-- CONTRIBUTING.md
|-- CITATION.cff
|-- pyproject.toml
|-- nsaif/
|   |-- core/
|   |-- reasoning/
|   |-- topology/
|   |-- memory/
|   |-- perception/
|   `-- training/
|-- benchmarks/
|   |-- arc_challenge/
|   |-- gsm8k/
|   |-- clutrr/
|   `-- custom_nsaif_bench/
|-- docs/
|   |-- theorems/
|   |-- tutorials/
|   `-- api/
|-- experiments/
|-- configs/
`-- tests/

Cognitive Bridge

CognitiveBridge maps dense values to interpretable symbolic labels and can reconstruct a dense representation from symbolic activations. With PyTorch installed, callers may attach the bridge to a differentiable model; the core package intentionally remains usable without heavyweight dependencies.

from nsaif.core import CognitiveBridge

bridge = CognitiveBridge(
    neural_dim=4,
    symbolic_vocab=["cold", "warm", "bright", "dark"],
    norm_type="godel",
)
symbols, trace = bridge.encode([0.1, 0.9, 0.7, 0.2])
print(symbols.top_symbols(2))

Causal reasoning

from nsaif.reasoning import CausalGraph

graph = CausalGraph()
graph.add_edge("treatment", "outcome", weight=0.8)
estimate = graph.do(treatment=1.0).query("outcome")

This module is a transparent educational intervention engine, not a substitute for validated statistical causal inference in medical, legal, financial, or other high-stakes settings.

Adaptive topology

The topology manager records every decision and evaluates a simplified minimum description length objective:

objective = data_loss + mdl_lambda * structural_complexity

Adapters can connect these decisions to real PyTorch modules. The base package does not silently mutate arbitrary production models.

Benchmarks

Each benchmark directory contains a reproducible harness and result schema. No headline scores are shipped as verified results. Run the harnesses, record the environment and seed, and publish generated JSON artifacts with any claim.

python -m benchmarks.run_all --output artifacts/benchmark-results.json

Project status

Version 0.1.0 provides a tested reference architecture and extension points. It is not a trained 7B model, a proof assistant, or a clinically validated decision system. The nsaif-7b-reasoning preset is a configuration description for downstream integrations; it does not download or bundle model weights.

Research directions

  • Differentiable grounding with formally measured approximation error.
  • Verified rule backends using Lean, Coq, or SMT solvers.
  • Distributed knowledge graphs and multi-agent memory.
  • Continual topology adaptation with stability guarantees.
  • Reproducible comparisons on ARC, GSM8K, CLUTRR, and causal benchmarks.

Citation

See CITATION.cff. A BibTeX example is also available in docs/citation.bib.

Contributing and security

Read CONTRIBUTING.md before opening a pull request and SECURITY.md before reporting a vulnerability.

Support NSAIF Research

Support NSAIF

Help keep independent neuro-symbolic AI research open to everyone

Every contribution supports compute infrastructure, dataset access, reproducible experiments, documentation, and open publication.

Support with PayPal

Independent Research Open Source MIT Licensed


Bank Transfer via Wise

Select the account matching your transfer currency. Please verify every field before confirming a payment with your bank.

EUR - SEPA / International SWIFT
Transfer field Details
Beneficiary Ciprian Stefan Plesca
IBAN BE83 9679 1975 8915
SWIFT / BIC TRWIBEB1XXX
Bank Wise
Bank address Rue du Trone 100, 3rd floor, Brussels, 1050, Belgium

Recommended use: IBAN for SEPA transfers; IBAN and SWIFT/BIC for international transfers.

GBP - United Kingdom / International SWIFT
Transfer field Details
Beneficiary Ciprian Stefan Plesca
Account number 92055372
Sort code 23-14-70
IBAN GB68 TRWI 2314 7092 0553 72
SWIFT / BIC TRWIGB2LXXX
Bank Wise Payments Limited
Bank address 1st Floor, Worship Square, 65 Clifton Street, London, EC2A 4JE, United Kingdom

Recommended use: account number and sort code for UK transfers; IBAN and SWIFT/BIC for international transfers.

USD - ACH / Wire / International SWIFT
Transfer field Details
Beneficiary Ciprian Stefan Plesca
Account type Checking
Routing number 026073150 - ACH and wire
Account number 8314225367
SWIFT / BIC CMFGUS33
Bank Community Federal Savings Bank
Bank address 89-16 Jamaica Ave, Woodhaven, NY 11421, United States

Recommended use: routing and account numbers for US transfers; SWIFT/BIC for international transfers.


Your support becomes open research

Compute time | Dataset access | Reproducible science | Open publication

Contribute via PayPal

Thank you for helping NSAIF remain independent, transparent, and accessible.

License

NSAIF is released under the MIT License.

Releases

No releases published

Packages

 
 
 

Contributors

Languages