Skip to content

Triadic Neurosymbolic Engine

A deterministic algebraic framework for neurosymbolic validation, semantic projection, and AI model auditing.

PyPI Python 3.10+ License: BUSL-1.1 DOI Paper DOI Software


The Problem with Cosine Similarity

Cosine similarity tells you "King and Queen are 0.87 similar" — a black-box number.

The Triadic Engine tells you "King = 2x3x5 and Queen = 2x5x7. They share {2,5} (Royalty). King has {3} (Male) that Queen lacks. Queen has {7} (Female) that King lacks." — fully transparent, deterministic decomposition.

Cosine Similarity Triadic Engine
Speed (50K pairs) baseline 28.4x faster
Explainability Black box Prime factor proof
Subsumption (A contains B?) Approximation Exact: phi(A) mod phi(B) == 0
Composition (A union B) Geometric average lcm(phi(A), phi(B))
Gap analysis Not possible gcd + quotient decomposition
Determinism Seed-dependent PCA / contrastive modes
AI model audit Not supported Topological discrepancy

How It Works

Text --> Neural Embedding --> LSH Hyperplanes --> Composite Prime Integer
            (R^384)           (k projections)       (phi(x) = prod p_i)

Each concept becomes a single integer whose prime factors are its semantic features. This enables three operations impossible under cosine similarity:

Operation Math What it answers
Subsumption phi(A) mod phi(B) == 0 "Does A contain every feature of B?"
Composition lcm(phi(A), phi(B)) "What concept has all features of both A and B?"
Gap Analysis gcd(phi(A), phi(B)) + quotients "Which features do they share? Which are unique?"

Core Modules

Module Description
neurosym.encoder Multi-backend embedding encoder (HuggingFace, OpenAI, Cohere) + 4-mode LSH-to-Prime projection
neurosym.triadic Algebraic validation: subsumption, composition, abductive gap analysis
neurosym.graph Scalable graph builder with inverted prime index (avoids O(N^2))
neurosym.storage SQLite persistence for prime indices and audit results
neurosym.reports Exportable reports in HTML, JSON, and CSV formats
neurosym.ingest DataFrame ingestion with inverted prime index and semantic search
neurosym.anomaly Multiplicative anomaly detection for tabular data

Built-in Tools

Interactive Dashboard

pip install "triadic-engine[dashboard]"
triadic-dashboard

Six tabs: Ingestion & Encoding, Semantic Graph, Logic & Search, AI Auditor, Anomaly Detection, Benchmarks.

REST API

pip install "triadic-engine[api]"
uvicorn api.server:app --host 0.0.0.0 --port 8000
Endpoint Method Description
/health GET Engine status and loaded concepts count
/encode POST Encode concepts into composite prime integers
/audit POST Compare two embedding models topologically
/search POST GCD-based semantic search over indexed concepts
/report GET Export engine state as HTML, JSON, or CSV

Interactive docs at http://localhost:8000/docs (Swagger UI).

Ecosystem

The Engine is the foundation of the Triadic research program:

  • TriadicGPT — 40M-parameter GPT that learns prime signatures end-to-end
  • reptimeline — Tracks how discrete representations evolve during training