A Python CLI that runs Tesseract on PDFs, then uses local or cloud LLMs to fix OCR errors and optionally emit Markdown.
Overview
LLM Aided OCR turns scanned PDFs into cleaner text by combining classical OCR with language-model correction. Pages render to images, pass through preprocessing and Tesseract, then move through chunked LLM passes that fix recognition mistakes and optionally format results as Markdown.
The pipeline can strip recurring headers and page numbers, preserve footnotes across page breaks, stitch chunk boundaries deterministically, and score output against raw OCR using conservation and similarity checks. Processing supports asynchronous API calls with bounded concurrency or local GGUF models through llama-cpp, plus optional GPU acceleration for local inference.
Configuration uses environment variables to pick OpenAI, Anthropic, or a local model, set token limits, toggle Markdown formatting, and control PDF rendering DPI. Users install Tesseract separately on the host alongside Python dependencies managed through the project setup.
Typical outputs are a raw OCR text file and a corrected Markdown or plain-text file for the same document basename, with detailed logging across conversion, chunking, correction, and quality assessment stages.
Key features
- PDF to image conversion for OCR
- Tesseract text extraction with preprocessing
- LLM OCR error correction per chunk
- Optional Markdown structuring
- OpenAI, Anthropic, or local LLM backends
- Asynchronous API chunk processing
- Header and page number suppression
- Quality assessment against raw OCR
Use cases
- Cleaning scanned PDF OCR output
- Producing Markdown from digitized books
- Batch correcting noisy document text
- Offline OCR cleanup with local LLMs
- Preparing archives for search or editing