Repository navigation
feat: Add VisionPDFLoader for VLM-based Markdown extraction - #1066
Merged
AmitoVrito merged 2 commits intoOct 13, 2026
Merged
Conversation
…cess, mock-based tests doc.close() was skipped if any page's VLM call raised, leaking the fitz.Document/file handle. Page rasterization also called page.get_pixmap() concurrently across threads (via asyncio.to_thread under a bounded semaphore) on the shared fitz.Document, which is not safe for concurrent cross-thread access in PyMuPDF; rasterization is now serialized behind a lock while the LLM call still runs concurrently. Replaced the unittest.mock/MagicMock-based test doubles with a hand-written fake fitz module and a real temp PDF file per house testing standards, and fixed a mypy no-any-return on the pixmap bytes. Co-authored-by: Ashish Maurya <[email protected]>
AmitoVrito
force-pushed
the
feature/vision-pdf-loader
branch
from
October 13, 2026 17:00
6441220 to
06f9e80
Compare
AmitoVrito
approved these changes
Oct 13, 2026
AmitoVrito
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed and hardened before merge: fixed a resource leak (doc.close() skipped on a failed page), serialized PyMuPDF page rasterization (not safe for concurrent cross-thread access) behind a lock while still letting the LLM call run concurrently, replaced MagicMock-based tests with a hand-written fake fitz module + a real temp PDF, and updated the loader-count preflight test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces
VisionPDFLoader, a new async RAG data loader that bypasses traditional text-extraction libraries (like PyPDF/PyMuPDF text extraction) which often fail on complex enterprise documents (two-column academic papers, financial tables, charts, embedded images).Instead, it converts PDF pages into high-res images and passes them directly to a Vision-Language Model (VLM) (e.g., GPT-4o, Claude 3.5 Sonnet) to output perfectly structured Markdown.
Why?
Vision-based parsing is the absolute state-of-the-art for Enterprise RAG. By leveraging VLMs directly in the ingestion pipeline,
SynapseKitleaps ahead of standard LangChain loaders by perfectly capturing document structure, reading charts natively, and eliminating messy text overlap from complex layouts.Features
asyncioto process pages concurrently via a configurable Semaphore, blasting through large documents.BaseLLM(OpenAI, Anthropic, Gemini) by automatically formatting the multimodal payload depending on theBaseLLM's provider configuration.fitzfor ultra-fast, high-fidelity PDF rasterization without requiringpopplerOS dependencies.Changes
src/synapsekit/loaders/vision_pdf.pyfeaturing theVisionPDFLoader.VisionPDFLoaderinsrc/synapsekit/loaders/__init__.py.tests/loaders/test_vision_pdf.py.