Skip to content

Use pymupdf4llm in pdf fast process mode - #352

Open
Exino329 wants to merge 14 commits into
EPFLiGHT:mainfrom
Exino329:wip/ll-pymupdf4llm
Open

Exino329 wants to merge 14 commits into
EPFLiGHT:mainfrom
Exino329:wip/ll-pymupdf4llm

Conversation

@Exino329

@Exino329 Exino329 commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator

pymupdf has an extension named pymupdf4llm that can convert documents into structured Markdown, JSON, and plain text in a suitable way for RAG pipelines : https://github.com/pymupdf/pymupdf4llm.

There is now a new pdf processor src/mmore/process/processors/pdf_pymupdf4llm_processor.py that extract pdf in a markdown structure in fast mode.

It can be configured by setting :

dispatcher_config:
  use_fast_processors: true
  processor_selection:
    ".pdf": PDFPyMuPDF4LLMProcessor
  processor_config:
    PDFPyMuPDF4LLMProcessor:
      - image_dpi: 300  # optional, resolution figures are rendered at

in a process config file.

Comment thread src/mmore/process/utils.py Resolved
Comment thread pyproject.toml Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues affect processor selection, fast-mode execution, image handling, and downstream modality preservation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds an opt-in pymupdf4llm PDF processor for structured Markdown extraction in fast mode.

Changes:

  • Adds Markdown, paragraph metadata, and image extraction.
  • Preserves Markdown blank lines.
  • Adds the dependency, configuration documentation, and processor-selection tests.
File Summary Review notes
tests/​test_processor_selection.py Tests PDF processor selection. —
src/​mmore/​process/​utils.py Adds optional blank-line preservation. —
src/​mmore/​process/​processors/​pdf_pymupdf4llm_processor.py Implements the new Markdown-based PDF processor. Six findings: five moderate (votes: 1, 1, 2, 1, 2) and one nit (4 votes), covering image-link matching, default registration priority, missing extraction-path tests, reused image XObjects, modality chunking, and device-specific fast-mode handling.
pyproject.toml Adds the pymupdf4llm dependency. —
examples/​process/​config.yaml Documents PDF processor choices. —

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Exino329 Exino329 self-assigned this Sep 29, 2026
@Exino329
Exino329 marked this pull request as draft October 1, 2026 08:24
@Exino329
Exino329 marked this pull request as ready for review October 27, 2026 09:00
@Exino329

Exino329 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

As discussed with @fabnemEPFL, pymupdf4llm will be used as the default processor for the Index API.

The current behaviour is that a processor exposes a standard processor and potentially a "fast" processor, with the intention that the fast processor produces less accurate output.

Since PR #350 introduced configurable processor selection, we will change the behaviour to expose a list of available processors for each document type instead of separating them into "standard" and "fast" versions.

@Exino329
Exino329 requested a review from fabnemEPFL October 27, 2026 18:33
Comment thread src/mmore/run_index_api.py Resolved
Comment thread src/mmore/utils.py
output_path=output_path,
use_fast_processors=False,
# use pymupdf4llm by the api by default, should be configurable in the future
use_fast_processors=True,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fast processing will apply to other file types aside from pdf. Is it the intent?

@Exino329 Exino329 Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a temporary "hack" that was discussed with @fabnemEPFL. This is because for the moment, the separation between processor is done using normal mode or fast_mode, so enabling fast_mode is the only way to use pymupdf4llm in the index api for the moment. We should later fix the current processor selection to create a list of available processors instead of separating them by the normal or fast mode.

Comment thread tests/test_processor_selection.py Resolved
@Exino329
Exino329 requested a review from nawwam November 5, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues merge Markdown across page boundaries, strip meaningful list and code indentation, and cause excessive worker creation for single-PDF jobs.

3 open issues
3 resolved since last review

Review effort: Balanced

Comment thread src/mmore/process/utils.py Resolved
Comment thread src/mmore/utils.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants