Metadata-Version: 2.4
Name: docling-mps
Version: 2.110.1
Summary: Modular version of the Docling package: SDK and CLI for parsing PDF, DOCX, HTML, and more, to a unified document representation for powering downstream workflows such as gen AI applications.
Project-URL: homepage, https://github.com/docling-project/docling
Project-URL: repository, https://github.com/docling-project/docling
Project-URL: issues, https://github.com/docling-project/docling/issues
Project-URL: changelog, https://github.com/docling-project/docling/blob/main/CHANGELOG.md
Author-email: Christoph Auer <cau@zurich.ibm.com>, Michele Dolfi <dol@zurich.ibm.com>, Maxim Lysak <mly@zurich.ibm.com>, Nikos Livathinos <nli@zurich.ibm.com>, Ahmed Nassar <ahn@zurich.ibm.com>, Panos Vagenas <pva@zurich.ibm.com>, Peter Staar <taa@zurich.ibm.com>
License-Expression: MIT
License-File: LICENSE
Keywords: convert,docling,document,docx,html,layout model,markdown,pdf,segmentation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <4.0,>=3.10
Requires-Dist: certifi>=2024.7.4
Requires-Dist: docling-core<3.0.0,>=2.86.0
Requires-Dist: filetype<2.0.0,>=1.2.0
Requires-Dist: pluggy<2.0.0,>=1.0.0
Requires-Dist: pydantic-settings<3.0.0,>=2.3.0
Requires-Dist: pydantic<3.0.0,>=2.0.0
Requires-Dist: requests<3.0.0,>=2.32.2
Requires-Dist: tqdm<5.0.0,>=4.65.0
Provides-Extra: all
Requires-Dist: docling-slim[feat-ocr-easyocr,feat-ocr-mac,feat-ocr-tesserocr,format-audio,format-html-render,format-xml-xbrl,models-onnxruntime,models-remote,models-vlm-inline,standard]; extra == 'all'
Provides-Extra: cli
Requires-Dist: python-dotenv~=1.0; extra == 'cli'
Requires-Dist: rich>=13.0.0; extra == 'cli'
Requires-Dist: typer<0.27.0,>=0.12.5; extra == 'cli'
Provides-Extra: convert-core
Requires-Dist: numpy<3.0.0,>=1.24.0; extra == 'convert-core'
Requires-Dist: pillow<13.0.0,>=10.0.0; extra == 'convert-core'
Requires-Dist: rtree<2.0.0,>=1.3.0; extra == 'convert-core'
Requires-Dist: scipy<2.0.0,>=1.6.0; extra == 'convert-core'
Provides-Extra: extract-core
Requires-Dist: docling-slim[convert-core]; extra == 'extract-core'
Requires-Dist: polyfactory>=2.22.2; extra == 'extract-core'
Provides-Extra: feat-chunking
Requires-Dist: docling-core[chunking]<3.0.0,>=2.73.0; extra == 'feat-chunking'
Provides-Extra: feat-ocr-easyocr
Requires-Dist: easyocr<2.0,>=1.7; extra == 'feat-ocr-easyocr'
Requires-Dist: scikit-image>=0.19; extra == 'feat-ocr-easyocr'
Provides-Extra: feat-ocr-mac
Requires-Dist: ocrmac<2.0.0,>=1.0.0; (sys_platform == 'darwin') and extra == 'feat-ocr-mac'
Provides-Extra: feat-ocr-nemotron
Requires-Dist: nemotron-ocr>=2.0.0; (python_version == '3.12' and sys_platform == 'linux' and platform_machine == 'x86_64') and extra == 'feat-ocr-nemotron'
Provides-Extra: feat-ocr-rapidocr
Requires-Dist: rapidocr<4.0.0,>=3.9.1; extra == 'feat-ocr-rapidocr'
Provides-Extra: feat-ocr-rapidocr-onnx
Requires-Dist: onnxruntime<2.0.0,>=1.7.0; (python_version < '3.14') and extra == 'feat-ocr-rapidocr-onnx'
Requires-Dist: rapidocr<4.0.0,>=3.9.1; extra == 'feat-ocr-rapidocr-onnx'
Provides-Extra: feat-ocr-tesserocr
Requires-Dist: pandas<4.0.0,>=2.1.4; extra == 'feat-ocr-tesserocr'
Requires-Dist: tesserocr<3.0.0,>=2.7.1; extra == 'feat-ocr-tesserocr'
Provides-Extra: format-audio
Requires-Dist: mlx-whisper>=0.4.3; (python_version >= '3.10' and sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'format-audio'
Requires-Dist: numba>=0.63.0; extra == 'format-audio'
Requires-Dist: openai-whisper>=20250625; extra == 'format-audio'
Requires-Dist: whisper-s2t-reborn<2,>=1.6.3; (sys_platform != 'darwin' or platform_machine != 'arm64') and extra == 'format-audio'
Provides-Extra: format-docx
Requires-Dist: python-docx<2.0.0,>=1.1.2; extra == 'format-docx'
Provides-Extra: format-email
Requires-Dist: docling-slim[format-html]; extra == 'format-email'
Requires-Dist: mail-parser<5.0.0,>=4.1.4; extra == 'format-email'
Provides-Extra: format-html
Requires-Dist: beautifulsoup4<5.0.0,>=4.12.3; extra == 'format-html'
Requires-Dist: lxml<7.0.0,>=4.0.0; extra == 'format-html'
Provides-Extra: format-html-render
Requires-Dist: playwright>=1.58.0; extra == 'format-html-render'
Provides-Extra: format-latex
Requires-Dist: pylatexenc<3.0,>=2.10; extra == 'format-latex'
Provides-Extra: format-markdown
Requires-Dist: marko<3.0.0,>=2.1.2; extra == 'format-markdown'
Provides-Extra: format-office
Requires-Dist: docling-slim[format-docx,format-pptx,format-xlsx]; extra == 'format-office'
Provides-Extra: format-opendocument
Requires-Dist: odfdo<4.0.0,>=3.22.0; extra == 'format-opendocument'
Provides-Extra: format-pdf
Requires-Dist: docling-slim[format-pdf-docling,format-pdf-pypdfium2]; extra == 'format-pdf'
Provides-Extra: format-pdf-docling
Requires-Dist: docling-parse<8.0.0,>=7.0.0; extra == 'format-pdf-docling'
Requires-Dist: pypdfium2!=4.30.1,<6.0.0,>=4.30.0; extra == 'format-pdf-docling'
Provides-Extra: format-pdf-pypdfium2
Requires-Dist: pypdfium2!=4.30.1,<6.0.0,>=4.30.0; extra == 'format-pdf-pypdfium2'
Provides-Extra: format-pptx
Requires-Dist: python-pptx<2.0.0,>=1.0.2; extra == 'format-pptx'
Provides-Extra: format-web
Requires-Dist: docling-slim[format-html,format-markdown]; extra == 'format-web'
Provides-Extra: format-xlsx
Requires-Dist: openpyxl<4.0.0,>=3.1.5; extra == 'format-xlsx'
Provides-Extra: format-xml-xbrl
Requires-Dist: arelle-release<3.0.0,>=2.38.17; extra == 'format-xml-xbrl'
Provides-Extra: models-local
Requires-Dist: accelerate<2,>=1.0.0; extra == 'models-local'
Requires-Dist: defusedxml<0.8.0,>=0.7.1; extra == 'models-local'
Requires-Dist: docling-ibm-models<4,>=3.13.0; extra == 'models-local'
Requires-Dist: huggingface-hub<2,>=0.23; extra == 'models-local'
Requires-Dist: torch<3.0.0,>=2.2.2; extra == 'models-local'
Requires-Dist: torchvision<1,>=0; extra == 'models-local'
Provides-Extra: models-onnxruntime
Requires-Dist: onnxruntime-gpu<1.24; (python_version < '3.14' and (sys_platform == 'linux' or sys_platform == 'win32')) and extra == 'models-onnxruntime'
Requires-Dist: onnxruntime<1.24; (python_version < '3.14' and sys_platform == 'darwin') and extra == 'models-onnxruntime'
Provides-Extra: models-remote
Requires-Dist: tritonclient[grpc]<3.0.0,>=2.65.0; extra == 'models-remote'
Provides-Extra: models-vlm-inline
Requires-Dist: accelerate<2.0.0,>=1.2.1; extra == 'models-vlm-inline'
Requires-Dist: mlx-vlm<1.0.0,>=0.4.3; (python_version >= '3.10' and sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'models-vlm-inline'
Requires-Dist: peft>=0.18.1; extra == 'models-vlm-inline'
Requires-Dist: qwen-vl-utils>=0.0.11; extra == 'models-vlm-inline'
Requires-Dist: transformers!=5.0.*,!=5.1.*,!=5.2.*,!=5.3.*,<5.9.0,>=4.42.0; (sys_platform == 'darwin') and extra == 'models-vlm-inline'
Requires-Dist: transformers!=5.0.*,!=5.1.*,!=5.2.*,!=5.3.*,<6.0.0,>=4.42.0; (sys_platform != 'darwin') and extra == 'models-vlm-inline'
Provides-Extra: service-client
Requires-Dist: httpx<1.0.0,>=0.28; extra == 'service-client'
Requires-Dist: python-dotenv~=1.0; extra == 'service-client'
Requires-Dist: rich>=13.0.0; extra == 'service-client'
Requires-Dist: typer<0.27.0,>=0.12.5; extra == 'service-client'
Requires-Dist: websockets<17.0,>=14.0; extra == 'service-client'
Provides-Extra: standard
Requires-Dist: docling-slim[cli,extract-core,feat-chunking,feat-ocr-rapidocr,format-email,format-latex,format-office,format-pdf,format-web,models-local,service-client]; extra == 'standard'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://github.com/docling-project/docling">
    <img loading="lazy" alt="Docling" src="https://github.com/docling-project/docling/raw/main/docs/assets/docling_processing.png" width="100%"/>
  </a>
</p>

# Docling-MPS

> [!TIP]
> **Docling-MPS** is an optimized fork of Docling designed specifically for Apple Silicon (M-series Macs). By enabling native Metal Performance Shaders (MPS) execution for TableFormer V1 & V2 stages, it achieves up to **2x faster end-to-end processing speeds** on macOS compared to standard CPU-bound execution.

---

### Local Installation & Testing

To install this MPS-accelerated fork on your Mac:

1. Clone this repository locally:
   ```bash
   git clone https://github.com/thomasf1/docling-mps.git
   cd docling-mps
   ```

2. Install the package in editable mode in your virtual environment:
   ```bash
   /path/to/your/venv/bin/pip install -e .
   ```

3. Verify that the MPS version is successfully loaded:
   ```bash
   /path/to/your/venv/bin/python -c "import importlib.metadata; print('Docling Version:', importlib.metadata.version('docling-slim'))"
   ```
   **Expected Output**: `2.110.0+mps` (or similar `+mps` local suffix).

4. Convert a document using MPS acceleration:
   * **Via Python API**:
     ```python
     from docling.datamodel.base_models import InputFormat
     from docling.datamodel.pipeline_options import PdfPipelineOptions
     from docling.document_converter import DocumentConverter, PdfFormatOption

     options = PdfPipelineOptions()
     options.accelerator_options.device = "mps" # Enables GPU acceleration

     converter = DocumentConverter(
         format_options={
             InputFormat.PDF: PdfFormatOption(pipeline_options=options)
         }
     )
     result = converter.convert("document.pdf")
     print(result.document.export_to_markdown())
     ```
   * **Via CLI**:
     ```bash
     uv run docling --device mps path/to/document.pdf
     ```

---

<p align="center">
  <a href="https://trendshift.io/repositories/17240" target="_blank"><img src="https://trendshift.io/api/badge/repositories/17240" alt="DS4SD%2Fdocling | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</p>

[![arXiv](https://img.shields.io/badge/arXiv-2408.09869-b31b1b.svg)](https://arxiv.org/abs/2408.09869)
[![Docs](https://img.shields.io/badge/docs-live-brightgreen)](https://docling-project.github.io/docling/)
[![PyPI version](https://img.shields.io/pypi/v/docling)](https://pypi.org/project/docling/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/docling)](https://pypi.org/project/docling/)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
[![prek](https://img.shields.io/badge/prek-enabled-brightgreen)](https://pypi.org/project/prek/)
[![License MIT](https://img.shields.io/github/license/docling-project/docling)](https://opensource.org/licenses/MIT)
[![PyPI Downloads](https://static.pepy.tech/badge/docling/month)](https://pepy.tech/projects/docling)
[![Docling Actor](https://apify.com/actor-badge?actor=vancura/docling&fpr=docling)](https://apify.com/vancura/docling)
[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/097760a8-135e-4789-8234-90c8837d7f1c/ask?utm_source=github)
[![Discord](https://img.shields.io/discord/1399788921306746971?color=6A7EC2&logo=discord&logoColor=ffffff)](https://docling.ai/discord)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10101/badge)](https://www.bestpractices.dev/projects/10101)
[![LF AI & Data](https://img.shields.io/badge/LF%20AI%20%26%20Data-003778?logo=linuxfoundation&logoColor=fff&color=0094ff&labelColor=003778)](https://lfaidata.foundation/projects/)

## What is Docling ?

Docling simplifies document processing by parsing diverse formats — including advanced PDF understanding — and providing seamless integrations with the generative AI ecosystem.

## Features

- 🗂️ Parsing of [multiple document formats][supported_formats] including PDF, DOCX, PPTX, XLSX, HTML, EPUB, WAV, MP3, WebVTT, email formats (EML, MSG), images (PNG, TIFF, JPEG, ...), LaTeX, DocLang, plain text, and more
- 📑 Advanced PDF understanding incl. page layout, reading order, table structure, code, formulas, image classification, and more
- 🧬 A unified, expressive [DoclingDocument][docling_document] representation format
- ↪️ Various [export formats][supported_formats] and options, including Markdown, HTML, WebVTT, DocLang, [DocTags](https://arxiv.org/abs/2503.11576) and lossless JSON
- 📜 Support for several application-specific XML schemas including [DocLang](https://doclang.ai), [USPTO](https://www.uspto.gov/patents) patents, [JATS](https://jats.nlm.nih.gov/) articles, and [XBRL](https://www.xbrl.org/) financial reports.
- 🔒 Local execution capabilities for sensitive data and air-gapped environments
- 🤖 Plug-and-play [integrations][integrations] incl. LangChain, LlamaIndex, Crew AI & Haystack for agentic AI
- 🔍 Extensive OCR support for scanned PDFs and images
- 👓 Support for several Visual Language Models, such as ([GraniteDocling](https://huggingface.co/ibm-granite/granite-docling-258M))
- 🎙️ Audio support with Automatic Speech Recognition (ASR) models
- 🔌 Connect to any agent using the [MCP server](https://docling-project.github.io/docling/usage/mcp/)
- 🌐 Run Docling as a service with the [API server](https://docling-project.github.io/docling/usage/api_server/) (docling-serve)
- 💻 Simple and convenient CLI

### What's new

- 📄 Parsing of ODF (OpenDocument Format) files for text documents (`.odt`), spreadsheets (`.ods`), and presentations (`.odp`)
- 💼 Parsing of XBRL (eXtensible Business Reporting Language) documents for financial reports
- 📧 Parsing of email files (`.eml`, `.msg`)
- 📚 Parsing of EPUB (Electronic Publication) files for e-books
- 📝 Parsing of plain-text files (`.txt`, `.text`) and Markdown supersets (`.qmd`, `.Rmd`)
- 📊 Chart understanding (Barchart, Piechart, LinePlot): convert them into tables or code and add detailed descriptions

### Coming soon

- 📝 Metadata extraction, including title, authors, references & language
- 📝 Complex chemistry understanding (Molecular structures)

## Quickstart

### 1. Install

```bash
pip install docling
```

> **Note:** Python 3.9 support was dropped in docling version 2.70.0. Please use Python 3.10 or higher.

Works on macOS, Linux and Windows environments for both x86_64 and arm64 architectures.

More [detailed installation instructions](https://docling-project.github.io/docling/getting_started/installation/) are available in the docs.

## 2. Convert a document (CLI)

```bash
docling https://arxiv.org/pdf/2206.01062
```

This generates a .md file in the current directory containing structured document content.

You can also use 🥚[GraniteDocling](https://huggingface.co/ibm-granite/granite-docling-258M) and other VLMs via Docling CLI:

```bash
docling --pipeline vlm --vlm-model granite_docling https://arxiv.org/pdf/2206.01062
```

## 3. Python usage (recommended)

```python
from docling.document_converter import DocumentConverter

source = "https://arxiv.org/pdf/2408.09869"  # a document via a local path or URL
converter = DocumentConverter()
result = converter.convert(source)
print(result.document.export_to_markdown())  # output: "## Docling Technical Report[...]"
```

More advanced [usage](https://docling-project.github.io/docling/usage/) and [configuration](https://docling-project.github.io/docling/getting_started/installation/) options.

## Documentation

Check out Docling's [documentation](https://docling-project.github.io/docling/) for details on
installation, usage, concepts, recipes, extensions, and more.

## Examples

Go hands-on with our [examples](https://docling-project.github.io/docling/examples/),
demonstrating how to address different application use cases with Docling.

## Integrations

To further accelerate your AI application development, check out Docling's native
[integrations](https://docling-project.github.io/docling/integrations/) with popular frameworks
and tools.

## Get help and support

Please feel free to connect with us using the [discussion section](https://github.com/docling-project/docling/discussions).

## Technical report

For more details on Docling's inner workings, check out the [Docling Technical Report](https://arxiv.org/abs/2408.09869).

## Contributing

Please read [Contributing to Docling](https://github.com/docling-project/docling/blob/main/CONTRIBUTING.md) for details.

## References

If you use Docling in your projects, please consider citing the following:

```bib
@techreport{Docling,
  author = {Deep Search Team},
  month = {8},
  title = {Docling Technical Report},
  url = {https://arxiv.org/abs/2408.09869},
  eprint = {2408.09869},
  doi = {10.48550/arXiv.2408.09869},
  version = {1.0.0},
  year = {2024}
}
```

## Apple Silicon Optimizations & Benchmarks

This local version (`2.107.0+mps`) has been optimized to fully leverage Apple Silicon hardware (M-series chips) for document processing.

### Optimizations
- **MPS (Metal Performance Shaders) Enablement**: Removed CPU fallbacks for TableFormer V1 & V2 models, enabling standard PyTorch operations to execute natively on the GPU instead of CPU.
- **VLM Presets for Apple Silicon**: Added `GRANITEDOCLING` and `SMOLDOCLING` constants that dynamically select highly-optimized local `mlx-vlm` models on Apple Silicon.

### Benchmark Results (TableFormer V1 Accurate Mode)
Timings measured for processing financial reports in `/Volumes/18T/Annual/scratch/comparison` (156-page PDF documents) sequentially:

| PDF Document | Configuration | Processing Time (s) | Output Chars | Speedup vs CPU | Speedup vs MPS |
|---|---|---|---|---|---|
| **NASDAQ_LPCN_2023.pdf** | PyTorch CPU | 102.56s | 604,940 | 1.00x | 0.49x |
| | PyTorch MPS | 50.46s | 604,940 | **2.03x** | **1.00x** |
| **NYSE_ITT_2023.pdf** | PyTorch CPU | 121.35s | 453,126 | 1.00x | 0.49x |
| | PyTorch MPS | 59.24s | 453,126 | **2.05x** | **1.00x** |
| **OTC_SOMC_2023.pdf** | PyTorch CPU | 115.56s | 340,292 | 1.00x | 0.53x |
| | PyTorch MPS | 61.19s | 340,292 | **1.89x** | **1.00x** |

### Concurrent Workload Benchmark (Parallel Processing)
Concurrently processing all 3 documents using parallel Python subprocesses:
* **PyTorch CPU Parallel**: **226.53 seconds** (1.00x)
* **PyTorch MPS Parallel**: **110.61 seconds** (**2.05x speedup** vs CPU)

### CoreML & MLX Hardware Contention (Why they didn't pan out)

We also researched, converted, and benchmarked TableFormer V1's encoder to CoreML (linear quantized to INT8 for the Neural Engine) and MLX (GPU), and the Layout Model (RT-DETR) to ONNX running on Apple's `CoreMLExecutionProvider`. While successfully running with 100% numerical correctness, these backends did not outperform PyTorch MPS due to native platform architectural constraints:

1. **Graph Partitioning & Context Switching Overhead (Layout Model)**:
   - Because RT-DETR contains custom post-processing nodes unsupported by CoreML, ONNX Runtime split the model into **28 separate CoreML partitions**.
   - Transitioning between CoreML hardware execution and CPU fallback nodes required copying intermediate tensor data between ANE memory and system RAM 28 times per page. This context switching and memory copy overhead offset the ANE's raw processing speedup, making Layout CoreML (64.29s) slower than running natively on GPU via PyTorch MPS (50.46s).

2. **Apple Neural Engine (ANE) Multi-Process Contention**:
   - When attempting to run parallel document conversions concurrently under multiprocessing, Apple's E5/ANE runtime suffered from **compilation cache and file-lock collisions** on the compiled macho assets inside `/var/folders/`, throwing on-device model load failures (`ANE model load has failed...`).
   - This forced CoreML to fallback to silent CPU execution. The resulting core thread contention degraded parallel throughput significantly (**137.53s** wall time) compared to the hardware time-sliced GPU command queue multiplexing of **PyTorch MPS** (**110.61s**).

Thus, native **PyTorch MPS (GPU)** remains the most robust, performant, and scale-friendly backend for Docling on Apple Silicon.

## License

The Docling codebase is under MIT license.
For individual model usage, please refer to the model licenses found in the original packages.

## LF AI & Data

Docling is hosted as a project in the [LF AI & Data Foundation](https://lfaidata.foundation/projects/).

### IBM ❤️ Open Source AI

The project was started by the AI for knowledge team at IBM Research Zurich.

[supported_formats]: https://docling-project.github.io/docling/usage/supported_formats/
[docling_document]: https://docling-project.github.io/docling/concepts/docling_document/
[integrations]: https://docling-project.github.io/docling/integrations/
[extraction]: https://docling-project.github.io/docling/_generated/examples/extraction/
