r/developersPak • • 12d ago

Help Best Models For Doing Data Extraction From Accounting Documents

I am working with some complex accounting documents such as lengthy bank statements, pdf invoices, sometimes images of receipts etc.

So far I have been using Gemini 3.1 Pro for intelligent extraction because I need the output in a specific JSON format and also because the documents have no specific format of their own either, so using a dedicated OCR model like pdfminer etc won't work.

The issue is that the cost is eating up the whole budget to the point that according to calculations it would be a miracle to make breakeven for my product.

I can't compromise on accuracy because it is related to financial decisions of the users which is a sensitive thing, and I can't be too open with my wallet because what's the point of the business if it is going in loss.

I need suggestions for replacement with the following considerations:

  1. Must have at least equivalent accuracy to 3.1 Pro in extracting data from pdf/images.

  2. Must be less costly than 3.1 Pro (even 20% less cost would be acceptable for now).

  3. Should have Zero Data Retention Policy.

  4. The output should be in a structured JSON, for example it should understand that if there are two dates mentioned on the document it should properly create the JSON mentioning which date is the invoice creation/issue date and which date is the due date for invoice payment.

2 Upvotes

9 comments sorted by

3

u/Candid-Fudge-4015 11d ago

Accounting documents give you checks that most extraction doesn't have. Line items should add up to the invoice total, a statement's opening balance plus its transactions should equal the closing balance, and a due date should come after the issue date. Run a cheaper model first, run those checks in code, and send only the documents that fail to 3.1 Pro. How much that saves depends on how many pass, which you can only learn on your own files, so label 50 or so with the correct JSON and compare both setups on them before trusting either.

Two smaller things. If your users can wait, Gemini's Batch API is priced at 50% of the standard rate. And hash every file and store its result, so a re-upload or a retry after a failure doesn't bill again for a document you already extracted.

1

u/NotSoAsian86 11d ago

I have already tried the first part that you mentioned, the math part is easy, the issue is that smaller models would sometimes make mistakes like assigning names wrongly, it will mark the supplier as the customer and the customer as the supplier, and some other issues that I faced. I can't give too much details because if anyone else reads it, it might affect my anonymity.

As for the batching part, I checked that as well and if I remember correctly the results are returned in 24 hours at max (usually it doesn't take very long but still it is a possibility). This is kind of a gamble that is not acceptable at production level where there might be at least 100 concurrent users each uploading at least 10 documents.

I already have faced a situation where 30 users were uploading at the same time (rare occurrence at this stage).

Still, thanks a lot for the suggestions and insights. Some other users mentioned Azure, I will check that out.

1

u/Candid-Fudge-4015 7d ago

The supplier and customer swap has a cheap check if users upload their own documents. One of the two parties is usually the uploader's own business, so compare both extracted names and tax numbers against the account's company profile. If the user's company lands on the wrong side, flip the roles or flag the document, and keep those cases as test examples for whichever model you settle on.

Agreed that Batch doesn't fit live uploads. It's better suited to backfills and reprocessing. For 100 users at 10 documents each, standard calls behind a queue with a concurrency limit let a burst of 1,000 documents drain at your rate limit instead of failing.

1

u/rizistt Software Engineer 11d ago

Hey, I am building something for data extraction for precisely cases like this. Would love your feedback if you're open.

1

u/NotSoAsian86 11d ago

Are you building a model for extraction or are you building an application with a similar case as mine?

1

u/rizistt Software Engineer 11d ago

I am actually building an end to end platform for document intlligence.

2

u/Cheap_Fly_1003 ML/AI Engineer 11d ago

I am using Azure Document Intelligence (ADI) for Healthtech domain which includes Patient's reports that include number especially the tables, it handles these documents accurately and. It costs 10$ for 1000 pages, be it images or PDFs.

1

u/itsPerceptron 11d ago

Use azure OCR API or llamaOCR api, both work great and you can process 1000 of document under 15$

1

u/BATEMANx9 6d ago

for bank statements i wouldn't send every page through a big model at all. most statements from online banking have a real text layer, so you can pull the transaction table out without an llm and only use a small cheap model for the header bits (account, period, vendor names).

the part that actually saves you is a plain check per statement: opening balance + credits - debits = closing balance. anything that fails goes to manual review or to the expensive model. that way you know which files you can trust.

if pdfminer keeps breaking on the layouts, i built an api for this (switchfile.io, disclosure: mine). it turns pdfs into json, csv or excel, and with store=false nothing is kept after the request. servers are in the eu.