S_Euclid — A 100% LLM-Free Geometric State-Space Hologram
Try it live in your browser: tas1287/s-euclid-demo
S_Euclid is a 78.6M-parameter inference-only MomentEngine crystal folded chronologically over all 13 Books of Euclid's Elements (Book I, Def 1 through Book XIII, Prop 18, alongside Sir Thomas Heath's 1908 critical notes).
There is no language model head, no token vocabulary, no autoregressive decoder, and no growing KV-cache anywhere in this repository.
Instead, inputs are mapped through a frozen coordinate sensor (intfloat/multilingual-e5-large) into a 768-dimensional whitened unit sphere, and folded through a 16-layer multi-timescale recurrent core (24 heads × 64×64 per layer) into a fixed 6.0 MiB fp32 state tensor S:
- 9 fast heads (decay band
[0.50, 0.90]) — immediate turn kinematics & local basin footing - 9 medium heads (decay band
[0.90, 0.99]) — multi-step geometric continuity - 6 slow heads (decay band
[0.99, 0.9995], half-life up to 1,386 steps) — long-horizon canonical memory (S_Euclid)
How Inference Works
Rather than generating prose token-by-token, we read where the recurrent state points:
- Your query is embedded and folded into the live 6.0 MiB state
S(which persists across turns without resetting). - Over 10 closed-loop steps, the crystal outputs a continuous predicted vector and tangent velocity on the unit sphere, selects the nearest mathematical landmark word from its 3,243-word gallery, and immediately folds that landmark back into
Sto travel along a geodesic. - At each step, the trajectory points directly to verbatim passages from Euclid's Elements and Heath's 1908 notes.
- An optional
<1 mspure-Python Deterministic Trace Compiler (trace_compiler.py,0neural parameters) formats that exact step-by-step telemetry and verbatim Euclid quotes into a readable first-person trace.
Quickstart
pip install -r requirements.txt
Interactive CLI
# Interactive multi-turn session
python cli.py
# One-shot query
python cli.py "Why are there infinitely many prime numbers?"
# Raw telemetry table only (without the deterministic trace compiler)
python cli.py --raw "How do you prove the Pythagorean theorem?"
Inside the interactive CLI, you can also play with the live recurrent state directly:
/reset— reload the full canonical 13-book stateS_Euclid/book I(orII..XIII) — switch the live state to any individual folded Book/wipe_slow— zero out only the 6 slow heads (S_slow = 0) while keeping weights untouched/blank— start from a blank zero stateS_0 = 0/trace//raw— toggle the deterministic trace narrative on or off
Python API
from modeling_euclid import EuclidCrystal
crystal = EuclidCrystal.from_pretrained("tas1287/s-euclid")
# Turn 1 (folds into persistent S_Euclid state)
r1 = crystal.ask("Why are there infinitely many prime numbers?")
print(r1["trajectory_str"])
print(r1["winning_passage_anchor"], "->", r1["winning_passage_text"])
print(r1["trace"]["markdown"])
# Turn 2 (carries forward state from Turn 1 — no KV-cache, no prompt concatenation)
r2 = crystal.ask("How does that connect to greatest common measure?")
# Try ablating just the 6 slow memory heads
crystal.wipe_slow()
r3 = crystal.ask("Why are there infinitely many prime numbers?")
# Reset back to full S_Euclid
crystal.reset()
Browser UI (Gradio / Hugging Face Space)
python app.py
Bundle Contents
model.safetensors— Inference-onlyMomentEngineforward-pass weights (78.6M params)crystal_state.safetensors— Canonical 6.0 MiB foldeds_euclid, per-book folded statess_book_I..XIII, ZCA whitening projection, and aligned moment vectorsword_gallery.safetensors&word_gallery_meta.json— 3,243 mathematical landmark vectors and corpus anchorscorpus_moments.json— Aligned public-domain Euclid's Elements + Heath (1908) verbatim passagesmodeling_euclid.py— Standalone inference-only runtimetrace_compiler.py— Zero-parameter deterministic telemetry-to-grammar compilercli.py&app.py— Terminal REPL and Gradio web UI
Corpus Attribution
Base propositions and critical notes are drawn from Euclid's Elements in Sir Thomas L. Heath's public-domain 1908 Cambridge edition (via the Perseus Digital Library).