Use cases

How to code invoices to the general ledger

GL coding looks like reading an invoice. It is really classification with hundreds of classes, a long tail, and a right answer that depends on your chart of accounts and your vendor history more than on the invoice text.

The pain points

How to do it

  1. Train on posted, approved entries, with the chart as it stood on the posting date. Coding that a reviewer corrected is the label; the original clerk's guess is not.
  2. Give the prompt the relevant slice of the chart, not all of it. A lookup step can fetch this vendor's recent coding and the handful of candidate accounts for the line's category, frozen onto each row. The prompt then chooses among a short list, with definitions, rather than recalling the whole chart.
  3. Score at two levels. Exact match on the account, and match on the account group (expense versus asset versus liability) as a second metric. Weight the second heavily. A prompt that is often off by one expense line but never crosses the balance sheet is one your controller can live with.
  4. Hold out by time. Keep the most recent months out of the search, so the score says how the prompt does on invoices it has not seen, under the chart as it is now.
  5. Route what the prompt is unsure of. Ask for the account and a short reason, send low-agreement lines to a person, and record their corrections. Those become the next dataset.

Pitfalls worth checking first

PitfallWhat it looks likeHow to check, before spending anything
Chart changesOld rows coded to accounts that no longer existMap or drop rows from before a restructure.
LeakageApprover comments or posting batch predict the accountKeep only what exists when the invoice arrives: the invoice, the PO, the vendor record.
Vendor memorizationGreat on known vendors, poor on new onesHold some vendors out entirely and score them separately.
Flat accuracyFrequent accounts dominate the scoreRead the per-account table; score the account group as well as the account.
Line versus invoiceOne invoice, three correct accountsLabel and score per line, not per invoice.

References

Tools that run this loop: DSPy and its GEPA optimizer, bpto (ours, open source), and Impromptune, the studio built on it.