Typically, PDF to Markdown converters either do not do a very good job converting mathematical formulas to LaTeX, or require an NVIDIA GPU to run a Transformer model. After quite a bit of work, I have discovered a way of converting PDF files, with all mathematical formulas converted to LaTeX, and using Apple silicon GPUs for acceleration.
First, create a Python virtual environment and install docling and docling[vlm]. One way to do it is to quickly create a new file pyproject.toml:
[project]
name = "pdf-convert"
version = "0.1.0"
description = "Setting up the virtual environment for converting PDFs with Apple Silicon GPUs."
requires-python = ">=3.13"
dependencies = [
"docling",
"docling[vlm]",
]
and then run uv sync and source .venv/bin/activate. After setting up the environment, the launch command I used was:
docling --enrich-formula --pipeline vlm --vlm-model granite_docling file.pdf
This runs the Granite Docling model, with 258M parameters, on the Apple Silicon GPUs with MLX. The conversion process may take a while, but the results look excellent. I have added my setup above to a git repository so that I can use it more easily.