Finance AI

ML Invoice Classification: Auto-Sort to the Right GL Code

Manual GL coding is the slowest step in invoice processing. Here's how machine learning classifies invoices to the correct general ledger code with 90-95% accuracy.

Ken

Ken

AI Finance Assistant

·7 min read
Listen to this article (2 min summary)
0:00--:--

A controller at a 300-person SaaS company told me her AP team spends more time picking GL codes than reviewing the invoices themselves. Four people, 800 invoices a month, and an average of 3.2 minutes per invoice just on coding. That is 42 hours a month — more than a full work week — spent on a task that is essentially pattern matching: "this vendor always goes to 6200-Marketing, that one goes to 5100-Cloud Infrastructure."

Machine learning invoice classification eliminates this bottleneck by learning from your historical coding decisions and applying them to new invoices automatically. Not with rigid rules. Not with lookup tables that break when a vendor changes their invoice format. With models that understand context.

Why GL Coding Is the Hidden Bottleneck in AP

Invoice data extraction gets all the attention. OCR accuracy, field-level extraction rates, header versus line-item parsing — these are the metrics vendors love to showcase. And they matter. But extraction answers "what does this invoice say?" GL coding answers "where does this expense go?" — and it is the harder problem.

Here is why. A typical mid-market company has 200 to 500 active GL codes. The chart of accounts was built over years, with codes added for specific projects, departments, and reporting requirements. Half the codes are rarely used. Some are nearly identical (is this software subscription 6200-SaaS or 6210-Cloud Services?). New AP clerks take 3 to 6 months to learn the coding patterns, and even experienced staff disagree on borderline cases 15 to 20% of the time.

Manual coding creates three cascading problems:

  1. Speed — GL coding adds 2 to 5 minutes per invoice, turning a 500-invoice month into 25+ hours of pure classification work
  2. Accuracy — APQC data shows manual coding error rates of 3 to 8%, meaning 15 to 40 invoices per month land on the wrong account
  3. Month-end pain — every miscoded invoice becomes a journal entry correction during month-end close, adding 1 to 2 days to the cycle

The real cost is not the coding time itself. It is the rework downstream. A miscoded invoice flows through approval, payment, and into your general ledger before anyone catches it. By then, fixing it requires a journal entry, a reconciliation update, and sometimes a restatement of departmental budgets.

How Machine Learning Classifies Invoices

Machine learning invoice classification works by training a model on your historical coding decisions — every invoice your team has coded in the past 12 to 24 months — and using those patterns to predict the correct GL code for new invoices.

The process follows three stages:

Stage 1: Feature Extraction

The model does not just look at the vendor name. It extracts a rich set of features from each invoice:

  • Vendor identity — name, tax ID, industry classification
  • Line-item descriptions — the actual text describing what was purchased
  • Amount patterns — total amount, per-unit pricing, tax treatment
  • Historical context — how this vendor's invoices were coded previously
  • Departmental signals — which cost center submitted or received the goods
  • Temporal patterns — recurring invoices that follow monthly or quarterly cycles

A rule-based system might map "Vendor X = GL Code Y." A machine learning model maps "invoices from marketing-related vendors, with line items mentioning 'campaign' or 'media spend,' under $50,000, submitted by the marketing department = GL 6200-Marketing with 93% confidence."

Stage 2: Classification

Modern systems use transformer-based models (similar to the architecture behind large language models) to classify invoices. The LayoutLM model family has shown strong results because it understands both the text content and the spatial layout of invoices — where a field appears on the page matters for classification, not just what it says.

The model outputs a predicted GL code with a confidence score. High-confidence predictions (over 95%) route straight through. Medium-confidence predictions (80 to 95%) get flagged for quick human review. Low-confidence predictions (under 80%) go to manual coding.

Stage 3: Continuous Learning

Every time your AP team confirms or corrects a classification, the model updates. Confirm a prediction and it strengthens that pattern. Correct a prediction and it learns the exception. After 90 days of corrections and confirmations, most organizations see their auto-coding accuracy climb from an initial 80 to 85% to a steady-state 90 to 95%.

This is the fundamental advantage over rules-based coding. Rules do not improve. They work perfectly until an edge case appears, then they fail completely. ML models degrade gracefully — a new vendor might get coded with 75% confidence instead of 95%, prompting a human review rather than a silent misclassification.

What "90 to 95% Accuracy" Actually Means for Your Team

The headline number — 90 to 95% GL coding accuracy after 12 months of training data — sounds abstract. Here is what it means in practice for a team processing 800 invoices per month:

MetricManual CodingML Classification
Invoices auto-coded0640-720 (80-90%)
Human review needed80080-160
Coding errors per month24-644-8
Hours spent on GL coding426-8
Month-end journal corrections24-644-8

The 80-90% straight-through rate means your team only touches invoices that genuinely need human judgment — new vendors, unusual line items, ambiguous expense categories. The remaining 10-20% are flagged with the model's best guess and a confidence score, so even manual review starts from a reasonable suggestion rather than a blank field.

For month-end close, the impact is immediate. Fewer miscoded invoices means fewer journal entry corrections, which means your AP team finishes close 1 to 2 days faster.

Three Things That Make or Break GL Classification

ML invoice classification is not magic. Three factors determine whether you get 70% accuracy or 95%.

1. Clean historical data. The model learns from your past coding decisions. If those decisions are inconsistent — the same type of expense coded to different GL accounts by different team members — the model learns confusion. Before training, audit your last 12 months of coded invoices. Look for the top 10 vendors by volume and check whether their coding is consistent. Fix the inconsistencies first.

2. Chart of accounts hygiene. If your chart of accounts has 15 variations of "office supplies" or overlapping categories that even your team cannot distinguish, the model will struggle too. Consolidate redundant codes before you train. A clean chart of accounts with 150 well-defined codes produces better results than a bloated one with 500 overlapping codes.

3. Sufficient volume. ML models need data to learn. Organizations processing under 100 invoices per month may not generate enough training data for reliable classification. The sweet spot starts around 200+ invoices per month, where the model sees enough variety and repetition to learn meaningful patterns. Vic.ai reports that their models typically need 1,000 to 2,000 historical invoices before reaching reliable accuracy.

Practical Takeaways: Getting Started with ML Classification

You do not need to rip out your AP system to start using ML invoice classification. Here is a 4-week path:

Week 1: Export your last 12 months of coded invoices. Audit GL code consistency for your top 20 vendors by volume. Fix obvious inconsistencies.

Week 2: Review your chart of accounts. Flag any codes with fewer than 5 transactions in the past year — these are candidates for consolidation. Merge duplicates.

Week 3: Choose a tool that supports ML-based GL coding (Stampli, Vic.ai, and Ken from Finance all offer this). Feed your cleaned historical data into the training pipeline.

Week 4: Run in "suggestion mode" — the model suggests GL codes, your team confirms or corrects. Track accuracy daily. Most teams see 80%+ accuracy within the first two weeks of suggestion mode.

After 90 days, review your straight-through processing rate. If you are above 85% auto-coding accuracy with under 2% error rate, switch from suggestion mode to auto-coding with exception routing. Your team stops coding invoices and starts reviewing exceptions — a fundamentally different (and faster) workflow.

FAQ

How accurate is machine learning invoice classification?

Machine learning GL coding typically reaches 80 to 85% accuracy out of the box with 12 months of historical training data. After 90 days of feedback — confirming correct predictions and correcting wrong ones — accuracy climbs to 90 to 95% for organizations with consistent coding history and a clean chart of accounts. Accuracy depends heavily on data quality: inconsistent historical coding and overlapping GL codes are the two biggest limiters.

How many invoices do you need to train a GL classification model?

Most ML classification systems need 1,000 to 2,000 historically coded invoices to build a reliable initial model. For a company processing 200 invoices per month, that is 5 to 10 months of history. Companies with higher volume reach training thresholds faster. The model continues improving after deployment as your team confirms and corrects predictions, so accuracy at month 6 is typically 5 to 10 percentage points higher than at launch.

Can ML handle new vendors or unusual invoices?

New vendors without historical coding patterns get lower confidence scores, which routes them to human review instead of auto-coding. After your team manually codes 5 to 10 invoices from a new vendor, the model learns the pattern and begins auto-classifying future invoices from that vendor. Unusual one-off invoices — like a catering bill from a vendor who normally sells software — get flagged as anomalies. This is actually a feature: the AI fraud detection benefit of ML classification catches invoices that do not match expected patterns.

Related Topics

machine learning invoice classificationGL code automationautomated GL codinginvoice classification AI

Ready to automate your invoices?

See how Ken can extract invoice data in seconds, right in Slack. No credit card required.

Try Ken Free