A working product.
An inspectable implementation.
Margin Desk combines an evidence-led supplier workflow with reproducible machine-learning demonstrations. The application’s financial checks are deterministic. The model examples below are trained on synthetic data and do not establish production accuracy or money owed.
The financial checks come first.
Amounts use integer minor units. Agreed-price and receiving evidence determine a finding. Historical prices and missing records cannot be confirmed as claims. Partial credits reduce a specific case’s outstanding amount; duplicate imports and reused credit references cannot silently increase value.
The interactive workspace runs locally in your browser. Imported CSVs, case decisions, and credits are stored in that browser profile. Email-and-password sign-in uses server-validated sessions with public registration disabled. Authentication records are stored on this installation; invoice records remain in browser storage. PDF/image OCR, accounting integrations, and shared ledgers are not part of this demonstration.
Document classification, trained with PyTorch.
A small linear text classifier learns five document categories. Its exported weights run directly in the browser, with no model API or remote inference. Unknown vocabulary and low model scores produce a review result.
Held-out phrasing template per class; synthetic and limited. Not unseen real suppliers. The majority-class baseline is 20%. The review threshold can abstain even when the highest-scoring category is correct; this accuracy is measured before abstention. This intentionally simple dataset is proof of a runnable training/export/inference path, not proof that real supplier documents will perform similarly.
Price signals, trained with TensorFlow.
A small neural model estimates the next unit price from six consecutive values. Evaluation holds out complete synthetic price series. Its signal is separate from the reconciliation engine and cannot create or confirm a financial claim.
Last-price baseline error on the same held-out set: 1.47%. Selected inference: trained neural model. The simple baseline remains the fallback when the neural model does not improve this measure.
Self-hosted language-model drafting.
The optional drafting integration uses a configured local service. It never falls back to a cloud model. The workspace’s initial supplier request is a transparent fixed template; a separate action requests a model rewrite. Numbers and references are checked before a model suggestion is shown.
The default application does not download a model or enable drafting automatically. The repository includes a loopback-bound Python service and setup instructions. A model suggestion always needs human review.
# Download the small demonstration model once python3 ml/serve.py --download # Serve cached weights locally, without runtime downloads python3 ml/serve.py # Configure the application in .env.local LOCAL_LLM_URL=http://127.0.0.1:8048/v1/chat/completions
Reproduce, inspect, challenge.
Training seed: 41. Frameworks exercised: PyTorch 2.6.0 and TensorFlow 2.19.1. Retrain both examples and regenerate their artifacts with the command below. Detailed datasets, limitations, and checks are included with the project.
bun install --frozen-lockfile bun test bun run typecheck python3 ml/train.py bun run build
- No real supplier validation.
- Classifier confidence is not calibrated.
- The price model is illustrative and must never establish a claim.
- No production model accuracy or customer savings are claimed.