Skip to content

A high-quality tool for convert PDF to Markdown and JSON.一站式开源高质量数据提取工具,将PDF转换成Markdown和JSON格式。

License

Notifications You must be signed in to change notification settings

opendatalab/MinerU

Repository files navigation

Changelog

  • 2025/07/05 Version 2.1.0 Released
    • This is the first major update of MinerU 2, which includes a large number of new features and improvements, covering significant performance optimizations, user experience enhancements, and bug fixes. The detailed update contents are as follows:
    • Performance Optimizations:
      • Significantly improved preprocessing speed for documents with specific resolutions (around 2000 pixels on the long side).
      • Greatly enhanced post-processing speed when the pipeline backend handles batch processing of documents with fewer pages (<10 pages).
      • Layout analysis speed of the pipeline backend has been increased by approximately 20%.
    • Experience Enhancements:
      • Built-in ready-to-use fastapi service and gradio webui. For detailed usage instructions, please refer to Documentation.
      • Adapted to sglang version 0.4.8, significantly reducing the GPU memory requirements for the vlm-sglang backend. It can now run on graphics cards with as little as 8GB GPU memory (Turing architecture or newer).
      • Added transparent parameter passing for all commands related to sglang, allowing the sglang-engine backend to receive all sglang parameters consistently with the sglang-server.
      • Supports feature extensions based on configuration files, including custom formula delimiters, enabling heading classification, and customizing local model directories. For detailed usage instructions, please refer to Documentation.
    • New Features:
      • Updated the pipeline backend with the PP-OCRv5 multilingual text recognition model, supporting text recognition in 37 languages such as French, Spanish, Portuguese, Russian, and Korean, with an average accuracy improvement of over 30%. Details
      • Introduced limited support for vertical text layout in the pipeline backend.
History Log
2025/06/20 2.0.6 Released
  • Fixed occasional parsing interruptions caused by invalid block content in vlm mode
  • Fixed parsing interruptions caused by incomplete table structures in vlm mode
2025/06/17 2.0.5 Released
  • Fixed the issue where models were still required to be downloaded in the sglang-client mode
  • Fixed the issue where the sglang-client mode unnecessarily depended on packages like torch during runtime.
  • Fixed the issue where only the first instance would take effect when attempting to launch multiple sglang-client instances via multiple URLs within the same process
2025/06/15 2.0.3 released
  • Fixed a configuration file key-value update error that occurred when downloading model type was set to all
  • Fixed the issue where the formula and table feature toggle switches were not working in command line mode, causing the features to remain enabled.
  • Fixed compatibility issues with sglang version 0.4.7 in the sglang-engine mode.
  • Updated Dockerfile and installation documentation for deploying the full version of MinerU in sglang environment
2025/06/13 2.0.0 Released
  • New Architecture: MinerU 2.0 has been deeply restructured in code organization and interaction methods, significantly improving system usability, maintainability, and extensibility.
    • Removal of Third-party Dependency Limitations: Completely eliminated the dependency on pymupdf, moving the project toward a more open and compliant open-source direction.
    • Ready-to-use, Easy Configuration: No need to manually edit JSON configuration files; most parameters can now be set directly via command line or API.
    • Automatic Model Management: Added automatic model download and update mechanisms, allowing users to complete model deployment without manual intervention.
    • Offline Deployment Friendly: Provides built-in model download commands, supporting deployment requirements in completely offline environments.
    • Streamlined Code Structure: Removed thousands of lines of redundant code, simplified class inheritance logic, significantly improving code readability and development efficiency.
    • Unified Intermediate Format Output: Adopted standardized middle_json format, compatible with most secondary development scenarios based on this format, ensuring seamless ecosystem business migration.
  • New Model: MinerU 2.0 integrates our latest small-parameter, high-performance multimodal document parsing model, achieving end-to-end high-speed, high-precision document understanding.
    • Small Model, Big Capabilities: With parameters under 1B, yet surpassing traditional 72B-level vision-language models (VLMs) in parsing accuracy.
    • Multiple Functions in One: A single model covers multilingual recognition, handwriting recognition, layout analysis, table parsing, formula recognition, reading order sorting, and other core tasks.
    • Ultimate Inference Speed: Achieves peak throughput exceeding 10,000 tokens/s through sglang acceleration on a single NVIDIA 4090 card, easily handling large-scale document processing requirements.
    • Online Experience: You can experience our brand-new VLM model on MinerU.net, Hugging Face, and ModelScope.
  • Incompatible Changes Notice: To improve overall architectural rationality and long-term maintainability, this version contains some incompatible changes:
    • Python package name changed from magic-pdf to mineru, and the command-line tool changed from magic-pdf to mineru. Please update your scripts and command calls accordingly.
    • For modular system design and ecosystem consistency considerations, MinerU 2.0 no longer includes the LibreOffice document conversion module. If you need to process Office documents, we recommend converting them to PDF format through an independently deployed LibreOffice service before proceeding with subsequent parsing operations.
2025/05/24 Release 1.3.12
  • Added support for PPOCRv5 models, updated ch_server model to PP-OCRv5_rec_server, and ch_lite model to PP-OCRv5_rec_mobile (model update required)
    • In testing, we found that PPOCRv5(server) has some improvement for handwritten documents, but has slightly lower accuracy than v4_server_doc for other document types, so the default ch model remains unchanged as PP-OCRv4_server_rec_doc.
    • Since PPOCRv5 has enhanced recognition capabilities for handwriting and special characters, you can manually choose the PPOCRv5 model for Japanese-Traditional Chinese mixed scenarios and handwritten documents
    • You can select the appropriate model through the lang parameter lang='ch_server' (Python API) or --lang ch_server (command line):
      • ch: PP-OCRv4_server_rec_doc (default) (Chinese/English/Japanese/Traditional Chinese mixed/15K dictionary)
      • ch_server: PP-OCRv5_rec_server (Chinese/English/Japanese/Traditional Chinese mixed + handwriting/18K dictionary)
      • ch_lite: PP-OCRv5_rec_mobile (Chinese/English/Japanese/Traditional Chinese mixed + handwriting/18K dictionary)
      • ch_server_v4: PP-OCRv4_rec_server (Chinese/English mixed/6K dictionary)
      • ch_lite_v4: PP-OCRv4_rec_mobile (Chinese/English mixed/6K dictionary)
  • Added support for handwritten documents through optimized layout recognition of handwritten text areas
    • This feature is supported by default, no additional configuration required
    • You can refer to the instructions above to manually select the PPOCRv5 model for better handwritten document parsing results
  • The huggingface and modelscope demos have been updated to versions that support handwriting recognition and PPOCRv5 models, which you can experience online
2025/04/29 Release 1.3.10
  • Added support for custom formula delimiters, which can be configured by modifying the latex-delimiter-config section in the magic-pdf.json file in your user directory.
2025/04/27 Release 1.3.9
  • Optimized formula parsing functionality, improved formula rendering success rate
2025/04/23 Release 1.3.8
  • The default ocr model (ch) has been updated to PP-OCRv4_server_rec_doc (model update required)
    • PP-OCRv4_server_rec_doc is trained on a mixture of more Chinese document data and PP-OCR training data based on PP-OCRv4_server_rec, adding recognition capabilities for some traditional Chinese characters, Japanese, and special characters. It can recognize over 15,000 characters and improves both document-specific and general text recognition abilities.
    • Performance comparison of PP-OCRv4_server_rec_doc/PP-OCRv4_server_rec/PP-OCRv4_mobile_rec
    • After verification, the PP-OCRv4_server_rec_doc model shows significant accuracy improvements in Chinese/English/Japanese/Traditional Chinese in both single language and mixed language scenarios, with comparable speed to PP-OCRv4_server_rec, making it suitable for most use cases.
    • In some pure English scenarios, PP-OCRv4_server_rec_doc may have word adhesion issues, while PP-OCRv4_server_rec performs better in these cases. Therefore, we've kept the PP-OCRv4_server_rec model, which users can access by adding the parameter lang='ch_server' (Python API) or --lang ch_server (command line).
2025/04/22 Release 1.3.7
  • Fixed the issue where the lang parameter was ineffective during table parsing model initialization
  • Fixed the significant speed reduction of OCR and table parsing in cpu mode
2025/04/16 Release 1.3.4
  • Slightly improved OCR-det speed by removing some unnecessary blocks
  • Fixed page-internal sorting errors caused by footnotes in certain cases
2025/04/12 Release 1.3.2
  • Fixed dependency version incompatibility issues when installing on Windows with Python 3.13
  • Optimized memory usage during batch inference
  • Improved parsing of tables rotated 90 degrees
  • Enhanced parsing of oversized tables in financial report samples
  • Fixed the occasional word adhesion issue in English text areas when OCR language is not specified (model update required)
2025/04/08 Release 1.3.1
  • Fixed several compatibility issues
    • Added support for Python 3.13
    • Made final adaptations for outdated Linux systems (such as CentOS 7) with no guarantee of continued support in future versions, installation instructions
2025/04/03 Release 1.3.0
  • Installation and compatibility optimizations
    • Resolved compatibility issues caused by detectron2 by removing layoutlmv3 usage in layout
    • Extended torch version compatibility to 2.2~2.6 (excluding 2.5)
    • Added CUDA compatibility for versions 11.8/12.4/12.6/12.8 (CUDA version determined by torch), solving compatibility issues for users with 50-series and H-series GPUs
    • Extended Python compatibility to versions 3.10~3.12, fixing the issue of automatic downgrade to version 0.6.1 when installing in non-3.10 environments
    • Optimized offline deployment process, eliminating the need to download any model files after successful deployment
  • Performance optimizations
    • Enhanced parsing speed for batches of small files by supporting batch processing of multiple PDF files (script example), with formula parsing speed improved by up to 1400% and overall parsing speed improved by up to 500% compared to version 1.0.1
    • Reduced memory usage and improved parsing speed by optimizing MFR model loading and usage (requires re-running the model download process to get incremental updates to model files)
    • Optimized GPU memory usage, requiring only 6GB minimum to run this project
    • Improved running speed on MPS devices
  • Parsing effect optimizations
    • Updated MFR model to unimernet(2503), fixing line break loss issues in multi-line formulas
  • Usability optimizations
    • Completely replaced the paddle framework and paddleocr in the project by using paddleocr2torch, resolving conflicts between paddle and torch, as well as thread safety issues caused by the paddle framework
    • Added real-time progress bar display during parsing, allowing precise tracking of parsing progress and making the waiting process more bearable
2025/03/03 1.2.1 released
  • Fixed the impact on punctuation marks during full-width to half-width conversion of letters and numbers
  • Fixed caption matching inaccuracies in certain scenarios
  • Fixed formula span loss issues in certain scenarios
2025/02/24 1.2.0 released

This version includes several fixes and improvements to enhance parsing efficiency and accuracy:

  • Performance Optimization
    • Increased classification speed for PDF documents in auto mode.
  • Parsing Optimization
    • Improved parsing logic for documents containing watermarks, significantly enhancing the parsing results for such documents.
    • Enhanced the matching logic for multiple images/tables and captions within a single page, improving the accuracy of image-text matching in complex layouts.
  • Bug Fixes
    • Fixed an issue where image/table spans were incorrectly filled into text blocks under certain conditions.
    • Resolved an issue where title blocks were empty in some cases.
2025/01/22 1.1.0 released

In this version we have focused on improving parsing accuracy and efficiency:

  • Model capability upgrade (requires re-executing the model download process to obtain incremental updates of model files)
    • The layout recognition model has been upgraded to the latest doclayout_yolo(2501) model, improving layout recognition accuracy.
    • The formula parsing model has been upgraded to the latest unimernet(2501) model, improving formula recognition accuracy.
  • Performance optimization
    • On devices that meet certain configuration requirements (16GB+ VRAM), by optimizing resource usage and restructuring the processing pipeline, overall parsing speed has been increased by more than 50%.
  • Parsing effect optimization
    • Added a new heading classification feature (testing version, enabled by default) to the online demo (mineru.net/huggingface/modelscope), which supports hierarchical classification of headings, thereby enhancing document structuring.
2025/01/10 1.0.1 released

This is our first official release, where we have introduced a completely new API interface and enhanced compatibility through extensive refactoring, as well as a brand new automatic language identification feature:

  • New API Interface
    • For the data-side API, we have introduced the Dataset class, designed to provide a robust and flexible data processing framework. This framework currently supports a variety of document formats, including images (.jpg and .png), PDFs, Word documents (.doc and .docx), and PowerPoint presentations (.ppt and .pptx). It ensures effective support for data processing tasks ranging from simple to complex.
    • For the user-side API, we have meticulously designed the MinerU processing workflow as a series of composable Stages. Each Stage represents a specific processing step, allowing users to define new Stages according to their needs and creatively combine these stages to customize their data processing workflows.
  • Enhanced Compatibility
    • By optimizing the dependency environment and configuration items, we ensure stable and efficient operation on ARM architecture Linux systems.
    • We have deeply integrated with Huawei Ascend NPU acceleration, providing autonomous and controllable high-performance computing capabilities. This supports the localization and development of AI application platforms in China. Ascend NPU Acceleration
  • Automatic Language Identification
    • By introducing a new language recognition model, setting the lang configuration to auto during document parsing will automatically select the appropriate OCR language model, improving the accuracy of scanned document parsing.
2024/11/22 0.10.0 released

Introducing hybrid OCR text extraction capabilities:

  • Significantly improved parsing performance in complex text distribution scenarios such as dense formulas, irregular span regions, and text represented by images.
  • Combines the dual advantages of accurate content extraction and faster speed in text mode, and more precise span/line region recognition in OCR mode.
2024/11/15 0.9.3 released

Integrated RapidTable for table recognition, improving single-table parsing speed by more than 10 times, with higher accuracy and lower GPU memory usage.

2024/11/06 0.9.2 released

Integrated the StructTable-InternVL2-1B model for table recognition functionality.

2024/10/31 0.9.0 released

This is a major new version with extensive code refactoring, addressing numerous issues, improving performance, reducing hardware requirements, and enhancing usability:

  • Refactored the sorting module code to use layoutreader for reading order sorting, ensuring high accuracy in various layouts.
  • Refactored the paragraph concatenation module to achieve good results in cross-column, cross-page, cross-figure, and cross-table scenarios.
  • Refactored the list and table of contents recognition functions, significantly improving the accuracy of list blocks and table of contents blocks, as well as the parsing of corresponding text paragraphs.
  • Refactored the matching logic for figures, tables, and descriptive text, greatly enhancing the accuracy of matching captions and footnotes to figures and tables, and reducing the loss rate of descriptive text to near zero.
  • Added multi-language support for OCR, supporting detection and recognition of 84 languages. For the list of supported languages, see OCR Language Support List.
  • Added memory recycling logic and other memory optimization measures, significantly reducing memory usage. The memory requirement for enabling all acceleration features except table acceleration (layout/formula/OCR) has been reduced from 16GB to 8GB, and the memory requirement for enabling all acceleration features has been reduced from 24GB to 10GB.
  • Optimized configuration file feature switches, adding an independent formula detection switch to significantly improve speed and parsing results when formula detection is not needed.
  • Integrated PDF-Extract-Kit 1.0:
    • Added the self-developed doclayout_yolo model, which speeds up processing by more than 10 times compared to the original solution while maintaining similar parsing effects, and can be freely switched with layoutlmv3 via the configuration file.
    • Upgraded formula parsing to unimernet 0.2.1, improving formula parsing accuracy while significantly reducing memory usage.
    • Due to the repository change for PDF-Extract-Kit 1.0, you need to re-download the model. Please refer to How to Download Models for detailed steps.
2024/09/27 Version 0.8.1 released

Fixed some bugs, and providing a localized deployment version of the online demo and the front-end interface.

2024/09/09 Version 0.8.0 released

Supporting fast deployment with Dockerfile, and launching demos on Huggingface and Modelscope.

2024/08/30 Version 0.7.1 released

Add paddle tablemaster table recognition option

2024/08/09 Version 0.7.0b1 released

Simplified installation process, added table recognition functionality

2024/08/01 Version 0.6.2b1 released

Optimized dependency conflict issues and installation documentation

2024/07/05 Initial open-source release

Table of Contents

  1. MinerU
  2. TODO
  3. Known Issues
  4. FAQ
  5. All Thanks To Our Contributors
  6. License Information
  7. Acknowledgments
  8. Citation
  9. Star History
  10. Links

MinerU

Project Introduction

MinerU is a tool that converts PDFs into machine-readable formats (e.g., markdown, JSON), allowing for easy extraction into any format. MinerU was born during the pre-training process of InternLM. We focus on solving symbol conversion issues in scientific literature and hope to contribute to technological development in the era of large models. Compared to well-known commercial products, MinerU is still young. If you encounter any issues or if the results are not as expected, please submit an issue on issue and attach the relevant PDF.

pdf_zh_cn.mp4

Key Features

  • Remove headers, footers, footnotes, page numbers, etc., to ensure semantic coherence.
  • Output text in human-readable order, suitable for single-column, multi-column, and complex layouts.
  • Preserve the structure of the original document, including headings, paragraphs, lists, etc.
  • Extract images, image descriptions, tables, table titles, and footnotes.
  • Automatically recognize and convert formulas in the document to LaTeX format.
  • Automatically recognize and convert tables in the document to HTML format.
  • Automatically detect scanned PDFs and garbled PDFs and enable OCR functionality.
  • OCR supports detection and recognition of 84 languages.
  • Supports multiple output formats, such as multimodal and NLP Markdown, JSON sorted by reading order, and rich intermediate formats.
  • Supports various visualization results, including layout visualization and span visualization, for efficient confirmation of output quality.
  • Supports running in a pure CPU environment, and also supports GPU(CUDA)/NPU(CANN)/MPS acceleration
  • Compatible with Windows, Linux, and Mac platforms.

Quick Start

If you encounter any installation issues, please first consult the FAQ.
If the parsing results are not as expected, refer to the Known Issues.
There are three different ways to experience MinerU:

Warning

Pre-installation Notice—Hardware and Software Environment Support

To ensure the stability and reliability of the project, we only optimize and test for specific hardware and software environments during development. This ensures that users deploying and running the project on recommended system configurations will get the best performance with the fewest compatibility issues.

By focusing resources on the mainline environment, our team can more efficiently resolve potential bugs and develop new features.

In non-mainline environments, due to the diversity of hardware and software configurations, as well as third-party dependency compatibility issues, we cannot guarantee 100% project availability. Therefore, for users who wish to use this project in non-recommended environments, we suggest carefully reading the documentation and FAQ first. Most issues already have corresponding solutions in the FAQ. We also encourage community feedback to help us gradually expand support.

Parsing Backend pipeline vlm-transformers vlm-sglang
Operating System windows/linux/mac windows/linux windows(wsl2)/linux
CPU Inference Support
GPU Requirements Turing architecture or later, 6GB+ VRAM or Apple Silicon Turing architecture or later, 8GB+ VRAM
Memory Requirements Minimum 16GB+, 32GB+ recommended
Disk Space Requirements 20GB+, SSD recommended
Python Version 3.10-3.13

Online Demo

OpenDataLab HuggingFace ModelScope

Local Deployment

1. Install MinerU

1.1 Install via pip or uv

pip install --upgrade pip
pip install uv
uv pip install -U "mineru[core]"

1.2 Install from source

git clone https://github.com/opendatalab/MinerU.git
cd MinerU
uv pip install -e .[core]

Note

Linux and macOS systems automatically support CUDA/MPS acceleration after installation. For Windows users who want to use CUDA acceleration, please visit the PyTorch official website to install PyTorch with the appropriate CUDA version.

1.3 Install Full Version (supports sglang acceleration) (requires device with Turing or newer architecture and at least 8GB GPU memory)

If you need to use sglang to accelerate VLM model inference, you can choose any of the following methods to install the full version:

  • Install using uv or pip:
    uv pip install -U "mineru[all]"
  • Install from source:
    uv pip install -e .[all]

Tip

If any exceptions occur during the installation of sglang, please refer to the official sglang documentation for troubleshooting and solutions, or directly use Docker-based installation.

  • Build image using Dockerfile:
    wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/global/Dockerfile
    docker build -t mineru-sglang:latest -f Dockerfile .
    Start Docker container:
    docker run --gpus all \
      --shm-size 32g \
      -p 30000:30000 \
      --ipc=host \
      mineru-sglang:latest \
      mineru-sglang-server --host 0.0.0.0 --port 30000
    Or start using Docker Compose:
      wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/compose.yaml
      docker compose -f compose.yaml up -d

Tip

The Dockerfile uses lmsysorg/sglang:v0.4.8.post1-cu126 as the default base image, which supports the Turing/Ampere/Ada Lovelace/Hopper platforms.
If you are using the newer Blackwell platform, please change the base image to lmsysorg/sglang:v0.4.8.post1-cu128-b200.

1.4 Install client (for connecting to sglang-server on edge devices that require only CPU and network connectivity)

uv pip install -U mineru
mineru -p <input_path> -o <output_path> -b vlm-sglang-client -u http://<host_ip>:<port>

2. Using MinerU

2.1 Command Line Usage

Basic Usage

The simplest command line invocation is:

mineru -p <input_path> -o <output_path>
  • <input_path>: Local PDF/Image file or directory (supports pdf/png/jpg/jpeg/webp/gif)
  • <output_path>: Output directory
View Help Information

Get all available parameter descriptions:

mineru --help
Parameter Details
Usage: mineru [OPTIONS]

Options:
  -v, --version                   Show version and exit
  -p, --path PATH                 Input file path or directory (required)
  -o, --output PATH              Output directory (required)
  -m, --method [auto|txt|ocr]     Parsing method: auto (default), txt, ocr (pipeline backend only)
  -b, --backend [pipeline|vlm-transformers|vlm-sglang-engine|vlm-sglang-client]
                                  Parsing backend (default: pipeline)
  -l, --lang [ch|ch_server|ch_lite|en|korean|japan|chinese_cht|ta|te|ka|latin|arabic|east_slavic|cyrillic|devanagari]
                                  Specify document language (improves OCR accuracy, pipeline backend only)
  -u, --url TEXT                  Service address when using sglang-client
  -s, --start INTEGER             Starting page number (0-based)
  -e, --end INTEGER               Ending page number (0-based)
  -f, --formula BOOLEAN           Enable formula parsing (default: on)
  -t, --table BOOLEAN             Enable table parsing (default: on)
  -d, --device TEXT               Inference device (e.g., cpu/cuda/cuda:0/npu/mps, pipeline backend only)
  --vram INTEGER                  Maximum GPU VRAM usage per process (GB)(pipeline backend only)
  --source [huggingface|modelscope|local]
                                  Model source, default: huggingface
  --help                          Show help information

2.2 Model Source Configuration

MinerU automatically downloads required models from HuggingFace on first run. If HuggingFace is inaccessible, you can switch model sources:

Switch to ModelScope Source
mineru -p <input_path> -o <output_path> --source modelscope

Or set environment variable:

export MINERU_MODEL_SOURCE=modelscope
mineru -p <input_path> -o <output_path>
Using Local Models
1. Download Models Locally
mineru-models-download --help

Or use interactive command-line tool to select models:

mineru-models-download

After download, model paths will be displayed in current terminal and automatically written to mineru.json in user directory.

2. Parse Using Local Models
mineru -p <input_path> -o <output_path> --source local

Or enable via environment variable:

export MINERU_MODEL_SOURCE=local
mineru -p <input_path> -o <output_path>

2.3 Using sglang to Accelerate VLM Model Inference

Through the sglang-engine Mode
mineru -p <input_path> -o <output_path> -b vlm-sglang-engine
Through the sglang-server/client Mode
  1. Start Server:
mineru-sglang-server --port 30000
  1. Use Client in another terminal:
mineru -p <input_path> -o <output_path> -b vlm-sglang-client -u http://127.0.0.1:30000

Tip

For more information about output files, please refer to Output File Documentation


3. API Calls or Visual Invocation

  1. Directly invoke using Python API: Python Invocation Example

  2. Invoke using FastAPI:

    mineru-api --host 127.0.0.1 --port 8000

    Visit http://127.0.0.1:8000/docs in your browser to view the API documentation.

  3. Use Gradio WebUI or Gradio API:

    # Using pipeline/vlm-transformers/vlm-sglang-client backend
    mineru-gradio --server-name 127.0.0.1 --server-port 7860
    # Or using vlm-sglang-engine/pipeline backend
    mineru-gradio --server-name 127.0.0.1 --server-port 7860 --enable-sglang-engine true

    Access http://127.0.0.1:7860 in your browser to use the Gradio WebUI, or visit http://127.0.0.1:7860/?view=api to use the Gradio API.

Tip

Below are some suggestions and notes for using the sglang acceleration mode:

  • The sglang acceleration mode currently supports operation on Turing architecture GPUs with a minimum of 8GB VRAM, but you may encounter VRAM shortages on GPUs with less than 24GB VRAM. You can optimize VRAM usage with the following parameters:
    • If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by setting --mem-fraction-static 0.5. If VRAM issues persist, try lowering it further to 0.4 or below.
    • If you have more than one GPU, you can expand available VRAM using tensor parallelism (TP) mode: --tp-size 2
  • If you are already successfully using sglang to accelerate VLM inference but wish to further improve inference speed, consider the following parameters:
    • If using multiple GPUs, increase throughput using sglang's multi-GPU parallel mode: --dp-size 2
    • You can also enable torch.compile to accelerate inference speed by about 15%: --enable-torch-compile
  • For more information on using sglang parameters, please refer to the sglang official documentation
  • All sglang-supported parameters can be passed to MinerU via command-line arguments, including those used with the following commands: mineru, mineru-sglang-server, mineru-gradio, mineru-api

Tip

  • In any case, you can specify visible GPU devices at the start of a command line by adding the CUDA_VISIBLE_DEVICES environment variable. For example:
    CUDA_VISIBLE_DEVICES=1 mineru -p <input_path> -o <output_path>
  • This method works for all command-line calls, including mineru, mineru-sglang-server, mineru-gradio, and mineru-api, and applies to both pipeline and vlm backends.
  • Below are some common CUDA_VISIBLE_DEVICES settings:
    CUDA_VISIBLE_DEVICES=1 Only device 1 will be seen
    CUDA_VISIBLE_DEVICES=0,1 Devices 0 and 1 will be visible
    CUDA_VISIBLE_DEVICES="0,1" Same as above, quotation marks are optional
    CUDA_VISIBLE_DEVICES=0,2,3 Devices 0, 2, 3 will be visible; device 1 is masked
    CUDA_VISIBLE_DEVICES="" No GPU will be visible
  • Below are some possible use cases:
    • If you have multiple GPUs and need to specify GPU 0 and GPU 1 to launch 'sglang-server' in multi-GPU mode, you can use the following command:
    CUDA_VISIBLE_DEVICES=0,1 mineru-sglang-server --port 30000 --dp-size 2
    • If you have multiple GPUs and need to launch two fastapi services on GPU 0 and GPU 1 respectively, listening on different ports, you can use the following commands:
    # In terminal 1
    CUDA_VISIBLE_DEVICES=0 mineru-api --host 127.0.0.1 --port 8000
    # In terminal 2
    CUDA_VISIBLE_DEVICES=1 mineru-api --host 127.0.0.1 --port 8001

4. Extending MinerU Functionality Through Configuration Files

  • MinerU is designed to work out-of-the-box, but also supports extending functionality through configuration files. You can create a mineru.json file in your home directory and add custom configurations.
  • The mineru.json file will be automatically generated when you use the built-in model download command mineru-models-download. Alternatively, you can create it by copying the configuration template file to your home directory and renaming it to mineru.json.
  • Below are some available configuration options:
    • latex-delimiter-config: Used to configure LaTeX formula delimiters, defaults to the $ symbol, and can be modified to other symbols or strings as needed.
    • llm-aided-config: Used to configure related parameters for LLM-assisted heading level detection, compatible with all LLM models supporting the OpenAI protocol. It defaults to Alibaba Cloud Qwen's qwen2.5-32b-instruct model. You need to configure an API key yourself and set enable to true to activate this feature.
    • models-dir: Used to specify local model storage directories. Please specify separate model directories for the pipeline and vlm backends. After specifying these directories, you can use local models by setting the environment variable export MINERU_MODEL_SOURCE=local.

TODO

  • Reading order based on the model
  • Recognition of index and list in the main text
  • Table recognition
  • Heading Classification
  • Code block recognition in the main text
  • Chemical formula recognition
  • Geometric shape recognition

Known Issues

  • Reading order is determined by the model based on the spatial distribution of readable content, and may be out of order in some areas under extremely complex layouts.
  • Limited support for vertical text.
  • Tables of contents and lists are recognized through rules, and some uncommon list formats may not be recognized.
  • Code blocks are not yet supported in the layout model.
  • Comic books, art albums, primary school textbooks, and exercises cannot be parsed well.
  • Table recognition may result in row/column recognition errors in complex tables.
  • OCR recognition may produce inaccurate characters in PDFs of lesser-known languages (e.g., diacritical marks in Latin script, easily confused characters in Arabic script).
  • Some formulas may not render correctly in Markdown.

FAQ

  • If you encounter any issues during usage, you can first check the FAQ for solutions.
  • If your issue remains unresolved, you may also use DeepWiki to interact with an AI assistant, which can address most common problems.
  • If you still cannot resolve the issue, you are welcome to join our community via Discord or WeChat to discuss with other users and developers.

All Thanks To Our Contributors

License Information

LICENSE.md

Currently, some models in this project are trained based on YOLO. However, since YOLO follows the AGPL license, it may impose restrictions on certain use cases. In future iterations, we plan to explore and replace these with models under more permissive licenses to enhance user-friendliness and flexibility.

Acknowledgments

Citation

@misc{wang2024mineruopensourcesolutionprecise,
      title={MinerU: An Open-Source Solution for Precise Document Content Extraction}, 
      author={Bin Wang and Chao Xu and Xiaomeng Zhao and Linke Ouyang and Fan Wu and Zhiyuan Zhao and Rui Xu and Kaiwen Liu and Yuan Qu and Fukai Shang and Bo Zhang and Liqun Wei and Zhihao Sui and Wei Li and Botian Shi and Yu Qiao and Dahua Lin and Conghui He},
      year={2024},
      eprint={2409.18839},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2409.18839}, 
}

@article{he2024opendatalab,
  title={Opendatalab: Empowering general artificial intelligence with open datasets},
  author={He, Conghui and Li, Wei and Jin, Zhenjiang and Xu, Chao and Wang, Bin and Lin, Dahua},
  journal={arXiv preprint arXiv:2407.13773},
  year={2024}
}

Star History

Star History Chart

Links