also you can just download the model look at the model reader and implement it yourself I'm gonna make a v1.1 (download: https://huggingface.co/oddlogiclab/SN-V-T-1.0-109989-111726/resolve/main/sn_mnist_qmnist.spuf?download=true)
SN β Statistical Network on MNIST
A Statistical Network (SN): a custom autoregressive statistical model made of PPMI bigrams + skipgrams + structure bias. It classifies MNIST digits encoded as 0/1 pixel strings and stores its parameters in a custom binary container format called SPUF (Statistical Probability United Format).
Unlike gradient-trained classifiers, this model is purely count-based β it learns by incrementally counting co-occurrences. There are no learned weight matrices, no backpropagation, and no optimizer.
This repository contains the pretrained SPUF model files, the SPUF format specification, and the measured evaluation results.
Results (real, measured)
| model | counts added | MNIST 10k test accuracy | ms/image |
|---|---|---|---|
| SN trained on MNIST 60k | 60,000 sequences | 83.84 % (8384/10000) | 0.61 |
| SN + QMNIST addition | +49,989 new sequences β 109,989 total | 84.14 % (8414/10000) | 0.60 |
Weights were tuned on a held-out 5k split of the MNIST train set (never part of the test set). After the QMNIST addition the val split is inside the counts (full-sequence memory memorizes it), so the augmented model keeps the MNIST-only tuned weights β re-tuning there would be circular.
Per-digit recall (QMNIST-augmented model, MNIST 10k test)
0: 93.9% 5: 57.6%
1: 94.5% 6: 90.9%
2: 75.7% 7: 82.1%
3: 74.9% 8: 86.9%
4: 93.7% 9: 88.2%
latency: 0.60 ms/image (CPU, sandbox)
Confusion matrix (rows = true, cols = predicted)
0 1 2 3 4 5 6 7 8 9
0: 920 0 5 0 0 11 7 1 33 3
1: 0 1072 4 26 2 22 7 1 1 0
2: 6 2 781 121 7 26 50 10 25 4
3: 2 26 32 756 1 124 2 18 31 18
4: 1 0 4 0 920 4 9 2 10 32
5: 6 13 22 268 1 514 11 45 5 7
6: 9 5 44 4 8 9 871 0 8 0
7: 3 23 13 10 7 19 0 844 11 98
8: 15 1 10 59 3 20 7 6 846 7
9: 7 5 5 4 31 5 0 39 23 890
The weakest digit is 5 (mostly confused with 3) β expected for a pure count-based model without position-exact templates. The QMNIST addition improved it from 6.7 % (first raw version) β 57.0 % β 57.6 %.
Baseline comparison (same official 10k test set)
| model | accuracy |
|---|---|
| MLP 784-256-10, standard normalized pixels | 97.95 % |
| MLP 784-256-10, binarized bits (SN's exact input) | 97.62 % |
| LeNet-style CNN, standard normalized pixels | 98.68 % |
| LeNet-style CNN, binarized bits | 98.67 % |
| SN (MNIST counts only) | 83.84 % |
| SN (+ QMNIST counts) | 84.14 % |
The gap between SN (84 %) and a CNN (98.7 %) is the honest cost of a pure
count-based model with no learned weights β which is the model the spec asked for.
Model description
Vocabulary (13 tokens)
<image>, <prediction>, <im_end>, and "0".."9".
,and|are separator characters only β never vocabulary tokens.<eos>is a training-control sentinel, not a vocabulary token.- Bit tokens
0/1double as digit labels (one shared vocabulary; the token before a digit is always<prediction>).
Strict training / inference string
The model splits on , and |:
<image>|(encoded image string)|<prediction>|(number)|<im_end>|<eos>
<image>β tells the model an image follows- bits β
0= black,1= white, row-major, comma-separated (MNIST grayscale binarized at >128: ink β white) <prediction>β tells the model it must predict the number now(number)β the digit 0..9<im_end>β ends generation<eos>β stops training; never counted, never generated
Model components
- Bigrams β standard n-gram counting, bigram only, over the SN vocabulary (787 bigram positions per sequence).
- PPMI β bigram and skipgram co-occurrences re-scored with Positive Pointwise
Mutual Information. The runtime scoring uses log-LIFT
log(P(digit | match) / P(digit))with m-estimate smoothing (equivalent sample size 10), so rare patterns shrink to the prior. - Skipgrams β the same counting machinery at distances 2 and 3.
- Structure bias β the runtime booster:
- at every pixel, a left/right window of
2r+1bits is examined (radii 6 and 8, plus a 14-band position key packed above the window bits); - any previously seen window pattern boosts the tokens that followed such sequences β digit-association votes (window β digits) and next-token votes (window β following token);
- the bias also encodes entire sequences: exact image strings and all suffixes (4..12 bits) are FNV-1a-64 hashed into count tables;
- weights (per radius, seq, suffix) tuned on the held-out split.
- at every pixel, a left/right window of
Prediction is strictly autoregressive: from <image>|<bits>|<prediction>| the model
computes next-token scores, emits the digit, then emits <im_end> and stops.
<eos> is never generated.
Training
Training is incremental: counts only grow. The QMNIST step literally calls
train() again on the loaded model with more sequences β "just add more information
to the model since it's just counts".
Intended uses
- Research / educational demonstration of a fully count-based autoregressive classifier.
- Format demonstration β a working reference for the SPUF binary container.
Out-of-scope uses
- Production handwritten digit recognition. Accuracy (
84 %) is far below standard CNN baselines (98.7 %). Use a CNN for any real-world OCR task. - General-purpose image classification. The model is specialized to 28Γ28 binarized MNIST-style digits.
- Any setting requiring calibrated probabilities or robustness to distribution shift β the model is a lookup/counting model and has no generalization mechanism beyond shared patterns.
Limitations
- Low absolute accuracy (~84 %) compared to gradient-trained models. This is by design: the model contains no learned weights.
- Sensitive to input preprocessing. The model expects exactly the strict string format with binarized pixels; different binarization or layout will drastically reduce accuracy.
- Weak on visually similar digits β e.g., 5 is frequently confused with 3.
- No probabilistic calibration. Scores are count-derived log-lifts, not posterior probabilities.
- Tuning caveat. Weights were tuned on a held-out 5k split; after QMNIST augmentation that split is inside the counts, so re-tuning on it would be circular and is deliberately avoided.
SPUF format
The model is stored in SPUF v1 (Statistical Probability United Format) β a custom little-endian binary container with:
- length-prefixed UTF-8 strings, IEEE-754 floats;
- CRC32 checksums, zlib-compressed sections;
- FNV-1a-64 as the single hash;
- a sorted key/value META section with a direct
meta_offsetpointer in the header, so metadata (credits, weights) is binary-searchable directly from the file.
Byte-level spec: SPUF_SPEC.md (in this repository).
How to use
# Minimal read + metadata search, mirroring the source repo's spuf_cli.py
from sn import spuf # from the source repo: reference/sn/spuf.py
model = spuf.load("sn_mnist_qmnist.spuf")
print(model.info())
print(model.search_meta("credits"))
A full CLI (info, meta, get, search, verify, dump) ships in the source
repo. Requires Python 3.10+ and numpy.
Training data
- MNIST β 60,000 training images, 10,000 test images (Yann LeCun, Corinna Cortes, Christopher J.C. Burges).
- QMNIST β
facebookresearch/qmnist; the 50k new-writer images of its extended test split were added to the counts. The 10k MNIST-test replicas were verified by hash and excluded β 11 binarized duplicates were found and filtered, keeping the test set clean.
Evaluation data
- Official MNIST 10k test set β used unchanged for all reported accuracies.
Files in this repository
README.md this model card
LICENSE MIT
SPUF_SPEC.md byte-level SPUF v1 specification
sn_mnist.spuf SN trained on 60k MNIST (2.2 MB)
sn_mnist_qmnist.spuf + 49,989 QMNIST counts (3.1 MB)
metrics_mnist.json 10k-test metrics (MNIST-only model)
metrics_qmnist.json 10k-test metrics (augmented model)
Source code
The training pipeline is inside this Huggingface repository.
Citation
@misc{sn_vision_2026,
title = {SN-V-T-1.0-109989-111726: Statistical Network Vision},
author = {{Oddlogic Lab}},
year = {2026},
howpublished = {\url{https://huggingface.co/oddlogiclab/SN-V-T-1.0-109989-111726}},
note = {Experimental statistical vision architecture using PPMI Bigrams, Skipgrams, and Structure Bias, stored in SPUF v1}
}
Underlying Datasets
@article{lecun1998gradient,
title = {Gradient-based learning applied to document recognition},
author = {LeCun, Yann and Bottou, L{\'e}on and Bengio, Yoshua and Haffner, Patrick},
journal = {Proceedings of the IEEE},
volume = {86},
number = {11},
pages = {2278--2324},
year = {1998}
}
@inproceedings{yadav2019qmnist,
title = {Cold Case: The Lost MNIST Digits},
author = {Yadav, Chhavi and Bottou, L{\'e}on},
booktitle = {Advances in Neural Information Processing Systems 32 (NeurIPS 2019)},
year = {2019}
}
License
MIT. See the LICENSE file for full text.