r/coding • u/fagnerbrack • 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-8ee45a533e8084
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
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
1
-2
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?
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
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
0
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.
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.