RAG & Documents
Can a free AI on your computer read your invoices? 4 local models vs rules, measured with Spanish tax IDs, VAT and IRPF
Qwen3 4B correctly read 26 of 27 Spanish invoices locally, at 3.0 s each. Rules failed every invoice in a new format and Gemma 3 4B dropped the letter from the tax ID in 8.
- Date
- Nov 8, 2026
- Reading time
- 8 min
- Result
- Qwen3 4B: 96.3% perfect invoices • rules: 0% on a new format • 3.0 s per invoice on a laptop • 3 automatic checks flag 100% of Llama 3.2's and Qwen3 1.7B's errors
Translated from the Spanish original. The code, data and READMEs on GitHub are in Spanish.
A free AI model running on a laptop correctly read all 9 fields of 26 out of 27 Spanish invoices (96.3%), at 3.0 seconds per invoice and without sending anything to the internet: Qwen3 4B. The other three small models tested stayed between 51.9% and 74.1% perfect invoices. Fixed rules read the invoices in the formats they were written for without a single error, and none (0%) of the format they didn’t know. Measured on 8 November 2026 on an Apple M1 Max laptop.
“Can I use AI to enter supplier invoices into the accounts without paying for a tool and without uploading them to the cloud?” is one of the questions accounting firms and small businesses ask most. The answers going around are anecdotes (“it works for me with a 7B model”) or figures from vendors selling their own service. We couldn’t find a measurement with Spanish invoices, NIF tax IDs, VAT and IRPF withholding, or with published code. Here it is.
Definitions
- Extracting invoice data: pulling from the PDF the fields that need to go into the accounts. Here, nine: number, date, supplier NIF (Spanish tax ID), customer NIF, taxable base, VAT rate, VAT amount, IRPF withholding (Spanish income tax withheld by self-employed suppliers) and total.
- Local model: an AI model you download once and that runs on your computer, with no account, no pay-per-use and without the invoice leaving the company. The four tested used between 1.8 and 3.5 GB of memory.
- Rules: fixed instructions such as “the total is the number after TOTAL FACTURA”. It’s the classic per-supplier template method.
- Perfect invoice: all nine fields right. A NIF missing its letter or a total with one digit changed is no longer perfect.
- Automatic checks: three verifications any program can do without AI: that base + VAT − IRPF = total and VAT = base × rate, that each NIF’s check letter or digit is correct, and that the supplier’s NIF isn’t the same as the customer’s.
Hypotheses
- A small local model (from 1.7 billion to 4 billion parameters) correctly reads at least 9 out of 10 invoices.
- Rules are perfect with the formats they know and fail with a new one.
- Automatic checks catch the AI’s errors before they reach the accounts.
Setup
- Invoices: 27 programmatically generated PDFs, in three formats of 9 invoices each. A is the classic invoice («Nº de factura», «Base imponible», «TOTAL FACTURA»); B uses abbreviated labels («Subtotal», «I.V.A. (21%)», «Retención I.R.P.F.», «TOTAL A PAGAR»); C puts the customer before the supplier and uses other labels («Importe neto», «Serie y número», «Emitida el»). C plays the role of an invoice from a new supplier.
- Real-world traps: due date and order number next to the invoice date and number; NIFs written together, with a hyphen or with dots; dates in four formats («09/05/2026», «7 de noviembre de 2026»…); amounts with «€» before or after, with «EUR» and with or without thousands separators; VAT at 21, 10 and 4%; and 13 invoices from self-employed suppliers with 15% IRPF withholding, spread across the three formats, where the total isn’t base + VAT.
- Made-up data: names and addresses from the Faker library; random NIF and CIF numbers with valid check letters or digits. No real people or companies.
- Reading: each PDF’s text is extracted with PyMuPDF and is the same for all. The rules were written looking only at formats A and B. The four models receive the same instruction and reply in JSON:
- Qwen3 4B Instruct 2507 (Alibaba, Apache 2.0)
- Gemma 3 4B (Google)
- Llama 3.2 3B (Meta)
- Qwen3 1.7B (Alibaba, Apache 2.0, without reasoning mode)
- How they run: quantised to 4 bits with MLX, Apple’s library for its chip, at temperature 0 (always the most likely answer). Five full passes over the 27 invoices, one invoice at a time.
- Machine: Apple M1 Max laptop with 64 GB, macOS 26.6.2, plugged into mains power.
Results
Which invoices each option reads correctly
| Option | Perfect invoices | Correct fields | Format A | Format B | Format C (new) | Seconds per invoice |
|---|---|---|---|---|---|---|
| Rules | 66.7% | 69.5% | 9 of 9 | 9 of 9 | 0 of 9 | 0.04 ms |
| Qwen3 4B Instruct 2507 | 96.3% | 99.2% | 8 of 9 | 9 of 9 | 9 of 9 | 3.0 s |
| Qwen3 1.7B | 74.1% | 96.7% | 9 of 9 | 8 of 9 | 3 of 9 | 1.4 s |
| Gemma 3 4B | 55.6% | 92.2% | 4 of 9 | 5 of 9 | 6 of 9 | 3.2 s |
| Llama 3.2 3B | 51.9% | 91.8% | 5 of 9 | 5 of 9 | 4 of 9 | 1.8 s |
Answers were identical across the five passes for every option, and all four models always returned valid JSON. Time barely varied: Qwen3 4B took between 81.0 and 82.2 s to read the 27 invoices on each pass.
What each one gets wrong
| Option | Invoices with an error | With some amount wrong | NIF missing its letter | Supplier and customer NIFs swapped | Errors that pass all 3 checks |
|---|---|---|---|---|---|
| Rules | 9 | 9 | 0 | 0 | 0 |
| Qwen3 4B Instruct 2507 | 1 | 0 | 0 | 1 | 1 |
| Qwen3 1.7B | 7 | 2 | 0 | 0 | 0 |
| Gemma 3 4B | 12 | 0 | 8 | 2 | 2 |
| Llama 3.2 3B | 13 | 9 | 2 | 0 | 0 |
- Rules don’t get things wrong: they come up blank. With format C they found neither the total nor the date and confused supplier and customer. Since the amounts are left empty, the checks always catch it.
- Gemma 3 4B reads every amount and date correctly, but not the NIFs. In 8 invoices it returned an individual’s NIF without the final letter (just the 8 digits). It only got 59.3% of supplier NIFs right.
- Llama 3.2 3B makes up figures. In 9 invoices it got some amount wrong, often with one digit changed («24.980,46» instead of «24.880,46»). It also dropped the hyphen from the invoice number in 14.8% of cases («260918» instead of «26-0918»).
- Qwen3 1.7B fails with the new supplier: on format C it got 3 of 9 invoices right, mainly because it repeated the supplier’s NIF as the customer’s NIF (it got 81.5% of customer NIFs right).
- Qwen3 4B only got one invoice wrong: a self-employed supplier invoicing a company, where it swapped the supplier’s and the customer’s NIF. Gemma 3 4B made the same mistake on that invoice and on another identical one.
What the automatic checks catch
With the three checks (amounts add up, NIF check letter or digit, NIFs are different), a program would have set aside for review 100% of the invoices misread by Llama 3.2 3B (13 of 13) and by Qwen3 1.7B (7 of 7), and 10 of Gemma 3 4B’s 12. No correctly read invoice raised a false alarm. The only error they don’t catch is a supplier–customer swap, because both NIFs are valid and the amounts add up: 1 invoice with Qwen3 4B and 2 with Gemma 3 4B. That one is caught by comparing the supplier’s NIF with your supplier list, something we didn’t measure here.
Time and memory
| Model | Seconds per invoice | Minutes for 300 invoices | Peak memory | Tokens generated per second |
|---|---|---|---|---|
| Qwen3 4B Instruct 2507 | 3.0 | 15.1 | 3.1 GB | 77.0 |
| Gemma 3 4B | 3.2 | 16.1 | 3.5 GB | 72.9 |
| Llama 3.2 3B | 1.8 | 8.8 | 2.5 GB | 103.4 |
| Qwen3 1.7B | 1.4 | 6.9 | 1.8 GB | 156.4 |
Loading each already-downloaded model took between 0.5 and 1.4 s. On a machine without an Apple chip or a graphics card, times will be longer.
What it means for a company
- Hypothesis 1: it only holds with Qwen3 4B (96.3% perfect invoices). The other three models stay between 51.9% and 74.1%: size doesn’t explain everything, because Gemma 3 4B, the same size, was the second worst.
- Hypothesis 2: it holds. The rules read 100% of the known formats and 0% of the new one. They work for your regular suppliers; every new supplier requires writing new rules.
- Hypothesis 3: it partly holds. The checks catch made-up amounts and incomplete NIFs, but not a swapped supplier and customer.
An accounting firm or a small business that receives 300 invoices a month from different suppliers can read them with Qwen3 4B on a laptop in about 15 minutes, for free and without them leaving the office. What it can’t do is skip review: the workflow that came out of this test is local model + three automatic checks + comparing the NIF with the supplier list, with a person looking only at the invoices that don’t pass.
When to use each option
- Rules: if almost all your invoices come from a few fixed suppliers that always use the same format. Instant and error-free with what they know; useless with what they don’t.
- Qwen3 4B Instruct 2507: the best option measured for invoices from many different suppliers. It’s the one we recommend trying first.
- Qwen3 1.7B: if the machine is modest and speed matters more; it does well with classic formats but fails with unusual ones.
- Gemma 3 4B and Llama 3.2 3B: we don’t recommend them for this task without tuning; one loses NIF letters and the other changes digits in amounts.
- In any case: test with 30 or 50 of your own invoices before trusting it, and always turn on the checks.
Limitations
- Synthetic, digital invoices. They’re programmatically generated PDFs, with clean text. We didn’t test scanned or photographed invoices (which need text recognition first), complex tables, multiple pages, several VAT rates on the same invoice, or invoices in other languages. With real invoices, every result should be worse.
- Few invoices. 27 invoices in three formats; a single invoice moves each percentage by several points. It’s good for seeing big differences, not for ranking similar options.
- A single instruction, no tuning. We didn’t test examples inside the instruction, forced structured output or larger models (7 billion parameters or more), which would probably fail less. The sign of the withholding wasn’t taken into account (a «−108,76» counts as 108.76). After correcting that criterion, the Qwen3 1.7B measurement, the only one affected, was repeated.
- Rules written by us. More elaborate rules would read part of format C; the result illustrates the new-supplier problem, not a limit of rules in general.
- A single Apple M1 Max laptop with other apps open, plugged in. The timings are good for the order of magnitude: on a PC without an Apple chip or a graphics card they’ll probably be longer. All the computation fit in under 30 minutes.
- This isn’t tax advice. Reading an invoice correctly doesn’t replace its legal validity or the obligations around record-keeping and e-invoicing.
How to reproduce it
Code, invoice generator with a fixed seed, exact model revisions and every field extracted across the five passes: yeswelab-laboratorio/extraer-datos-facturas-ia-local on GitHub. It runs on a Mac with an Apple chip, with no accounts or keys; the first time it downloads the four models from Hugging Face. To test it with your invoices, put your PDFs and their correct data in verdad.json.
Related
- Which PDF parser should you use for RAG in Spanish? 6 libraries measured on invoices
- Structured outputs: repair a local model’s JSON or retry
- AI agents for business: use cases, costs and risks
Receive invoices from many suppliers and want to know whether a local AI would read them correctly? Commission the experiment with 50 of your invoices and we’ll tell you which model works with them, how many would need checking by hand and how much time it saves you.