Technical documentation · stage18 · Guard
How it works.
What was measured.
Architecture, typed heads, training recipe and held-out experiments behind this demo. Decidora is one encoder pass with four typed heads. Guard is a separate linear model over hashed character n-grams. Neither model generates text. The public Decidora demo is read-only: 13 fixed cases, precomputed answers.
English model
Stage18 at a glance
| parameters | 14 239 236 |
|---|---|
| encoder | 12 post-LN blocks, hidden 256, FF 1 024 |
| attention | 4 heads, attention head 64, typed head 128 |
| embedding | 128, WordPiece vocabulary 30 531 |
| positions | 1 024, separate tables for state and question |
| state | 384 max, 383 input tokens after the marker |
| question | 192 tokens |
| options | 2-32 for choice and score |
| span | 32-token window |
| bundle | int8 14.61 MB; fp32 source, q4 8.15 MB |
| runtimes | PyTorch, NumPy, PHP, JavaScript; Rust noul only |
Mechanics
One pass, four heads
Pick one option
The answer row and each option embedding are projected and scored by a dot
product. Softmax over 2-32 options produces probabilities,
pick and confidence.
Score a statement
A scalar projection of the answer row, then sigmoid. The output is
p: how likely the statement is true. Thresholds are applied
outside the model.
Rank an ordered level
The same option scoring over an ordered list. The expected value is a weighted
index 0..1, so score is ordinal, not a free-form number.
Extract a fragment
Start keys over state tokens, a null-start option and end queries. The best start opens a 32-token window; the end token is chosen inside it. Stage18 uses batched non-joint span.
Input layout: one state block plus one block per question. A block mask lets each question see the state and itself only. The state is silently truncated to 383 tokens; an overlong question is rejected. Multi-question answers do not depend on question order. No autoregressive decoding is involved.
Multilingual model
Guard
| parameters | 2 097 153, one float32 weight per bucket plus bias |
|---|---|
| features | char 2-5 grams, words, URL/host/TLD, email domain, script, message features |
| hash | FNV-1a 64 into 221 buckets |
| pooling | mean of feature weights, plus scalar bias, sigmoid |
| window | 1 536 characters, chunk 1 536 / stride 768, max-pooled logits |
| calibration | per-language temperature and FPR-5% threshold; long-payload threshold |
| language | 22 languages, one shared model; not a language detector |
| normalization | NFKC, format-character removal, lowercase, whitespace collapse |
Guard is not a multilingual Decidora: it returns spam/ham only, without
choice, score or span. Character n-grams make it
script-agnostic and cheap on CPU. English antispam goes to Decidora; non-English
antispam goes to Guard.
Release
Training recipe
| base | stage17b_noul.pt; stage18 is release 0.8.0 |
|---|---|
| data | stage15 train plus rebuilt transactional rows; dedupe by state, task, text |
| run | 1 epoch, batch 32, lr 2e-5, warmup 3%, AMP bf16, RTX 4060 |
| best step | 3 000 |
| changes | shuffled choice options, invalid span labels skipped, batched span |
| head flags | span_joint=False, span_null=True, span_v2=True |
| fit policy | thresholds and temperatures fitted on dev only |
Experiments
Stage18 variants
| variant | span SQuAD EM | entity exact | transactional | CLINC / BANKING / SST-5 | choice flips |
|---|---|---|---|---|---|
| stage17b joint archive | 0.461 | 9/19 | TPR 1.000, FPR 0.003 | - | 26.7% |
| stage18 batched release | 0.324 | 10/19 | acc 1.000, TPR 1.000, FPR 0.000 | 0.959 / 0.921 / 0.480 | 15.8% |
| stage18c span-only | 0.336 | 10/19 | acc 1.000, FPR 0.000; SMS TPR 0.949 | 0.960 / 0.918 / 0.469 | 16.7% |
| stage18d joint | 0.483 | 12/19 | FPR 0.138 | 0.944 / 0.870 / 0.429 | - |
Stage18d recovers span quality but regresses noul and
choice, so it did not ship. Stage18 is the compromise: lower span EM,
other heads in normal range. Stage17b remains archived.
Antispam
Transactional and SMS
| release | transactional | SMS | note |
|---|---|---|---|
| stage16b | FPR 0.527 | TPR 0.983 | previous |
| stage17b | TPR 1.000, FPR 0.003 | TPR 0.949 | archived |
| stage18 | acc 1.000, TPR 1.000, FPR 0.000, n=483 | acc 0.983, TPR 0.932, FPR 0.011 | current |
SMS threshold 0.7847 and antispam-v3 threshold 0.8995 are domain-specific. Do not move them to another domain without fitting on that domain's dev split.
Guard
Held-out numbers
| slice | metric |
|---|---|
| dev | AUROC 0.9876 |
| long payload v2 | AUROC 0.9983 |
| long payload test | TPR 0.967, FPR 0.012 |
| native Turkish SMS, n=973 | AUROC 0.9974 |
| native Chinese, n=1 195 | AUROC 0.955 |
| Spanish template, n=86 | AUROC 0.820 |
Runtimes
Conformance and speed
| engine | stage18 max gap | noul int8 p50 |
|---|---|---|
| PyTorch | reference | 6.8 ms |
| NumPy | 7.83e-6 | 8.5 ms |
| PHP + C kernel | 1.24e-5 | 5.4 ms |
| PHP pure, this demo | 1.24e-5 | 0.44-0.76 s uncached; read-only samples 0.5 ms |
| JavaScript, Node | 2.70e-6 | 219 ms |
| Rust | noul only, 1.2e-7 | 28.3 ms |
| Guard PHP | 35/35 features, max p 1.3e-5 | 6.9 ms SMS |
Full engine matrix and demo measurements: engines.html.
Conformance thresholds are 1e-4.
Honest limits
What the models do not do
English only
Stage18 does not support non-English choice, score or
span. Non-English antispam goes to Guard.
Span is the weak head
Stage18 batched span EM 0.324 is below joint 0.461. Entity extraction is the
main quality gap; p_present does not filter wrong answers.
Choice order matters
Permuting options flips 15.8% of choices. Shuffling during training helped from 26.7%, but option-order isolation is not solved.
Thresholds are domain-specific
SMS and antispam-v3 thresholds do not transfer. Fit them on the target domain's dev split and keep FPR separate for SMS, email and language.
Guard is not uniform
Weak slices: pa TPR@5% 0.746, zh 0.879,
tr 0.828, es 0.917. 14 languages are translated SMS
only.
Commercial demo, research weights
This is a commercial demo, not a safety filter. The underlying weights are research builds; several training corpora are GPL, CC BY-NC or unlicensed, so redistribution rights still need an audit.
Reproduce
Checks
| tests | .venv\Scripts\python.exe -m pytest -q |
|---|---|
| cross-engine | scripts/e2e_bench.py --iters 5 |
| Decidora PHP | ports/php/conformance.py |
| Guard JS | ports/js/guard_conformance.py then node ports/js/guard_conformance.mjs |
| Guard PHP | php ports/php/guard_example.php release/decidora-13.8m-stage18/guard "text" ru |
Sources: docs/RESULTS.md, docs/STAGE18.md,
docs/TRANSACTIONAL.md, docs/GUARD.md. Built by
GLOBUS.studio and
Leonidov Yevhen.