Instructions to use balticml/mmbert-small-invoice-extraction with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use balticml/mmbert-small-invoice-extraction with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('token-classification', 'balticml/mmbert-small-invoice-extraction');
mmbert-small-invoice-extraction
Marks the words of an invoice's fields in its text (as pdf.js reads a digital PDF): seller and buyer, their VAT numbers, invoice number, issue and due dates, net, VAT and total, and the IBAN, in the 24 languages of the EU, Norway and Ukraine. The first 12 of mmBERT-small's 22 layers, fine-tuned with BIO tags over words; ONNX weight-only int8 for transformers.js, 47.7 MB plus a 9.3 MB tokenizer.
It runs with a rule layer, as the widget on
balticml.eu does: VAT numbers (25 countries) and
IBANs checked by their check digits, sums that must add up, dates that must be dates, and seller
and buyer shown only where the page names them (otherwise both companies are listed, roles not
named). The model labels words, not tokens, each tokenized with the whitespace before it; use the
code in the repo (github.com/balticml/invoice-extraction,
web/model.js, web/pdftext.js, web/review.js) rather than the generic pipeline.
Results
PDFs from invoicing tools it never trained on, int8 with the rules, threshold 0.6. A field is right when its value equals the invoice's after normalising; "not sure" fields are left empty.
| set | fields | right | wrong, shown | not sure |
|---|---|---|---|---|
| InvoiceShelf, 72 invoices, 24 languages | 746 | 61.7% | 0.8% | 37.5% |
| Invoice Ninja, 63 invoices, 6 designs, 23 languages | 678 | 64.7% | 0.3% | 35.0% |
| Fakturownia, 20 invoices | 220 | 86.4% | 0.0% | 13.6% |
Most "not sure" fields are the seller and buyer of layouts that do not label them; in their place the widget lists both companies, and 6β8% of the names listed are wrong. On 60 LLM-written invoices checked by hand: 84.5% right, 0.8% wrong. The full tables, and how the test sets were kept apart: the repo's README.
Training data
No real invoices. 9,000 invoices from a generator (six layout families, six languages), 23,259 in layouts composed at random from blocks in 24 languages, 566 written whole by gpt-oss-20b for 30 kinds of business (each also filled again five times with other names and numbers), and 480 exported from local Dolibarr and Odoo installations to made-up companies. Every invoice was read with pdf.js, block by block; each word's label comes from where its value is printed.
Limits
Digital PDFs with a text layer only (no scans). One-page invoices of small businesses tested; no real invoice scored yet. Company names are the weakest fields. Test it on your own suppliers' invoices before trusting it on theirs.
- Downloads last month
- 71
Model tree for balticml/mmbert-small-invoice-extraction
Base model
jhu-clsp/mmBERT-small