# malha

> SPED-native RLVR environment for Brazilian accounting agents, priced in Lei 8.218/1991 statutory fines. Deterministic-first hybrid VLM agents with a fail-closed Trust Ledger and pixel-level scan inspection decisively beat both SPED rules (+10,020 BRL/world) and Tesseract OCR regex on noisy scans (+5,084 BRL/world).

- Tags: AI, Evals, Research
- Author: Caio Theodoro (https://caio.theodoro.dev/about.md)
- Canonical HTML: https://caio.theodoro.dev/projects/malha
- Source repository: https://github.com/caiotheodoro/malha
- Hugging Face: https://huggingface.co/collections/caiotheodoro/malha-6b071d26ff68721ad0fcabb4
- Live: https://doi.org/10.5281/zenodo.24589622

---

A company that cai na malha fina was caught by the Receita Federal’s cross-validation between a taxpayer’s own digital filings. Malha turns that net into a training ground: a generator produces a synthetic Brazilian company’s complete fiscal year — invoices, journal, ledger, the ECD and EFD-Contribuições filings — injects defects from a frozen 15-class taxonomy, and scores an agent’s audit in the reais the law actually charges. The oracle is the government’s own validation spec. No model sits inside the verifier.


## Pre-registered, honest negative

- No agent arm beats the deterministic rules engine yet — published as the pre-registered negative branch
- gemini-hydrogen: 12,331 BRL mean loss vs the engine’s 9,140 — interval crosses zero
- deepseek v4-pro: 13,955 — decisively worse than the engine, +4.8k CI [+1.3k, +8.8k], separated
- Free-tier SFT→GRPO on qwen3-8b: zero outcome variance across 4 seeds — a measured dead end at this model class, on $0 of compute

Binary evals cannot tell an agent that misses R$40,000 of unrecorded revenue from one that flags 53 phantoms — both are "wrong". Pricing them in statutory fines can. This is the measurement infrastructure behind the accounting-agent product bet.

---

## Writing about this project

- [Malha: Priced, Not Passed — What Accounting Agents Actually Lose (and Win) in a SPED Audit](https://caio.theodoro.dev/blog/malha-priced-not-passed.md)

All projects: https://caio.theodoro.dev/projects.md · About the author: https://caio.theodoro.dev/about.md · Machine-readable index: https://caio.theodoro.dev/llms.txt
