1. In-Memory Metric Extraction (PyMuPDF)

When you upload a PDF, the document is read entirely in RAM as a byte stream (zero disk writes). PyMuPDF inspects the structural layout, counting total pages, native vector tables, embedded graphics/images, and calculating character density per page.

2. Dynamic AI Ingestion Routing (Llama 3.3)

The extracted document metrics are passed to meta-llama/Llama-3.3-70B-Instruct-Turbo via Together AI. The model evaluates the structural complexity and selects the most efficient extraction strategy for pharmaceutical regulatory compliance:

PYMUPDF

Fast processing for text-heavy narrative documents like Cover Letters and Clinical Summaries.

DOCLING

Deep parsing for multi-column layouts, stability tables, and dense specification grids.

UNSTRUCTURED_OCR

OCR engine fallback for scanned image PDFs lacking searchable text layers.

HYBRID

Combined pipeline routing text to PyMuPDF and complex tables to Docling.

3. Memory Cleanup

Once analysis finishes, the byte buffer is purged immediately from RAM, keeping system memory lean and preventing residual data accumulation.