diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..30d2db07e33ca01dc8291a7548fa14f2e5f329c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,35 +1,3 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text *.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text +model/*/substrate.bin filter=lfs diff=lfs merge=lfs -text +model/giant-latin/substrate.bin filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e8ba3da8d3856a06d5c6c73b237c95c479e52a4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +*.pyc +build/ +hf_cache/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ec2cfac42fc7065804b6c67500e1b37d7a56ce6d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# SyFox giant model — HuggingFace Spaces (Docker SDK) +# Builds the SI-substrate engine from source, then serves the v3 HTTP API +# on the port Spaces expects (7860). No transformer, no NN: decisions come +# from the C++ SI substrate (energy injection -> settle -> readout). +FROM python:3.11-slim AS enginebuild +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential g++ make && rm -rf /var/lib/apt/lists/* +WORKDIR /src +COPY engine/ /src/ +RUN make build/libsyfox_core.so && strip build/libsyfox_core.so + +FROM python:3.11-slim +RUN pip install --no-cache-dir fastapi uvicorn +WORKDIR /app +COPY --from=enginebuild /src/build/libsyfox_core.so /app/build/libsyfox_core.so +COPY server/ /app/server/ +COPY inference.py /app/inference.py +COPY model/ /app/model/ +COPY datasets/ /app/datasets/ +COPY docs/ /app/docs/ +ENV PYTHONUNBUFFERED=1 +EXPOSE 7860 +# script routing: /app/model/giant -> /app/model/giant-latin, giant-bengali, ... +CMD ["python", "server/app.py", "--model", "model/giant", "--lang", "auto", \ + "--energy-norm", "--host", "0.0.0.0", "--port", "7860"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..4795ff664e581e162990aa51402135e1b1aacc55 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +MIT License + +Copyright (c) 2026 Mr-DS-ML-85 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Dataset licenses are listed in datasets/DATASETS.md and remain those of the +original publishers. diff --git a/PUSHING.md b/PUSHING.md new file mode 100644 index 0000000000000000000000000000000000000000..3589f4991eaf3b190c87b946ce79a8a3a94291a2 --- /dev/null +++ b/PUSHING.md @@ -0,0 +1,21 @@ +# Pushing to HuggingFace + +The latin substrate (`model/giant-latin/substrate.bin`, 112 MB) exceeds +HuggingFace's 100 MB non-LFS limit. `.gitattributes` already marks +`*.bin` as LFS — you only need git-lfs installed locally and the blob +re-staged as an LFS object: + +```bash +git lfs install # once per machine +git rm --cached model/giant-latin/substrate.bin +git add model/giant-latin/substrate.bin # now stored as an LFS pointer +git commit --amend --no-edit +git remote add origin https://huggingface.co//syfox-hf +git push -u origin main +``` + +The three small substrates (bengali/devanagari/cyrillic, ~0.5-0.6 MB) are +under the same `*.bin` rule and will ride along as LFS objects too. + +If you clone this repo after the LFS push, run `git lfs pull` to fetch the +binaries. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..073273079a46fbc646105947838b3008af7e84c3 --- /dev/null +++ b/README.md @@ -0,0 +1,139 @@ +--- +license: mit +language: + - en + - bn + - hi + - ru +tags: + - decision-engine + - system-one + - si-substrate + - intent-classification + - routing + - moderation + - spam-detection + - hebbian + - no-transformer + - no-neural-network +metrics: + - accuracy + - ece +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) + +| 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 (dedicated-fabric reference: 0.081); 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. + +## Files + +``` +engine/ C++ SI substrate core (core/*.hpp, src/*.cpp) — builds with make +server/ FastAPI HTTP bridge (v3 API, CLI-equal flags) +inference.py thin python wrapper (auto script routing) +model/ giant-{latin,bengali,devanagari,cyrillic}/substrate.bin (+meta, calibration) +datasets/ eval hidden splits, probes, schemas, MANIFEST (SHA-256), DATASETS.md +docs/ EVALUATION.md, ARCHITECTURE.md, PROBING.md, ZEROSHOT.md +examples/ JSON payloads + curl + python usage +Dockerfile HuggingFace Spaces (builds engine, serves on 7860) +``` + +## Usage (python) + +```python +from inference import SyFox +m = SyFox() # loads model/giant-