SyFox / README.md
Mr-DS-ML-85's picture
Build instructions: BUILDING.md + make sync-so
5aa6962 verified
|
Raw History Blame Contribute Delete
13.4 kB
---
license: mit
language:
- en
- bn
- hi
- ru
pipeline_tag: text-classification
tags:
# --- what it is ---------------------------------------------------------
- decision-engine
- decision-making
- decision-model
- structured-prediction
- system-one
- si-substrate
- text-classification
- intent-classification
- routing
# --- the differentiator: it can say "I don't know" ------------------------
- abstention
- uncertainty-quantification
- selective-prediction
# --- how it works --------------------------------------------------------
- hebbian
- energy-based-model
- associative-memory
# --- what it is not (kept deliberately: rare, and load-bearing) ---------
- no-transformer
- no-neural-network
- no-pattern-matching
# --- domains -------------------------------------------------------------
- moderation
- spam-detection
- multilingual
metrics:
- accuracy
- ece
- defer-rate
library_name: syfox
---
# SyFox Giant — a broad System-One decision engine (SI substrate, no NN)
One giant SyFox fabric family covering **16 decision domains** (customer
support, banking intents, spam, emotions, moderation, news topics, product
sentiment, entity typing, boolean comprehension, game commands, guardrails)
plus per-script substrates for Bengali / Devanagari / Cyrillic with automatic
script routing. **No transformer, no neural network, no pattern matching**:
every decision comes from a C++ SI substrate — energy injection →
dissipative settle → resonance readout → honest silence. The lanes ARE the
knowledge; every one is inspectable in `model/*/substrate.bin`.
Built from 76,142 real/synthetic-verified training rows across 16 domains,
trained with the three failure-mode fixes learned from the model-xl RCA:
empty per-row instructions, globally-unique opaque anchors (278), and
round-robin domain interleaving. Full measured evaluation:
[docs/EVALUATION.md](docs/EVALUATION.md).
## Headline measured numbers (hidden splits, scored once)
> **⚠ Measured with the v3.2.0 engine.** The core in this repo is now v3.9.1,
> which applies stricter honesty gates — some previously answered rows now
> defer. The numbers below have **not** been re-measured under v3.9.1. Treat
> them as the v3.2.0 result and re-run the evaluation before quoting them.
> Details and the exact behaviour diff: [docs/ENGINE_PORT.md](docs/ENGINE_PORT.md).
| domain | class acc | router | end-to-end |
|---|---:|---:|---:|
| tickets_en | 0.904 | 0.831 | 0.761 |
| sms spam | 0.752 | 0.233 | 0.222 |
| enron email spam | 0.752 | 0.394 | 0.323 |
| hate/offensive | 0.653 | 0.381 | 0.277 |
| ag_news topics | 0.604 | 0.320 | 0.206 |
| amazon polarity | 0.571 | 0.339 | 0.189 |
| dbpedia entities | 0.475 | 0.403 | 0.204 |
| boolq (boolean) | 0.531 | 0.097 | 0.059 |
| bank77 (77-way) | 0.023 | 0.931 | 0.022 |
| tickets_bn (bengali substrate) | 0.943 | 1.000 | 0.943 |
| tickets_hi (devanagari substrate) | 0.920 | 1.000 | 0.920 |
| tickets_ru (cyrillic substrate) | 0.959 | 1.000 | 0.959 |
Honest notes: the single 16-way router is the end-to-end bottleneck for
same-script domains — blind routing alone measures **0.400** on hidden
(23,528 rows) and the table's router column is the *informed* condition
(router + the true domain's class question asked together); naming the
domain in the API gives the class numbers. bank77's 77-way readout collapses
in a shared fabric — see **v3.2: the dedicated bank77 fabric** below for the
architectural fix (0.023 → 0.081 → **0.158**); boolq stays near
majority — boolean passage comprehension is a measured limit of bag-of-words
SI physics. Latency ≈ 6-11 ms/row on the 43k-node latin fabric.
## v3.2 — the semantic layer, retrieval by default, the two-stage router
The engine in this repo is SyFox **v3.9.1** (ported from `syfox-train`; see
[docs/ENGINE_PORT.md](docs/ENGINE_PORT.md) for the port, the ABI check, and one
caveat that matters — **the headline numbers below were measured with the
v3.2.0 engine and have not been re-measured**). The substrate gained:
the substrate now carries a
second, deterministic field — a 64-dim semantic vector per concept (signed
character-trigram hashing + two fabric-grounding passes over the Hebbian
lanes; no ML, no fit) — from which **resonance edges** leak an
energy-conserving share of a source's energy to semantically similar
neighbours during settle. **Context-sensitive lanes** learn required/forbidden
context words from the lessons that laid them and carry less when the
decision's own tokens do not match. **Retrieval is default-on**: a
`memories.jsonl` in the model dir primes every decide with the outcomes of
the most resonating lived experiences (Hopfield-style settled-field cosine),
disclosed in the response as `usage.retrieval`. Pre-v3.2 fabrics replay
bit-for-bit; `--no-semantics / --no-retrieval / --no-hierarchy` (and the
equal `options` keys on HTTP) are the kill switches.
Two new model dirs ship here:
- **model/b77-sem** — the DEDICATED banking77 fabric: 9,000 opaque-anchor
intent lessons + 9,000 category lessons, 1,648 nodes / 217,729 lanes,
7,728 resonance edges, 141,920 context-signed lanes, 256 retrieval
memories, calibrated. Hidden (3,080 rows, scored once, energy-norm):
**0.158 top-1** vs 0.081 (v3.1.0 dedicated+opaque) and 0.023 (shared
giant). Ablation: `--no-semantics` 0.039 — the semantic field IS the jump;
the hierarchy gate measured-negative on cal and ships floor 1.0 = off.
- **model/router16** — the two-stage physics router: 4,742 nodes trained
ONLY on router questions (16 domain anchors x 60 rows). Cal 16-way routing
**0.444** (chance 0.0625), ECE 0.380 → 0.086. Route with
`decide --router model/router16` (CLI) or the two-call pattern below —
bank77 queries route to model/b77-sem, everything else to giant-latin.
Zero-shot re-run under v3.2 (docs/ZEROSHOT.md Part 4,
datasets/zeroshot_v32_results.json): email spam on the tickets-only fabric
6/6 plain and 6/6 semantic rebuild; sms spam 5/6 (the one error at conf
0.103, disclosed); snake 1/8 both; tic-tac-toe picks cell 1 at conf 0 —
multi-constraint composition fails exactly as in Part 1 and the semantic
field does not fake it.
## Files
```
engine/ C++ SI substrate core v3.9.1 (core/*.hpp, src/*.cpp) — builds with make
NOTE: refresh ../build/libsyfox_core.so after rebuilding, or the
python bridge will keep loading the stale core (ENGINE_PORT.md)
server/ HTTP bridge (v3 API, CLI-equal flags incl. the v3.2 knobs)
inference.py thin python wrapper (auto script routing)
model/ giant-{latin,bengali,devanagari,cyrillic}/substrate.bin (v3.2-era, 16 domains)
sst2/ agnews/ amazon/ NEW v3.9.1 fabrics, handcrafted-probe gated
b77-sem/ dedicated 77-way banking fabric (v3.2 semantic layer)
router16/ two-stage physics router (router.json: anchors+models)
datasets/ eval hidden splits, probes, schemas, MANIFEST (SHA-256),
novel_probes/ (handcrafted admission probes + RESULTS.json),
router16_router.json, zeroshot_v32_results.json, DATASETS.md
docs/ ENGINE_PORT.md (v3.9.1 port + caveats), EVALUATION.md,
ARCHITECTURE.md, PROBING.md, ZEROSHOT.md
examples/ JSON payloads + curl + python usage
Dockerfile HuggingFace Spaces (builds engine, serves on 7860)
```
## Build
```bash
cd engine && make all && make sync-so && cd ..
```
`make sync-so` is **required** for the Python bridge: it loads
`build/libsyfox_core.so` from the **repo root**, not `engine/build/`, so a
plain `make all` leaves a stale library in place and `from inference import
SyFox` fails with `undefined symbol`. Full instructions, Docker, retraining
and troubleshooting: **[BUILDING.md](BUILDING.md)**.
## Usage (python)
```python
from inference import SyFox
m = SyFox() # loads model/giant-<script> per detected script
r = m.decide("I was charged twice on my last invoice, please refund.")
print(r["answers"]["domain"]) # router: choice + probabilities + confidence
# ask a named domain's question directly (skips the router bottleneck):
r = m.decide("I was charged twice on my last invoice, please refund.",
domain="bank77")
print(r["answers"]["intent"]) # 77-way choice with probabilities
```
## Usage (HTTP, what the Space runs)
```bash
curl -X POST http://localhost:7860/v1/systemone -H 'Content-Type: application/json' -d '{
"state": "Congratulations! You won a £1000 prize. Call now to claim!",
"questions": {"domain": {"type": "choice", "instructions": "",
"criteria": {"rt00": "support billing sales technical", "rt05": "text messages spam",
"...": "see datasets/schemas.json"}}},
"options": {"energy_norm": true, "defer_margin": 0.05}
}'
```
The server also exposes `/v1/health`, `/v1/models`, `/v1/deferrals`
(active-learning mirror) and per-call options `energy_norm`,
`salience_gating`, `miller_window`, `ngrams`, `defer_margin`, `evidence`,
and the v3.2 knobs `semantics`, `retrieval`, `retrieval_topk`,
`retrieval_dose`, `hierarchy`.
## Docker (HuggingFace Spaces)
The included Dockerfile builds the engine from source and serves the v3 API
on port 7860. Create a Docker Space, push this repo, done. CLI-equal flags
are passed in the `CMD` (`--lang auto --energy-norm`).
## Training recipe (reproduce or extend)
See docs/EVALUATION.md §Reproduce. Corpus + tooling live in the main SyFox
repo (`tools/hf_fetch.py`, `tools/giant_prepare.py`, `tools/giant_bench.py`,
`tools/router_sweep.py`). Constraint discipline: hidden splits are
firewall-enforced (never taught, never calibrated on); all model/wording
selection happened on cal; the core physics was never modified.
## Limitations
- Single-router e2e is bottlenecked by 16-way choice in one fabric (measured;
wording sweep shows it is the readout mechanism, not the wording); the
v3.2 dedicated router16 fabric raises blind 16-way routing to 0.444 on its
cal carve and routes bank77 to its dedicated fabric.
- 77-way banking intents: dedicated fabric v3.2 measures 0.158 hidden
(semantic field ablation 0.039 — the field is the mechanism); higher
ladders need arbitration or per-category substrates (hierarchy gating
itself measured-negative on cal, shipped off).
- Boolean passage comprehension is near-majority — the substrate reads
lexical fields, not logic.
- Zero-shot composition (constraints, topology) is NOT solved by scale or
by the semantic field — see docs/ZEROSHOT.md Parts 1 and 4 for the
measured two-dimension separation.
## License & credit
MIT © 2026 Mr-DS-ML-85. Core mechanics ported from the author's
Synthetic-Intelligence research substrate. Dataset licenses: see
datasets/DATASETS.md.
## New models — gated on handcrafted NOVEL questions
Three fabrics trained and admitted, each passing a handcrafted probe set built
to defeat the cheapest way to pass (`tools/novel_gate.py`, probes shipped in
`datasets/novel_probes/`):
| model | task | labels | novel acc | required | outcome |
|---|---|---:|---:|---:|---|
| `model/sst2` | sentiment (Stanford SST-2) | 2 | **0.750** | 0.650 | **ADMIT** |
| `model/agnews` | news topic | 4 | **0.583** | 0.400 | **ADMIT** |
| `model/amazon` | product polarity | 2 | **0.700** | 0.650 | **ADMIT** |
Admission rule: `novel_acc > max(majority_baseline, uniform_chance + 0.15)` and
no prediction collapse (≤60% of probes answered with one class).
```bash
./engine/build/syfox decide --model model/sst2 \
--state "a hollow, inert picture that never risks anything" \
--questions '{"q":{"type":"choice","instructions":"sentiment",
"criteria":{"negative":"negative","positive":"positive"}}}'
```
### Why handcrafted probes, not the held-out split
`_hidden` shares its generator, templates and vocabulary distribution with
`_train`, so it rewards memorising n-grams — a bag-of-words fabric scores well
there while understanding nothing. The probe set is built against that:
- no probe sentence is copied from any split;
- paraphrase-invariant (same meaning, deliberately different words);
- minimal pairs differing in one content word with opposite labels;
- evaluative vocabulary chosen to be rare in the training distribution;
- **a reversal canary** per polarity set — an inverted sentence of one of its
own probes, which a lexical shortcut must fail.
### Two candidates were REJECTED — recorded, not hidden
| model | task | novel acc | required | why |
|---|---|---:|---:|---|
| `toxic` | toxicity | 0.286 | 0.650 | **below baseline**; all 5 toxicity probes predicted non-toxic; 71% of answers collapsed to one class |
| `emotion` | 6-way emotion | 0.250 | 0.317 | **chance**. 3/12 on six classes; errors show no structure (joy→sadness, love→anger) |
`toxic` is the interesting failure: hate-speech is exactly what a moderation
tag promises, and a bag-of-words SI fabric does not separate abuse from ordinary
blunt speech at all. `emotion` is the one this repo previously mislabelled 100%
(M6); the corrected fabric still does not clear a handcrafted bar. **Neither
model is published.** `xnli` was also trained and measured at 0.338 against a
0.333 chance floor — compositional language understanding is a genuine limit
of bag-of-words SI physics, consistent with this project's own composition
benchmark at 0/16.