LucasFazzi
New Contributor II

Great points here! I'm using a similar hybrid approach in production:

PyMuPDF runs on everything first, it extracts native text from digital PDFs (fast, free, zero AI cost). Any PDF that returns no text gets tagged as needs_ocr.

Only the needs_ocr documents go through ai_parse_document, scanned PDFs, complex layouts, etc. This keeps AI costs minimal.

For the consumption layer, instead of ai_query we chunk the extracted text (4K chars, 200 overlap) and expose it through a Gold view joined with business context. Attached that to a Genie space, users can now search inside 150K+ documents in natural language and it works surprisingly well.

ai_parse_document is powerful but expensive at scale. Using it only as a fallback for what PyMuPDF can't handle gives you the best of both worlds.