Live data from Hacker News

Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

github.com

131–140 of 178 posts

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#131
This is how you end up with "Xerox scanners/photocopiers randomly alter numbers in scanned documents" https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres...

I dont want hallucinations in places where OCR loses plot. I want either better OCR or error message telling me to repeat the scan.

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#132

> My original project had all sorts of complex stuff for detecting hallucinations and incorrect, spurious additions to the text (like "Here is the corrected text" preambles > asks it to correct OCR errors So, if I understand correctly, you add some prompt like "fix this text" and then the broken text? Why don't you do it differently, by not using a chat model but instead a completion model and input the broken OCRd t…

What you describe is a very different approach. It would require orders of magnitude more inference requests, but it would be missing out on all the power and "intelligence" of these new models because they wouldn't have sufficient context to make sensible decisions about what might be wrong or how to fix it. Also, there are not many hallucinations anymore now that these better models are available. But what you describe may work well, I'm not sure.

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#135
post #134

Is there any goodmodel for OCR but on handwritten information? I feel like most models are currently kind of trash

Can't say it'll solve all your problems, but try Florence-2. It's worked well on some handwritten documents for me when all the text is a relatively uniform size.

Model: https://huggingface.co/microsoft/Florence-2-large

Demo space: https://huggingface.co/spaces/gokaygokay/Florence-2

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#136

Even simpler, you can convert each PDF page to a PNG and ask gpt4 to simply transcribe the image. In my experience it's extremely accurate, more so than Tesseract or classic OCR.

That would cost like 100x as much though.

Not really. An A4 page at 75ppi — aka what used to be the standard "Web export" back in the day — is 620x877, and 1,000 of those images costs about $2 with the current pricing for gpt4o. Assuming there are about 500 words per page on an A4-sized page, and that each word is 0.75 tokens, that's ~666k tokens for $2. Given that gpt4o is $2.50/million tokens of text, using it for OCR is break-even with Tesseract + LLM, and a lot more accurate — especially once tables or columns are involved.

It's honestly shocking how much gpt4o with vision has simplified things.

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#137

Earlier quoted context omitted.

You can get them through the Vision API (Swift/Objective-C/AppleScript)

Yes but it's relatively shit The Vision API can't even read vertical Japanese text

Fair enough. There are some new OCR APIs in the next macOS release. I wonder if the model has been improved.

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#138

paging Jason Huggins ( https://news.ycombinator.com/user?id=hugs ) to add his two cents to this discussion

Oh hey! (This might be the first time I've been paged on HN)

I'm extremely excited by real, non-hype reasons to use LLMs, and I've also been frustrated that OCR isn't 100% accurate... I currently use Tesseract OCR in the context of UI automation of mobile apps. UI automation is already notorious for flakiness, I don't need to add to the problem... BUT... sometimes you only have access to the visible screen and literally nothing else... or you're in a regulated environment like payments, automative, or medical device testing where you're required to test the user interface exactly the way a user would, and you still want to automate that -- in those cases, all options are on the table, especially if an LLM-backed-OCR approach works better.

But with all that said, my "acid test" for any multimodal LLM here is to "simply" find the X,Y coordinates of "1", "2", "+", and "=" on the screenshot of a calculator app. So far in my testing, with no or minimal extra prompt engineering... Chat-GPT4o and Llava 1.5 fail this test miserably. But based on the pace of AI announcements these days, I look forward to this being a solved problem in a few months? Or... is the LLM-Aided OCR Project the magic I've been looking for? Tools like plain Tesseract and EasyOCR retain the X,Y locations in the scanned document image of the source text. I can't tell if that meta-information is lost when run through the LLM here.

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#139
post #109

Earlier quoted context omitted.

Maybe a pipeline like: 1. Segment document: Identify which part of the document is text, what is an image, what is a formula, what is a table, etc... 2. For text, do OCR + LLM. You can use LLMs to calculate the expectation of the predicted text, and if it is super off, try using ViT or something to OCR. 3. For tables, you can get a ViT/CNN to identify the cells to recover positional information, and then OCR + LLM fo…

I don't see how you make LLM improve tables where most of the time table is single word or single value that doesn't have continuous context like a sentence.

They take images

Re: Show HN: LLM-aided OCR – Correcting Tesseract OCR errors with LLMs

#140
post #63

In my experience, this works well but doesn't scale to all kinds of documents. For scientific papers; it can't render formulas. meta's nougat is the best model to do that. For invoices and records; donut works better. Both these models will fail in some cases so you end up running LLM to fix the issues. Even with that LLM won't be able to do tables and charts justice, as the details were lost during OCR process (bold…

Maybe a pipeline like: 1. Segment document: Identify which part of the document is text, what is an image, what is a formula, what is a table, etc... 2. For text, do OCR + LLM. You can use LLMs to calculate the expectation of the predicted text, and if it is super off, try using ViT or something to OCR. 3. For tables, you can get a ViT/CNN to identify the cells to recover positional information, and then OCR + LLM fo…

How to segment the document without LLM?

I prefer to do all of this in 1 step with an LLM with a good prompt and few shots.

With so many passes with images, the costs/time will be high with ViT being slower.

Post reply on HN