{
  "licence": "https://creativecommons.org/licenses/by/4.0/",
  "credit": "Saulius Beconis, sbeconis.com",
  "page": "https://sbeconis.com/lab/invoice-extraction/",
  "url": "https://sbeconis.com/lab/invoice-extraction/invoices-2026-10-09.json",
  "lab": "LAB/014",
  "title": "Multilingual invoice extraction with plain-code checks",
  "date": "2026-10-09",
  "method": {
    "data": "400 synthetic B2B invoices, 100 each in Lithuanian, German, Polish and English (Irish VAT), half rendered clean and half scan-like; fictional companies; exact ground truth; generator in the repository",
    "model": "Qwen3-VL-8B Q4_K_M (llama.cpp), output constrained to a JSON schema, greedy",
    "prompt": "Extract this invoice as JSON. Copy text values exactly as printed. Write amounts as plain decimals with a dot and no thousands separators (for example 1234.56), dates as YYYY-MM-DD, the VAT rate of each line as a number (for example 21), and the IBAN and VAT IDs without spaces. Include every line item.",
    "validators": "line nets sum to net total; VAT per line and rate sums to VAT total (±0.02); net + VAT = total; IBAN mod-97; VAT ID format per country",
    "outcomes": "straight-through = all checks pass and every field right; caught = a check fails and something is wrong; silent error = all checks pass but something is wrong; false reject = a check fails but everything is right"
  },
  "environment": {
    "gpu": "RTX 4070 12 GB"
  },
  "tables": {
    "outcomes": {
      "caption": "What happens to each invoice: processed with no human touch, sent to a person, or wrong without anyone knowing.",
      "columns": [
        {
          "key": "straight-through",
          "label": "Straight-through",
          "suffix": "%"
        },
        {
          "key": "caught",
          "label": "Caught",
          "suffix": "%"
        },
        {
          "key": "silent error",
          "label": "Silent error",
          "suffix": "%"
        },
        {
          "key": "false reject",
          "label": "False reject",
          "suffix": "%"
        }
      ],
      "rows": [
        {
          "label": "All",
          "cells": {
            "straight-through": 95.5,
            "caught": 2.8,
            "silent error": 1.8,
            "false reject": 0
          },
          "highlight": true
        },
        {
          "label": "Lithuanian",
          "cells": {
            "straight-through": 99,
            "caught": 1,
            "silent error": 0,
            "false reject": 0
          },
          "highlight": false
        },
        {
          "label": "German",
          "cells": {
            "straight-through": 87,
            "caught": 7,
            "silent error": 6,
            "false reject": 0
          },
          "highlight": false
        },
        {
          "label": "Polish",
          "cells": {
            "straight-through": 99,
            "caught": 0,
            "silent error": 1,
            "false reject": 0
          },
          "highlight": false
        },
        {
          "label": "English (Irish VAT)",
          "cells": {
            "straight-through": 97,
            "caught": 3,
            "silent error": 0,
            "false reject": 0
          },
          "highlight": false
        },
        {
          "label": "Clean images",
          "cells": {
            "straight-through": 95,
            "caught": 2.5,
            "silent error": 2.5,
            "false reject": 0
          },
          "highlight": false
        },
        {
          "label": "Scan-like images",
          "cells": {
            "straight-through": 96,
            "caught": 3,
            "silent error": 1,
            "false reject": 0
          },
          "highlight": false
        }
      ]
    },
    "fields": {
      "caption": "Field accuracy, all 400 invoices (exact match after removing spaces).",
      "columns": [
        {
          "key": "acc",
          "label": "Correct",
          "suffix": "%"
        }
      ],
      "rows": [
        {
          "label": "invoice number",
          "cells": {
            "acc": 100
          }
        },
        {
          "label": "issue date",
          "cells": {
            "acc": 100
          }
        },
        {
          "label": "due date",
          "cells": {
            "acc": 100
          }
        },
        {
          "label": "seller vat id",
          "cells": {
            "acc": 99.8
          }
        },
        {
          "label": "buyer vat id",
          "cells": {
            "acc": 100
          }
        },
        {
          "label": "iban",
          "cells": {
            "acc": 99
          }
        },
        {
          "label": "net total",
          "cells": {
            "acc": 97
          }
        },
        {
          "label": "vat total",
          "cells": {
            "acc": 97
          }
        },
        {
          "label": "total",
          "cells": {
            "acc": 97
          }
        },
        {
          "label": "line items (recall)",
          "cells": {
            "acc": 96.1
          }
        }
      ]
    },
    "checks": {
      "caption": "Which plain-code check caught the wrong invoices (one invoice can fail several).",
      "columns": [
        {
          "key": "n",
          "label": "Wrong invoices caught",
          "decimals": 0
        }
      ],
      "rows": [
        {
          "label": "lines sum",
          "cells": {
            "n": 6
          }
        },
        {
          "label": "vat by rate",
          "cells": {
            "n": 3
          }
        },
        {
          "label": "net plus vat",
          "cells": {
            "n": 0
          }
        },
        {
          "label": "iban checksum",
          "cells": {
            "n": 4
          }
        },
        {
          "label": "vat id format",
          "cells": {
            "n": 1
          }
        }
      ]
    },
    "followup": {
      "caption": "Measured 2026-10-10. Two more checks: quantity × unit price = line amount (6), and the total within 1/10 to 10× of the supplier's earlier invoices (7).",
      "columns": [
        {
          "key": "straight-through",
          "label": "Straight-through",
          "suffix": "%"
        },
        {
          "key": "caught",
          "label": "Caught",
          "suffix": "%"
        },
        {
          "key": "silent error",
          "label": "Silent error",
          "suffix": "%"
        },
        {
          "key": "false reject",
          "label": "False reject",
          "suffix": "%"
        }
      ],
      "rows": [
        {
          "label": "First set (400), checks 1–5",
          "cells": {
            "straight-through": 95.5,
            "caught": 2.8,
            "silent error": 1.8,
            "false reject": 0
          }
        },
        {
          "label": "First set, + line arithmetic (chosen after seeing its errors)",
          "cells": {
            "straight-through": 95.5,
            "caught": 4,
            "silent error": 0.5,
            "false reject": 0
          }
        },
        {
          "label": "Fresh set B (400), checks 1–5",
          "cells": {
            "straight-through": 98,
            "caught": 2,
            "silent error": 0,
            "false reject": 0
          }
        },
        {
          "label": "Fresh set B, checks 1–7",
          "cells": {
            "straight-through": 98,
            "caught": 2,
            "silent error": 0,
            "false reject": 0
          },
          "highlight": true
        },
        {
          "label": "Fresh set C, wide prices (400), checks 1–5",
          "cells": {
            "straight-through": 90.3,
            "caught": 3.8,
            "silent error": 4.8,
            "false reject": 1.3
          }
        },
        {
          "label": "Fresh set C, wide prices, checks 1–7",
          "cells": {
            "straight-through": 90.3,
            "caught": 8.5,
            "silent error": 0,
            "false reject": 1.3
          },
          "highlight": true
        }
      ]
    }
  },
  "examples": {
    "thousands-dot": {
      "title": "German thousands dot read as a decimal point: every check passed",
      "verdict": "wrong",
      "fields": [
        {
          "label": "Printed on the invoice",
          "text": "line 1: 25 × 1.601,08 = 40.027,00 €; total 69.395,44 €"
        },
        {
          "label": "Qwen3-VL-8B extracted",
          "text": "line 1: quantity 25, unit_price 1.60, net 40.02; total 69.39",
          "mono": true
        },
        {
          "label": "Checks",
          "text": "all five passed"
        }
      ],
      "source": "Synthetic invoice de-0066 (fictional, generated for this Lab)."
    },
    "unit-price": {
      "title": "One digit dropped from a unit price: every check passed",
      "verdict": "wrong",
      "fields": [
        {
          "label": "Printed on the invoice",
          "text": "line 1: 10 × 2 226,93 = 22 269,30 zł; total 37 140,35 zł"
        },
        {
          "label": "Qwen3-VL-8B extracted",
          "text": "line 1: quantity 10, unit_price 226.93, net 22269.30; total 37140.35",
          "mono": true
        },
        {
          "label": "Checks",
          "text": "all five passed"
        }
      ],
      "source": "Synthetic invoice pl-0070 (fictional, generated for this Lab)."
    }
  },
  "thousands_misread": {
    "by_language": {
      "lt": 0,
      "de": 12,
      "pl": 0,
      "en": 0
    },
    "outcomes": {
      "silent error": 6,
      "caught": 6
    }
  },
  "charts": {
    "outcomes": {
      "title": "Outcome per language",
      "meta": "Share of invoices · silent errors are the ones to drive to zero",
      "max": 100,
      "suffix": "%",
      "groups": [
        {
          "label": "Lithuanian",
          "bars": [
            {
              "label": "straight-through",
              "value": 99,
              "highlight": false
            },
            {
              "label": "caught",
              "value": 1,
              "highlight": false
            },
            {
              "label": "silent error",
              "value": 0,
              "highlight": true
            },
            {
              "label": "false reject",
              "value": 0,
              "highlight": false
            }
          ]
        },
        {
          "label": "German",
          "bars": [
            {
              "label": "straight-through",
              "value": 87,
              "highlight": false
            },
            {
              "label": "caught",
              "value": 7,
              "highlight": false
            },
            {
              "label": "silent error",
              "value": 6,
              "highlight": true
            },
            {
              "label": "false reject",
              "value": 0,
              "highlight": false
            }
          ]
        },
        {
          "label": "Polish",
          "bars": [
            {
              "label": "straight-through",
              "value": 99,
              "highlight": false
            },
            {
              "label": "caught",
              "value": 0,
              "highlight": false
            },
            {
              "label": "silent error",
              "value": 1,
              "highlight": true
            },
            {
              "label": "false reject",
              "value": 0,
              "highlight": false
            }
          ]
        },
        {
          "label": "English (Irish VAT)",
          "bars": [
            {
              "label": "straight-through",
              "value": 97,
              "highlight": false
            },
            {
              "label": "caught",
              "value": 3,
              "highlight": false
            },
            {
              "label": "silent error",
              "value": 0,
              "highlight": true
            },
            {
              "label": "false reject",
              "value": 0,
              "highlight": false
            }
          ]
        }
      ]
    }
  },
  "headline": {
    "value": "95.5%",
    "label": "of 400 invoices in four languages processed with no person involved and every checked field correct; 1.8% were wrong without a check noticing"
  },
  "updated": "2026-10-10",
  "stats": {
    "followup": {
      "items": [
        {
          "value": "4.8% → 0%",
          "label": "wrong invoices that passed every check, fresh set of 400, five checks → seven",
          "signal": true
        },
        {
          "value": "90.3%",
          "label": "went straight through, every checked field correct"
        },
        {
          "value": "6.5 s",
          "label": "per invoice on one GPU, nothing leaves the machine"
        }
      ]
    }
  },
  "units": {
    "followup": {
      "title": "The same 400 fresh invoices, routed by five checks and by seven",
      "meta": "One mark per invoice · circles are wrong invoices that passed every check",
      "unit": "invoice",
      "panels": [
        {
          "label": "Checks 1–5",
          "categories": [
            {
              "label": "Straight through, correct",
              "count": 361,
              "kind": "base"
            },
            {
              "label": "Sent to a person, wrong",
              "count": 15,
              "kind": "outline"
            },
            {
              "label": "Wrong, passed every check",
              "count": 19,
              "kind": "signal"
            },
            {
              "label": "Sent to a person, correct",
              "count": 5,
              "kind": "muted"
            }
          ]
        },
        {
          "label": "Checks 1–7",
          "categories": [
            {
              "label": "Straight through, correct",
              "count": 361,
              "kind": "base"
            },
            {
              "label": "Sent to a person, wrong",
              "count": 34,
              "kind": "outline"
            },
            {
              "label": "Wrong, passed every check",
              "count": 0,
              "kind": "signal"
            },
            {
              "label": "Sent to a person, correct",
              "count": 5,
              "kind": "muted"
            }
          ]
        }
      ]
    }
  },
  "processes": {
    "followup": {
      "title": "Three real invoices from the fresh set, through all seven checks",
      "meta": "✓ passed · ✕ failed: the invoice goes to a person",
      "steps": [
        {
          "label": "Lines add up"
        },
        {
          "label": "VAT by rate"
        },
        {
          "label": "Net + VAT = total"
        },
        {
          "label": "IBAN checksum"
        },
        {
          "label": "VAT ID format"
        },
        {
          "label": "Qty × price = line"
        },
        {
          "label": "Supplier history"
        }
      ],
      "cases": [
        {
          "title": "German invoice de-0002",
          "item": "total 60.634,00 € · read correctly",
          "results": [
            "pass",
            "pass",
            "pass",
            "pass",
            "pass",
            "pass",
            "pass"
          ],
          "outcome": "Every check passed and every field was right: booked with no human touch.",
          "verdict": "correct"
        },
        {
          "title": "German invoice de-0000",
          "item": "printed total 442.198,74 € · read as 442.19",
          "results": [
            "pass",
            "pass",
            "pass",
            "pass",
            "pass",
            "fail",
            "fail"
          ],
          "outcome": "Thousands dot read as a decimal point. The first five checks passed; checks 6 and 7 sent it to a person.",
          "verdict": "caught"
        },
        {
          "title": "German invoice de-0015",
          "item": "printed total 70.637,39 € · read as 70.63",
          "results": [
            "pass",
            "pass",
            "pass",
            "pass",
            "pass",
            "pass",
            "fail"
          ],
          "outcome": "Same misread, and the line arithmetic still held: only the supplier's history caught it.",
          "verdict": "caught"
        }
      ]
    }
  }
}
