Skip to content

Extraction Tiers ​

Waspada AI uses a two-tier extraction system that balances speed, accuracy, and resource usage.

Tier 1: Regex Engine (Deterministic) ​

Always available. Zero model download required.

The regex engine runs instantly and handles the majority of Malaysian financial document patterns:

PatternExampleRegex
Malaysian NRIC880101-14-5678\d{6}-\d{2}-\d{4}
Bank Account (8-17 digits)1234567890\d{8,17}
SWIFT/BIC CodeMBBEMYKL[A-Z]{4}MY[A-Z0-9]{2}
Phone (MY format)+60123456789\+?60\d{9,10}
URLshttps://scam.comStandard URL regex
Transaction AmountRM 1,500.00RM\s*[\d,]+\.?\d*

Supported Banks (BIC Resolution) ​

BankBIC Code
MaybankMBBEMYKL
CIMBCIBBMYKL
Public BankPBBEMYKL
Hong LeongHLBBMYKL
RHBRHBBMYKL
AmBankAMMBMYKL
Bank IslamBIMBMYKL
Bank RakyatBKRMMYKL
Alliance Bank / Alliance IslamicAFBQMYKL / MFBBMYKL
Affin BankARBKMYKL
OCBCOCBCMYKL
UOBUOBBMYKL
HSBCHBMBMYKL
Standard CharteredSCBLMYKX
BSNBSNAMYK1
AgrobankAGOBMYKL
Bank MuamalatMBABOREA
GXBankGXSPMYKL
Touch 'n GoTNGDMYNB

Measured accuracy ​

Noisy figures are in-sample, post-fix on the corpus that surfaced the bugs — a characterized error inventory + regression floor, not a holdout generalization estimate. See package EXTRACTION_METRICS.md.

Clean CI gate (regression floor) ​

Corpus 2026-07-11 — 37 synthetic Malay receipt layouts (Tier-1 regex).
Hard gate: P ≥ 0.90 and R ≥ 0.85 on account + BIC. Clean text near-perfect is expected for this contract — not a claim about production OCR.

FieldSupportNotes
mule_account_number29No errors on clean layouts (gate PASS)
mule_bank_bic32No errors on clean layouts (gate PASS)
scammer_alias35Tracked; not the hard gate
malicious_urls3Tracked; small support

Noisy / adversarial soft gate (bank conversation surface) ​

Corpus 2026-07-26-noisy — 21 OCR-mash / adversarial layouts.
Soft gate: P ≥ 0.85 and R ≥ 0.80 on account + BIC.

Outcome (account)CountMeaning
Correct14Match
Miss (no account)2Safe failure — costs coverage
Wrong account1Line-wrap truncation (5642… → 23456789)

Honest register: ~90% of account outputs correct under adversarial text (n=21, wide CI). About 1 in 15 account outputs was the wrong account — which is why nothing we emit is a freeze instruction, and why actionable requires three independent institutions on the same account.

FieldSupportHonest summary
mule_bank_bic19No errors observed on these 19 samples — not “100% across MY banks × OCR”
scammer_alias21~1 miss (merchant SDN BHD / person-name filter)
malicious_urls1Not meaningfully measured — omit from pitch tables

Priority gap: line-wrap account join (only failure that emits a different real-looking account). Phone-shaped 6012… miss is a deliberate phone/NRIC-vs-account tradeoff.

CI gate scope

Hard gate = Tier-1 regex on clean labeled text. Soft gate = noisy account/BIC floors. Neither covers span-NER regressions, image-to-OCR end-to-end, or a held-out set. Holdout (label once, score once, never tune) is the follow-up before quoting out-of-sample accuracy.

DuitNow QR (no account on the slip) ​

Many DuitNow QR receipts never show a recipient account number — only a name and sometimes a bank/e-wallet. The eval corpus labels those as mule_account_number: null on purpose. Inventing an account from a DuitNow reference ID is a false positive. Product response: extract alias/BIC when present, keep disposition advisory, and ask the user for a second (account-transfer) slip when possible.

Tier 2: SpanNER v2.1 Engine (Biaffine Pointer) ​

SpanNER v2.1 (waspada_span_ner_q8.onnx, 14.6 MB native ANE Core ML / 15.3 MB web weight-only DequantizeLinear INT8) loads from the same origin as PP-OCRv5 (3.29 ms ANE p50, 28.18 ms warm .mlmodelc load). It slices exact character spans out of text already on the device (0.959 regex-off account F1 on the 10-receipt gauntlet; noisy full-page person F1 is 0.104, disclosed transparently so regex and DuitNow QR TLV retain ownership of hard routing fields). It never generates digits.

A person span can fill scammer_alias only when the routing rules already allow it. qrMerchantName and a corporate Sdn Bhd name are excluded. Regex and the QR still own account numbers and BICs.

When Tier 2 Activates ​

Tier 2 only runs when Tier 1 results are incomplete:

Regex extracts account + BIC + alias → REGEX_ONLY (skip NER)
Regex extracts account + BIC only   → Run NER for alias → HYBRID
Regex extracts nothing              → Run NER for all  → NER_ENCODER

Performance Optimization

For 95%+ of digital bank receipts, Tier 1 Regex is sufficient. The NER model is only invoked for ambiguous, informal, or handwritten evidence where regex patterns fail.

Extraction Tier Labels ​

TierMeaningTypical Latency
REGEX_ONLYAll indicators extracted by regex< 10ms
NER_ENCODERNER model used for extraction100-200ms
HYBRIDRegex + NER combined100-200ms

On-device scam shield, hardware-attested receipts, and MONITOR-only bank advisories.