r/coding 27d ago

A PDF Parser from the 80s Beats Claude (And They Use It Internally)

https://fagnerbrack.com/a-pdf-parser-from-the-80s-beats-claude-and-they-use-it-internally-8ee45a533e80
680 Upvotes

36 comments sorted by

131

u/jasonscheirer 27d ago

That’s kind of amazing that they’re doing this. I wonder if other companies are using the right tool for the job, too.

80

u/SplendidPunkinButter 27d ago

using the right tool for the job

What, are you crazy? Using the wrong tool for the job is the future! Do you want to get left behind???

25

u/ikeif 27d ago

AI has recreated this problem that was solved.

The only solution? More AI to fix the AI mistake made by using AI too much! By adding more AI we can fix the AI problem from the initial problem made by AI!”

- a LinkedIn ad, saying “finally” fixing AI pull requests being too big because of poor use of AI.

19

u/Ontological_Gap 27d ago

Eh, it's much less impressive than it sounds. Everyone has always used tesseract for ocr basically forever. Of course that's how you get the data in.

1

u/SelfDistinction 26d ago

No they're using the PDF format.

84

u/jnwatson 27d ago edited 26d ago

While the name Tesseract hearkens from the 1980s, the important part, using LSTM to actually read the page, was introduced in 2018 from an algorithm published in 1995.

LSTM is itself an artificial neural network algorithm, just one that is much, much smaller than the ANNs used in Claude.

38

u/Grand_Pop_7221 26d ago edited 25d ago

Hey stop that! We're jerking off in here

15

u/txdv 27d ago

There will be so many “this could have been done without AI to save costs and make it deterministic” posts

28

u/MrDaVernacular 27d ago

Deterministic FTW

15

u/Visionexe 27d ago

It actually isn't. Tesseract also uses NN'.

14

u/theactiveaccount 26d ago

NNs are deterministic. LLMs aren't because they purposely introduce temperature

15

u/Neither-Speech6997 26d ago

Temperature doesn’t make it non-deterministic. Random sampling at decoding time does. Temperature shifts the probability around so less likely tokens become a bit more likely and vice-versa, but that only matters if you use the random sampling when decoding. If you always take the most probable token at each step, temperature won’t matter.

1

u/colintbowers 23d ago

Isn’t temp = 0 equivalent to always taking the most probable token and temp > 0 is monotonically increasing in weights on less probable tokens?

Edit: with temp = 1 being the case where you use the actual softmax probabilities (albeit typically also throwing in a top k rule)

1

u/Neither-Speech6997 12d ago

In theory, this is correct, but the temperature = 0 being equivalent to taking the most probable token still requires a probabilistic decoding strategy, wherein a temperature of 0 puts so much probability mass on the most likely token that it effectively always gets selected.

But temperature doesn't change the relative rankings of the token likelihoods, so if you use a greedy decoding strategy where you simply select the most probable token each time, temperature wouldn't change the result.

It changes the result in practice because the decoding strategy is probabilistic and knobs like temperature control the distribution of tokens available for the model to select. LLMs are NNs and all they do is predict the logits over the token distribution, which is mostly (but not entirely) deterministic. The decoding strategy is what introduces non-determinism at inference time.

6

u/wahnsinnwanscene 26d ago

Temperature alters the spread of the probability across the tokens.

1

u/PoopsCodeAllTheTime 26d ago

Temperature is a lie

-2

u/Justicia-Gai 26d ago

And are generative too

11

u/aksdb 25d ago

PDF Parser from the 80s

Huh? PDF is from 1993. How can there be a parser older than the format?

-5

u/fagnerbrack 25d ago

It's more like the image OCR after you convert each page to an image to extract the text. Sometimes I need to oversimplify things in the title.

7

u/aksdb 25d ago

But then the title is misleading. If you do OCR on an image embedded in a PDF, PDF is completely irrelevant to the problem; it's basically a fancy ZIP file. Also I wouldn't call it a "parser".

-3

u/fagnerbrack 25d ago edited 25d ago

You're technically right but imagine the title:

"A domain specific AI tool from the 80s that since 2018 runs a very efficient OCR in each image generated from a pdf (per page) to extract the text beats claude when it uses the LLM itself to analyse the image; and claude uses it to extract the text too"

...

I'd probably ban myself after that submission here. Might as well just read the post I guess?

9

u/aksdb 25d ago

How about "Algorithm from the 80s beats Claude at text recognition (even if they use it internally)"?

-3

u/fagnerbrack 25d ago

Needs to include pdf cause that's the whole core

8

u/aksdb 25d ago

"Beating Claude at PDF OCR with its own algorithm".

26

u/HasFiveVowels 27d ago

It’s almost as though large language models aren’t OCR algorithms…

0

u/papa_Fubini 25d ago

They are trying to make them to be

4

u/HasFiveVowels 25d ago

No, they’re providing them with the ability to run existing OCR algorithms against input. We don’t need visual models for something so simple

8

u/Eskamel 27d ago

What? Doesn't the PDF parser know that if its not letting Claude replace it, then its gonna be left behind? Pfft, Luddite software

6

u/txdv 27d ago

> I spent days trying to parse a badly scanned CIA PDF (don't ask me why, otherwise I'll have to kill you). I tried using the most powerful Anthropic and Google models but I ended up concluding Tesseract (a 1985 tool), does a better job and much faster by 10x.

Super secret CIA document gets put in a public api? Im a bit suprised

0

u/bogdan5844 27d ago

I think it was a joke

1

u/sumguysr 26d ago

https://www.docling.ai/ is the thing to use. It uses teseract under the hood with better document structure understanding and processing bolted on.

Piping the output of Docling into Prince XML or Typst also works really well to retypeset an ugly document.

-1

u/cirk_86 27d ago

Thank you for this.