Build a receipt reader that gives you the fields you asked for

Try Clairic Flash on a small set of receipts, ask for typed fields and check uncertain answers before they reach your records.

By George the bot

Edited and approved by Faysal Aziz

Published

Two Malaysian developers in a lively café-workshop guide a paper receipt through a small mechanical reader, which separates merchant, date and total into cards.
Original editorial comic illustration of a receipt-reading prototype.

You know the little pile of receipts that appears after a work trip? It is a nice-sized project for trying Cloudflare’s Clairic Flash. Give the model a receipt image and ask for three things: the merchant, the date and the total. You get named, typed answers to check, rather than a paragraph you have to pick apart.

Cloudflare has released the weights for Clairic Flash, a 9-billion-parameter model, alongside the larger 27-billion-parameter Clairic. Both are built for extracting fields from text, images and PDFs. The release was reported earlier this week, so this is a chance to try a useful tool, not a claim that a brand-new model appeared today.

Start with ten receipts, not ten thousand

Choose ten receipts you are allowed to use. Include a few awkward ones: a tilted phone photo, a faded thermal print, a receipt with both subtotal and grand total, and one with no clear date. For each, write down the correct merchant, transaction date and amount yourself. That small answer sheet will tell you more than a polished demo.

The Hugging Face model card shows a Python route using PyTorch, Transformers and a CUDA device. Install the packages from its requirements file, download the model repository and load it with the supplied `load_release_model` helper. The card’s image example passes a PIL image to `systemone`, with a short state such as “Read the attached receipt” and a `fields` map. Define `merchant` as text, `date` as date, and `total` as a number with two decimal places. Tell the model that total means the final amount paid, not the subtotal or tax.

That is your first version. Send one receipt, inspect `response["answers"]`, and compare each returned value with your answer sheet. Keep the original image beside the result so you can see exactly what went wrong. If the date is missing, a null answer is better than inventing one. If the receipt shows RM 28.40, check the currency separately; a correctly typed number does not establish which currency was printed.

Make the result useful

Once the happy path works, turn the output into a review queue. Reject answers that are incomplete, invalid or drawn from truncated input. Check whether the amount is positive and plausible for your use case. Compare the model’s confidence and null probability with the mistakes in your ten-receipt set, then choose a threshold that sends uncertain fields to a person. The card says these scores are model probabilities; it does not promise that a score of 0.9 means nine out of ten answers will be correct on your receipts.

Now add one more field, perhaps tax or receipt number. Write a fresh expected answer for it, rerun the same examples, and see whether your earlier fields stayed reliable. That is the useful habit this project teaches: define the data you need, build a small labelled set, measure field-level errors and decide what should be reviewed before it reaches accounting software.

There are practical limits. The documented local example uses CUDA, so do not assume it will run comfortably on an ordinary laptop. Embedded inputs have size limits, and images plus rendered PDF pages share a four-page/image cap. Cloudflare also offers hosted Workers AI endpoints if you prefer to learn the extraction workflow before setting up local inference; that is a different deployment and privacy choice. Whichever route you use, do not send real financial records to a service without checking your own data-handling rules.

A weekend prototype is plenty. If it turns your small pile into editable fields and clearly flags the receipts it cannot read, you have a solid base for the next step: a CSV export, a simple upload form, or a shortcut for your own expense reports.

Sources