跳到正文
DEV Community· Arin Dewangan·· 3 小時前AI 評分32

LatePay:預測哪些發票可能逾期未付

LatePay — know which invoices will ghost you, before they do 💸

AI 導讀

LatePay 以開源 TabPFN v2 預測發票逾付款條款超過 30 天才付款的風險,並按風險級別提供跟進建議。系統以 4,000 張模擬發票建立數據集,推理時採用分層抽取的 1,000 張發票作上下文,亦支援批量評分 CSV。推理在本機 CPU 執行,無需 API key 或專有模型;示範頁的預測均預先計算並標示為模擬,工具聲明結果並非財務建議或信用評分。

正文

LatePay — know which invoices will ghost you, before they do 💸

DEV Hacktoberfest AI Challenge — Week 2: Side Hustle.


Every freelancer knows the feeling: the work is delivered, the invoice is sent, and then… silence. Cash flow is the oxygen of a side hustle, and one late payer can choke it for a month.

So I built LatePay — a late-payment risk predictor that scores every outstanding invoice with TabPFN, the open-source tabular foundation model, and tells you what to do about it: chase now, ask for partial upfront, send a reminder, or relax.

🔗 Live demo: https://arindewangan.github.io/latepay/demo/ (precomputed TabPFN outputs, clearly labeled simulated)
💻 Repo: https://github.com/arindewangan/latepay

What it does

  • Score an invoice — enter the amount, client history (tenure, prior late rate, average days to pay), contract strength, and payment terms. TabPFN returns P(paid > 30 days past terms) as a risk band: HIGH / MEDIUM / ELEVATED / LOW.
  • Get one clear action — HIGH → chase now and pause further billable work; MEDIUM → require 50% upfront before the next milestone; ELEVATED → send a polite nudge on the due date; LOW → normal terms.
  • Batch-score a CSV — upload your invoice list and download a scored risk report with a recommendation per row. Missing history columns fall back to an honest new-client baseline.
  • Explore offline — the static demo ships 4 real client profiles plus a what-if grid (late rate × contract × amount), every cell a real precomputed TabPFN prediction, build-dated and labeled simulated.

How it's built

A Python/Flask backend with a vanilla HTML/CSS/JS frontend. The pipeline:

  1. data/build_dataset.py generates a SIMULATED invoice-history dataset (4,000 invoices, seeded RNG) with 12 features per invoice — amount, client tenure, prior invoice count, prior late rate, average days to pay, contract strength, payment terms, client size, international flag, invoice month.
  2. At request time, TabPFNClassifier(device="cpu") — fitted in-context on that dataset in risk.py — predicts the late-payment probability for the new invoice. No gradient training, no API key, no proprietary models.
  3. The GitHub Pages demo bakes real precomputed TabPFN outputs via demo/build_demo.py (build date stamped on the page) so it works with zero backend.

The honest hard parts

TabPFN's license gate. The latest tabpfn releases (≥2.1) demand interactive license acceptance at install time — a non-starter for a fully automated pipeline. So requirements.txt pins tabpfn==2.0.6 — the same version that proved itself in our Week 1 build (Frostwise). Same proven path, zero new surprises.

Attention is O(n²) on CPU. Our dataset has 4,000 simulated invoices, but fitting TabPFN in-context on all 4,000 rows made per-request inference painfully slow on CPU. The trade-off, documented in risk.py: a seeded, label-stratified 1,000-row subsample as the inference context — per-request scoring stays in the seconds range. The full 4,000-row CSV still ships as the data artifact; the demo's precomputed grid used the same setup.

Synthetic data means synthetic confidence. The model learned real, sensible patterns — a clean client scores 5.0% late risk, a serial late-payer 63.4% — but it has never seen a real invoice. That's why every demo screenshot, every CSV row, every UI badge says SIMULATED, and the README states plainly: these are risk estimates for prioritising follow-ups, not financial advice, not a credit score.

What I'm proud of

  • Real open-source-AI core: local TabPFN inference on real (simulated) tabular data, reproducible end-to-end from the repo — no API keys, no proprietary models, no fake "AI" labels.
  • An honest demo: every number on the static page is a real precomputed TabPFN prediction, build-dated and labeled SIMULATED.
  • CSV batch scoring that degrades gracefully — missing history columns fall back to a new-client baseline instead of erroring.
  • A UI a non-technical freelancer can actually use: one form, one gauge, one action.

What I learned

Technical: TabPFN genuinely collapses tabular ML to a one-liner — fit in-context, no training loop, no feature engineering — and the risk separation it produced was immediately sensible (5.0% LOW vs 63.4% HIGH). For a prioritisation tool like this, calibration across bands matters far more than any single accuracy number.

Process: honesty is a feature, not a tax. My first banner render shipped with an invented "94.2% accuracy" line in the artwork — I threw it out and regenerated it clean. Labeling simulated data visibly, pinning versions honestly, documenting the 1000-row trade-off: the write-up is stronger for every one of those, and this challenge weights writing most heavily.

What's next

  • Let freelancers import real invoice history (Stripe/Invoicely exports) so the context set is their own data, not simulated.
  • Per-client portfolio view: total at-risk revenue across all outstanding invoices.
  • Email reminder templates wired to the ELEVATED band's nudge schedule.

How it uses open-source AI

LatePay's risk core is TabPFN v2 (tabpfn, an open-source tabular foundation model). We generate a simulated invoice-history dataset locally, and TabPFN fits in-context on it and predicts P(payment > 30 days past terms) per invoice at inference time — all on local CPU. No proprietary models or API keys are involved anywhere in the pipeline.


Built with: Python, Flask, TabPFN (open-source), JavaScript. License: MIT.

來源:DEV Community · dev.to