Posts

Extracting Image Only PDFs to text with better accuracy than Tesseract using LLM. Langgraph loops and page blocking.

Image
How to obtain error free text from PDF files. Lets start with the simplest option, send the entire pdf to a LLM and have it extract text. What happens? Errors which start with tables and figures getting worse the deeper you go into the document. As the context window fills up on a LLM they lose ability. It is not unreasonable to assume this is the reason here. Reduce the context window by segmenting the pdf into individual pages and sending a single page pdf to the LLM. There are 2 choices, 1) have the LLM write the program to segment the multipage PDF into individual pages or 2 send the entire pdf to the LLM and have it return individual pages. Option 1 is O(1) in LLM tokens and option 2 is O(N) in tokens. N=num_pages There are 2 choices, extract the PDF as markdown or html. HTML is superior because you can run an agent in a loop to correct errors. A prompt that says "compare the pdf and html files, modify the css and html files to reduce text errors to zero. Make sur...