tiny-hash-intent / PROTOCOL.md
WideChaos's picture
Publish Tiny Hash Intent with model and experiment records
a2bd61d verified
|
Raw History Blame Contribute Delete
10.4 kB
# Tiny Hash Intent · fixed model protocol0.1
2026-11-04, before implementing or fitting this model. Work identity `work:tiny-hash-intent:v1`. One from-scratch character-hash, one-hidden-layer classifier for the 77 closed-set English BANKING77 intents, with portable int8 browser inference. It is a real new fit, not a recount of the earlier Label Budget study. Source data is reused, not newly collected or independent. The earlier study has already viewed this benchmark's test results; this protocol fixes new-model choices before evaluating the new fit, not historical blindness to BANKING77.
## Data and split freeze
Reuse exact unmodified PolyAI author CSV/category/license bytes already obtained through official CUA in `label-budget-lab-20261104/data`. Verify its SOURCE and each file hash, copy to this new directory, retain original commit links/CC BY4.0 license and Casanueva et al.2020 citation. Code Apache2; weights/data/derived experimental artifacts with CC BY4.0 attribution, not source ownership. Original category order, not HF alphabetic label ids.
The official train has10003 records and test3080. Only original train is used for fitting, validation selection and temperature choice. Trainer must not load the test CSV semantically; byte hashing for provenance is permitted. Preserve raw text/labels and every source row. Normalize for features and train/validation duplicate grouping as NFC, Unicode lowercase, then Python Unicode whitespace collapse. No stemming/translation/semantic duplicate detection. This limited text-equality grouping is not source-document/template-family metadata or an IID certificate.
For each original train row, group id=SHA256(UTF8 normalized text). Assign whole groups to validation when integer(full digest hex,16) modulo10 equals0, otherwise training. This fixed hash split is not tuned for class balance. Preserve all labels and ambiguous duplicate texts, report per-class supports and missing classes. Preflight requires at least one training example in each77class and nonempty validation; if it fails, record failure rather than silently resampling. Freeze exact membership/row ids/source hashes/config/implementation in PREFIT.json before any gradient update.
After PRETEST freeze, audit exact and normalized original train/test overlaps (both case-preserving NFC+whitespace for continuity with earlier study, and the feature-normalized lowercased form). Primary scores retain all3080officialrows. Also report a separate subset excluding feature-normalized matches to any original train row, including validation, with its actual denominator. Report actual fit/validation overlap counts separately. Never replace primary metrics or drop difficult examples.
## Fixed features and architecture
Normalize as above, wrap with literal `^` and `$`, enumerate character/code-point ngrams of lengths3,4,5, UTF8 FNV-1a32 unsigned hash modulo4096. Collisions count together, feature ids sorted ascending. Feature values=tf/sqrt(sum(tf^2)); zero feature vector handled explicitly, no dropped input. No vocabulary fit/IDF/pretrained embeddings. Accept nonblank Unicode scalar input up to2048UTF16units; reject overlength, no silent truncation. Source rows must pass this cap or the preflight fails without silent filtering.
E shape4096x64, hidden bias64, output W64x77 and output bias77. `h=tanh(xE+bh)`, `z=hW+bo`, stable softmax. Total267213 learned scalar parameters. Counts/indices for hashing are fixed feature construction; E and W are actually learned through gradients. This is not an LLM or bilingual competence claim. Closed-set predictions always select one of77; no OOD detector or rejection threshold exists.
All training arithmetic float64. Initialize E and W with independent draws from NumPy default_rng(seed123), normal(0,.05), in that parameter order; biases0. One seed/config/run, no architecture or learning-rate search. CPU NumPy only, no GPU/backend model API. Threads capped1 where runtime exposes OPENBLAS/OMP/VECLIB thread environment variables; record actual runtime and walltimes without portable speed claims.
## Optimizer and epoch selection
Minibatch128,30 complete epochs. At epoch e=1..30 shuffle training row ordinals with NumPy default_rng(2026+e). Last partial batch uses its actual size. Cross-entropy mean plus `.5*1e-4*(sum(E^2)+sum(W^2))`, no bias regularization. Add the L2 gradients before Adam (coupled L2, not AdamW).
Adam learning rate .003, beta1 .9, beta2 .999, epsilon1e-8, global step increments once per batch. `m=b1*m+(1-b1)*g`, `v=b2*v+(1-b2)*g^2`; bias-correct both by `1-beta^step`; subtract `lr*mhat/(sqrt(vhat)+epsilon)`. This explicit formula governs, not an assumed library variant. No clipping, dropout, warmup, adaptive schedule or restarts. Every parameter array and loss must remain finite; fail transparently on nonfinite values, do not silently change settings.
Each epoch record actual complete train-at-epoch-end cross-entropy and validation cross-entropy, fit steps and elapsed observations. Select lowest uncalibrated validation NLL; differences<=1e-12 tie to earliest epoch. Run all30 even if a later epoch worsens. Retain all trace points; save only the selected fit as the final model and document its selected epoch. No retraining on validation/test afterward.
Primary Adam reference inspected through its official arXiv abstract: Kingma and Ba, *Adam: A Method for Stochastic Optimization*, https://arxiv.org/abs/1412.6980 . The experimental HTML1412.6980v9 currently only references an embedded PDF and did not expose Algorithm1 text; do not claim that HTML supplied a full algorithm reproduction. This project defines/tests its own formula above, not the paper's benchmark experiments.
## Validation-only temperature
With the selected float model, evaluate T in [.5,.75,1,1.25,1.5,2,3] on validation NLL `logsumexp(z/T)-z_gold/T`. Choose lowest NLL, within1e-12 tie to closestTto1 then smallerT. Save all candidate values/support. This is a finite grid, not an exact continuous optimum. No new training gradients for T. Same T inherited by quantized export; no test-guided temperature or abstention threshold selection.
Method reference: Guo, Pleiss, Sun and Weinberger2017, *On Calibration of Modern Neural Networks*, https://arxiv.org/abs/1706.04599 . Official abstract and available HTML inspected; no claim of reproducing its architectures or results. Temperature cannot establish OOD safety, correctness of individual probabilities or general calibration.
## One post-training int8 representation
Quantize selected E per row and W per output column. Scale=max(abs(values))/127, or1 for all-zero slice. `q=clip(round-to-nearest-even(values/scale),-127,127).astype(int8)`. No -128, no QAT or new fit. Store int8 values as two's-complement bytes in base64, scales as finite float64 JSON numbers, biases unquantized float64. Keep exact dimensions/labels/preprocessor/T/version in portable JSON; validate lengths, all finite arrays, positive scales and supported schema. Never load pickle.
The browser performs code-point preprocessing/FNV/count-L2, dequantization and tanh/softmax locally using standard JS. Input editing clears stale results/exports, async initialization respects newer edits; initial fixed model asset GET only, no query network/storage/CDN/API. Show top3 labels with normalized known-class scores, explicit closed-set/English-only/OOD limitation. Export current input/config/model identity/predictions only after explicit action, warn that input is included. No financial advice, actual account operations or production routing decisions.
## Model-specific test freeze and complete metrics
Before this model first scores official test, freeze selected float `.npz`, portable int8JSON, chosen epoch/T/validation log/implementation/config/source/membership hashes in PRETEST.json. Distinguish this from prefit and prior knowledge of the benchmark. One learned model, four representations/evaluation modes: float T1, float selectedT, int8 T1, int8 selectedT. These are not four independently trained models.
Evaluate every official test row in every mode: accuracy, macroF1 across77classes(0 for undefined class F1), NLL from stable logits, multiclass Brier=sum_c(p_c-onehot_c)^2, and descriptive top-confidence ECE10. Bins[0,.1),...,[.9,1], index=min(9,floor(confidence*10)); keep each bin's count/meanconfidence/accuracy, empty meansnull, ECE=sum(n_bin/N*abs(meanconfidence-accuracy)). ECE depends on these bins; no confidence interval/general guarantee. Argmax uses unscaled logits (T should not alter class), lowest id on actual float tie; float/int8 disagreement ids/count and all negative changes retained. Different floating algebra/platform may change near ties, no universal bit-identical prediction claim.
Save all row ids/gold/prediction/maxprob/p_gold/NLL/Brier for all4modes, full class support/confusions and actual nonoverlap subset scores. Save raw validation/test logits for float and int8 for independent metric reconstruction. Never count model reload/evaluation/calibration/quantization as another training run. Original train/test hashes/splits unchanged.
## Acceptance and publication
Before fit: small finite-difference gradient check on an independent tiny D/H/C case over all parameters, hand forward/softmax/NLL cases, Adam scalar first-step/bias correction, feature/hash/Unicode/limits tests. After fit: actual reload identical saved model, independent parameter update/feature/forward/metric calculations and raw-row reconstruction, independent total-output actual re-fit if feasible, all negative/quantization/calibration outcomes kept.
Actual hidden official CUA browser inference and native report download required; compare floating outputs and class ids with the int8 Python representation over predefined ordinary/Unicode/empty/overlength/script-shaped examples. Bounded tolerance for scores and all discrepancies reported, not hidden by relabeling. Desktop/390layout, source network/log checks, no fake DOM-only model execution. Training traces/figures use saved actual data, no cherry-picked epoch deletion. Clean license/attribution, exact manifest, independent total review before later daily HF publish; today none. Public App/files/download/HTTPS/free conditions only proven on actual publication, local acceptance is not deployment/adoption.