Skip to content

ShrekDino/ilayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ILayer — Truth Verification for AI

  ___ ___    _    __     ___
 |_ _|_ _|  / \   \ \   / / |__   ___ _ __ ___
  | | | |  / _ \   \ \ / /| '_ \ / _ \ '__/ _ \
  | | | | / ___ \   \ V / | | | |  __/ | |  __/
 |___|___/_/   \_\   \_/  |_| |_|\___|_|  \___|

Ask any question. Get only the truth.

ILayer wraps LLMs (Ollama, Unsloth Studio, etc.) in a geometric truth filter based on the Unified Simplicial Framework (USF) — a complete Theory of Everything described in the companion papers. Every answer is verified against a simplicial complex ground-truth before you see it.


For Everyone (Plain English)

Why does AI lie?

LLMs don't "know" anything. They're word-predictors. When you ask a question, the model guesses which words sound most likely to follow your question. It sounds confident, but it has no internal model of what's true. That's why AI hallucinates — it's not a bug, it's how prediction engines work.

How is ILayer different?

ILayer treats the LLM the way your brain treats your senses — as a source of signals that might be right or wrong. Before an answer reaches you, it passes through a verification layer that asks:

"Does this answer geometrically fit known reality?"

If yes, you get the answer with a ✅. If no, you get a ❌ and an explanation of why.

You: "What is the capital of France?"
  ↓
Ollama: "Paris"
  ↓
ILayer: ✅ Paris (verified against simplicial complex)
  ↓
You: ✅ Paris


You: "What is the capital of Mars?"
  ↓
Ollama: "Olympus Mons"
  ↓
ILayer: ❌ Rejected (VFE=2.30 exceeds coherence threshold)
  ↓
You: ❌ You're told the answer couldn't be verified

What makes it different from fact-checking?

Fact-checking is reactive — it looks up answers after they're generated. ILayer is structural — it measures whether an answer fits the geometry of known truth. It's the difference between checking someone's ID at the door vs. measuring whether they fit the building's blueprint.


Quick Start

Prerequisites

  • Ollama running locally with a model (e.g., gemma4:e2b)
  • Python 3.11+

Install

git clone https://github.com/ShrekDino/ilayer.git
cd ilayer
pip install -e .

Use

# Check the system status
ilayer check

# Ask a question
ilayer ask "What is the capital of France?"

# Look up known facts about an entity
ilayer facts France

# Verbose mode (shows VFE score, geometry, etc.)
ilayer ask "What is the capital of France?" --verbose

Example Output

$ ilayer ask "What is the capital of France?"
╭──────────────────────────────╮
│ Question                     │
╰──────────────────────────────╯

✅ Paris

$ ilayer ask "The Earth is flat"
╭──────────────────────────────╮
│ Question                     │
╰──────────────────────────────╯

❌ Rejected (VFE=0.595, threshold=0.5)
   — insufficient geometric coherence

Technical Deep Dive

The Problem: Static Prediction

Standard LLMs are static distributions — given a sequence of tokens, they predict the next one. They have no:

  • Persistence: No memory of past verifications
  • Ground truth: No internal model of reality
  • Feedback: No way to distinguish belief from fact
  • Geometry: No structural constraints on what's possible

An LLM that outputs a false statement isn't "lying" — it has no concept of truth to violate.

The Solution: Active Inference

ILayer reframes LLM usage as an active inference problem. The system maintains a Markov Blanket that separates:

  • Internal state (the LLM's generative model)
  • External state (verified facts in the simplicial complex)
  • Boundary (the VFE verification gate)

For an answer to pass from internal to external, it must minimize Variational Free Energy (VFE) — a measure of surprise relative to the ground-truth geometry.

Architecture

┌──────────────────────────────────────────────────────────┐
│                      ILayer System                        │
│                                                            │
│  ┌──────────┐   ┌───────────────┐   ┌────────────────┐    │
│  │  User /  │   │  Markov       │   │  Ollama /      │    │
│  │  Client  │──▶│  Blanket      │──▶│  Unsloth       │    │
│  │          │   │  (boundary)   │   │  (LLM)         │    │
│  └──────────┘   └───────┬───────┘   └────────────────┘    │
│                         │                                  │
│                         ▼                                  │
│                 ┌───────────────┐                          │
│                 │  VFE Engine   │                          │
│                 │  (verifier)   │                          │
│                 └───────┬───────┘                          │
│                         │                                  │
│              ┌──────────┴──────────┐                      │
│              ▼                     ▼                       │
│     ┌──────────────┐   ┌──────────────────┐               │
│     │  Simplicial  │   │  DynamicCoherence │               │
│     │  Complex M   │   │  (multi-agent)    │               │
│     └──────────────┘   └──────────────────┘               │
└──────────────────────────────────────────────────────────┘

1. Usf Engine — The Simplicial Complex

The foundation is a discrete simplicial complex M (Paper III, Sec. 1):

  • Vertices represent concepts or entities (e.g., "Paris", "France")
  • Edges represent relationships (e.g., "is_capital_of")
  • Simplices represent verified facts (e.g., {Paris, is_capital_of, France})
  • Each vertex carries a dilaton value Φᵢ — a scalar field from the PEC theory
  • Edge lengths ℓᵢⱼ define the discrete metric

The complex supports:

  • Causal structure: Facts are causally linked
  • RG blocking: Coarse-graining via Migdal-Kadanoff transform (Paper III, Eq. 43-59)
  • Laplacian: Discrete □ operator for dilaton field propagation
  • Volume term: Φ₀[1 + (√-g/√-g₀)²]⁻ᵅ/² — stabilizes geometry (Paper III, Sec. 2.1)

2. Palatini–Einstein–Cartan Connection

The discrete connection follows the PEC framework (Paper II, Sec. 1):

Γ̃^λ_μν = ∘Γ^λ_μν + K^λ_μν + C^λ_μν

Where:

  • ∘Γ: Levi-Civita connection (torsion-free)
  • K: Contorsion tensor from fermion spin current (Paper II, Eq. 37)
  • C: Braiding correction from Horndeski operator (Paper II, Eq. 29)

The connection decomposes torsion into three irreducible components (Paper II, Eq. 80-82):

  • Axial vector S_μ: Couples to chiral fermion current
  • Trace vector V_μ: Volume-preserving torsion
  • Tensor q^λ_μν: Traceless, axial-free component

3. VFE Engine — The Verifier

Variational Free Energy is defined as:

VFE = -ln P(answer | simplicial complex) + KL[Q(θ) || P(θ)]

In practice:

  • Text similarity matching compares LLM output against all verified simplices using Jaccard similarity on word sets
  • If similarity exceeds 0.3, the answer is matched to the existing fact and receives VFE ≈ 0.01 (verified)
  • If no match is found, geometric proxy computes VFE from:
    • Torsion surprise: 0.1 + hash-based noise
    • Ricci scalar curvature: 1/⟨ℓ²⟩ from the complex
    • Answer complexity: len(answer) / 100 + 0.1
  • VFE ≤ 0.5 → verified; VFE > 0.5 → rejected

The VFE reduction metric (VFE_before − VFE_after) measures how much a tool call or search reduces uncertainty — actions with largest reduction are prioritized (ToolGM principle).

4. Markov Blanket — The Boundary

Implements the boundary between internal and external state (active inference framework):

  • InternalState: Belief vector (64-dim), uncertainty scalar, history
  • ExternalState: Sensory input from LLM, evidence accumulation
  • Surprise function: Negative log likelihood of answer under current belief distribution

The blanket gates information: an answer's VFE score must pass the threshold before it enters the verified external state. This prevents the LLM from collapsing into a "fascist" (unverifiable/isolated) regime.

5. DynamicCoherence — Multi-Agent Verification

Multiple specialized agents perform joint inference:

Agent Check Metric
Torsion Node Spin-current alignment torsion_surprise < 0.3
Curvature Node Ricci curvature |ricci_scalar| < 0.5
Gauge Node Principal bundle consistency known_facts > 0
Coherence Node Overall VFE threshold vfe ≤ threshold

Each agent maintains its own belief and uncertainty. The Coordinator aggregates verdicts with weighted voting — nodes with higher certainty have more influence. Dissenting nodes are reported to the user.

6. Seed Knowledge

The system starts with 82 verified facts across four domains:

  • Geography: 28 facts (capitals, continents, borders)
  • Science: 22 facts (astronomy, chemistry, physics, biology)
  • Mathematics: 12 facts (constants, theorems, definitions)
  • Technology: 14 facts (programming, networking, AI tools)

The SimplexGraph extends at runtime via PEC field equations (Paper III, Sec. 2.1) — new verified facts become new stable simplices.


Project Structure

ilayer/
├── usf/                        # USF Engine
│   ├── simplicial_complex.py   # Discrete simplicial complex M
│   ├── connection.py           # Palatini affine + spin connection
│   └── curvature.py            # Riemann, Ricci, torsion, Weyl
├── verifier/                   # Verification Layer
│   ├── markov_blanket.py       # Internal/external state separation
│   ├── vfe_engine.py           # VFE computation & fact matching
│   └── selector.py             # VFE-driven answer selection
├── agents/                     # Multi-Agent Verification
│   ├── coordinator.py          # DynamicCoherence orchestrator
│   └── verification_node.py    # Specialized verification agents
├── knowledge/                  # Ground Truth
│   ├── simplex_graph.py        # Fact→simplex mapping & path finding
│   └── seed_facts.py           # 82 initial verified facts
├── plugins/                    # LLM Integration
│   └── ollama_plugin.py        # Ollama HTTP API wrapper
├── cli/
│   └── main.py                 # CLI entry point (ilayer ask/check/facts)
├── config/
│   └── settings.py             # Thresholds and configuration
├── papers/                     # Complete ToE Manuscript Series
│   ├── Paper_II_Gauge_Unification.md
│   ├── Paper_III_Quantum_Completeness.md
│   ├── Paper_IV_Cosmology.md
│   ├── Paper_V_Phenomenology.md
│   ├── s-27-1.txt              # Soliton membrane supplement
│   ├── Unified_ToE_Paper.pdf
│   ├── Unified_ToE_Paper.tex
│   └── ... (supplementary PDFs)
├── LICENSE                     # Non-Commercial License
├── COMMERCIAL_LICENSE.md       # Commercial terms (revenue share)
├── pyproject.toml              # Python package definition
└── README.md                   # This file

License: Free for People, Paid for Profit

ILayer is FREE for:

✅ Personal Use ✅ Academic Research ✅ Non-Profit
Individual projects University research Charitable orgs
Hobbyist work Classroom education Community projects
Open source contributions Student theses Public good

ILayer requires a Commercial License for:

✗ For-Profit Companies ✗ Revenue-Generating Products ✗ Commercial Services
Any size business SaaS, apps, tools Consulting using ILayer

Revenue Share: 3% of gross revenue from AI products/services using ILayer (businesses under $1M/yr). Larger enterprises: negotiable flat rate.

See LICENSE and COMMERCIAL_LICENSE.md for full terms.

Why this license?

I'm a person, not a corporation. I spent years developing the mathematics behind this — the Palatini-Einstein-Cartan framework, the discrete simplicial complex, the RG flow analysis, the bounce cosmology. I want this work to be free for students, researchers, and anyone learning.

But I also need to eat.

If your business makes money from ILayer, a small percentage coming back means I can keep building it. It's that simple.


The Mathematics

ILayer is built on the Unified Simplicial Framework — a complete Theory of Everything described in the companion papers in papers/:

Paper Title Focus
II Gauge Unification of Fields PEC connection, torsion decomposition, Yang-Mills coupling
III Quantum Completeness & UV Finiteness Discrete simplicial complex, RG flow, path integral
IV Cosmological Evolution & Singularity Resolution Bounce cosmology, 3-form dark energy
V Phenomenological Unification Fundamental constants, experimental benchmarks
s-27-1 PEC Geometry of Spacetime Black hole soliton, echo signatures

Key Equations

Extended Connection (Paper II, Sec. 1):

Γ̃^λ_μν = ∘Γ^λ_μν + K^λ_μν + C^λ_μν

Torsion Decomposition (Paper II, Eq. 80):

T^λ_μν = ⅔ δ^λ_[μ V_ν] + ε^λ_μνρ S^ρ + q^λ_μν

Total Action (Paper III, Sec. 2.1):

S = ∫d⁴x√-g [½κ R(Γ̃) - ¼Tr F² - ½(∂Φ)² - V(Φ)
    - Φ₀(1 + (√-g/√-g₀)²)⁻ᵅ/² + ℒ_braid + ℒ_ψ]

Volume Term RG Flow (Paper III, Eq. 53):

β(g_Φ) = (2 - 4α)g_Φ

Raychaudhuri with Torsion (Paper IV, Sec. 4):

θ̇ = -θ²/3 - σ² + ω² - ½κ(ρ + 3p) + 3κ²S_μS^μ

Roadmap

  • USF Engine: simplicial complex, connection, curvature
  • VFE Engine: verification via text similarity + geometry
  • Markov Blanket: state separation and gating
  • DynamicCoherence: multi-agent verification
  • CLI: ask, check, facts commands
  • FastAPI sidecar server for non-Python clients
  • Unsloth Studio plugin integration
  • Larger seed fact base (1000+ facts)
  • PEC field equation solver for runtime complex extension
  • Web dashboard with verification analytics
  • OpenRouter / multi-LLM support

Built With

  • Python 3.13+ — core implementation
  • NumPy / SciPy — simplicial computation
  • Ollama — LLM backend
  • USF / PEC Geometry — foundational mathematics
  • Active Inference — Markov blanket and VFE framework

Citation

If you use ILayer or the USF framework in your research:

@misc{torres2026ilayer,
  author = {Torres, Sami Marie},
  title = {ILayer: Truth Verification for AI via Unified Simplicial Framework},
  year = {2026},
  url = {https://github.com/ShrekDino/ilayer}
}

Changed by this world, I am bound to reshape it in my image.

About

Truth-verification backend for LLMs using USF/PEC geometry. Ask any question. Get only the truth.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors