Neuro-Symbolic Core: A Framework From Scratch
This project is an implementation of a neuro-symbolic artificial intelligence framework, built entirely from scratch in Python. The goal is to provide a reusable and scalable engine that unites neural networks and symbolic logic, inspired by concepts such as Logic Tensor Networks (LTNs).
The system is capable of learning from facts and logical rules, adjusting numerical representations (embeddings) and neural models to satisfy a knowledge base. It has been designed to be flexible, performant, and auditable.
Core Features
-
Tensor Engine with Dual Backend: A custom Tensor class with support for automatic differentiation (backpropagation). It operates with a pure Python backend for portability or a NumPy backend for high performance.
-
Dynamic Neural Network Modules: Build neural network architectures (Linear, ReLU, Sigmoid, etc.) dynamically from configuration files, without needing to change the code.
-
Configurable Logical Representation: Represent first-order logic formulas (∀, →, ∧, etc.) and choose the fuzzy logic semantics (t-norms) and quantifier aggregators best suited for your problem.
-
Extensible Training Framework: An abstract Trainer with a Callbacks system allows for cleanly injecting functionalities like ModelCheckpoint (to save the best model) and EarlyStopping.
-
Explainability and Governance: Includes tools for auditing inferences, capable of identifying which entities in the domain most influenced a model's decision.
Project Structure
neuro-symbolic-core/
├── benchmarks/ # Scripts for performance testing
├── examples/
│ └── socrates/ # Example of how to use the library
│ ├── config.yaml
│ └── data/
├── src/ # The library's source code
│ ├── explainability/
│ │ └── explainer.py # (NEW) Inference audit tool
│ ├── interpreter/
│ │ ├── fuzzy_operators.py
│ │ └── interpreter.py
│ ├── logic/
│ ├── module/
│ │ └── factory.py # Neural network model factory
│ ├── tensor/
│ │ └── backend/ # Numerical backends (Python, NumPy)
│ └── training/
│ ├── callbacks.py # (NEW) Callback system
│ └── trainer.py # Main training class
└── ...
How to Use
1. Train the Model
Run the training script from an example. The library's Trainer will orchestrate the process, and the ModelCheckpoint callback will save the best-performing model.
# Run with the default backend (Python)
python examples/socrates/train.py
# To use the high-performance backend, set it at the beginning of your script:
# from src.tensor.backend import set_backend
# set_backend('numpy')
2. Run Inference and Audits
Use the inference script to ask a question to the trained model. Use the --explain flag to enable the governance report.
# Simple query
python src/inference/infer.py --query "Mortal(socrates)"
# Query with an explainability report
python src/inference/infer.py --query "Mortal(socrates)" --explain
The explainability report will show which constants from your domain (e.g., socrates, plato) had the greatest impact (as measured by the gradient) on the result of your query.
Metadata
Release files for neuro-symbolic-core 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neuro_symbolic_core-0.1.0.tar.gz | 35.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neuro_symbolic_core-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 71.2 kB
Release files / neuro_symbolic_core-0.1.0.tar.gz
| Download URL | neuro_symbolic_core-0.1.0.tar.gz |
|---|---|
| Size | 35.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b76e3aae6c40a427c98d2b674ed559d61f3bb94308a2c1d313c7b281b544fd5
|
|
BLAKE2b-256 checksum How to use checksums |
9c9b77ad492c36e6e647718e543fc4c61c170b327f84163a820660c741b83e64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / neuro_symbolic_core-0.1.0-py3-none-any.whl
| Download URL | neuro_symbolic_core-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5c59ace6b48ac9b58955d2ddd64108d55240d593855b8d09486577c48294539
|
|
BLAKE2b-256 checksum How to use checksums |
0009802fdc7f378aad4188e860d7836a50bd14539fd31fcc725cc0d1eb63f9fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|