marker README

The project's README from github.com/datalab-to/marker. As one markdown file: README.md.

Datalab Logo

Datalab

State of the Art models for Document Intelligence

Code License Model License Discord

Homepage Docs Public Playground


Marker

Marker converts documents to markdown, JSON, chunks, and HTML quickly and accurately.

Try Datalab's Managed Platform

Our managed platform uses Chandra, our latest open source model, and other models — higher accuracy than Marker, with opt-in zero data retention, SOC 2 Type 2, and custom BAAs.

If you have high volume workloads, we offer a batch processing service that has processed 1B+ pages in a day at peak — we manage the infrastructure so your workloads finish on time.

The Datalab API turns documents into verifiable knowledge your agents act on. Every result traces back to its page and position, and one API can parse, extract, fill and edit documents.

Get started with about 5,000 free convert pages every month (work email) — sign up.

Performance

Marker is built around a simple premise: you shouldn't have to choose between VLM-level accuracy and production throughput, or maintain separate tools for GPU and CPU.

On OmniParseBench (GitHub) — 16,288 pass/fail unit tests across 2,937 pages in 92 languages covering text & reading order (8,499 tests), table cell structure (5,386 tests), and block layout (2,403 tests) — as well as olmOCR-bench, Marker defines the Pareto frontier across every hardware tier:

Which mode should I use?

Mode Hardware Throughput OmniParseBench Best for
--mode balanced (GPU default) GPU + CPU 16.9 pg/s 80.5 (85.6 olmOCR suites) Production mixed workloads (born-digital PDFs, tables, math, CJK, and scans)
--mode vllm GPU 4.5 pg/s 85.9 (83.7 olmOCR-bench) Maximum accuracy on degraded scans, dense equations, handwriting, & complex tables
--mode fast (CPU/MPS default) CPU / MPS only 23.6 pg/s 78.6 (77.8 olmOCR suites) Laptops, CI, serverless/CPU containers, and fast local OCR with zero GPU dependencies
--mode no_ocr CPU only 57.0 pg/s 42.4 (83.6 digital docs) Bulk born-digital PDFs when you want layout, reading order, & tables at maximum speed

See below for the full OmniParseBench and olmOCR-bench tables, per-suite breakdowns, and instructions on how to run your own benchmarks.

Hybrid Mode

For the highest accuracy, pass the --use_llm flag to use an LLM alongside marker. This will do things like merge tables across pages, handle inline math, format tables properly, and extract values from forms. It works with Gemini, Claude, OpenAI-compatible, Azure, Vertex, OpenRouter, or Ollama models. By default, it uses gemini-3.5-flash. See below for details.

Examples

PDF File type Markdown JSON
Think Python Textbook View View
Switch Transformers arXiv paper View View
Multi-column CNN arXiv paper View View

Commercial usage

Our code is licensed under Apache 2.0 — free to use, including commercially. Our model weights use a modified AI Pubs Open Rail-M license (free for research, personal use, and startups under $5M funding/revenue). For commercial use of the model weights beyond that, visit our pricing page here.

Community

Discord is where we discuss future development.

Installation

You'll need python 3.10+ and PyTorch.

Install with:

pip install marker-pdf

If you want to use marker on documents other than PDFs, you will need to install additional dependencies with:

pip install marker-pdf[full]

Inference backend prerequisites

Surya auto-spawns the server on first use, and you need vllm (NVIDIA GPU) or llama.cpp (CPU / Apple Silicon):

Usage

First, some configuration:

Interactive Viewer App

Marker includes a built-in interactive web viewer (no extra dependencies required) that lets you drop in PDFs, images, or Office documents and inspect layout blocks, reading order, text lines, stage timings, and rendered Markdown, HTML, Chunks, and JSON page by page across all conversion modes (no_ocr, fast, balanced, vllm). Run it with:

marker_gui --port 8000

Then open http://localhost:8000 in your browser (pass --streamlit if you want the legacy Streamlit UI).

Convert a single file

marker_single /path/to/file.pdf

You can pass in PDFs or images.

Options:

OCR runs through the surya VLM, which is multilingual - see the surya README for details. If you don't need OCR, marker can work with any language.

Convert multiple files

marker /path/to/input/folder

Batch sizing cheat sheet (e.g. 1000 docs)

Use from python

See the PdfConverter class at marker/converters/pdf.py function for additional arguments that can be passed.

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered

converter = PdfConverter(
    artifact_dict=create_model_dict(),
)
rendered = converter("FILEPATH")
text, _, images = text_from_rendered(rendered)

rendered will be a pydantic basemodel with different properties depending on the output type requested. With markdown output (default), you'll have the properties markdown, metadata, and images. For json output, you'll have children, block_type, and metadata.

Custom configuration

You can pass configuration using the ConfigParser. To see all available options, do marker_single --help.

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.config.parser import ConfigParser

config = {
    "output_format": "json",
    "ADDITIONAL_KEY": "VALUE"
}
config_parser = ConfigParser(config)

converter = PdfConverter(
    config=config_parser.generate_config_dict(),
    artifact_dict=create_model_dict(),
    processor_list=config_parser.get_processors(),
    renderer=config_parser.get_renderer(),
    llm_service=config_parser.get_llm_service()
)
rendered = converter("FILEPATH")

Extract blocks

Each document consists of one or more pages. Pages contain blocks, which can themselves contain other blocks. It's possible to programmatically manipulate these blocks.

Here's an example of extracting all forms from a document:

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.schema import BlockTypes

converter = PdfConverter(
    artifact_dict=create_model_dict(),
)
document = converter.build_document("FILEPATH")
forms = document.contained_blocks((BlockTypes.Form,))

Look at the processors for more examples of extracting and manipulating blocks.

Other converters

You can also use other converters that define different conversion pipelines:

Extract tables

The TableConverter will only convert and extract tables:

from marker.converters.table import TableConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered

converter = TableConverter(
    artifact_dict=create_model_dict(),
)
rendered = converter("FILEPATH")
text, _, images = text_from_rendered(rendered)

This takes all the same configuration as the PdfConverter. You can specify the configuration force_layout_block=Table to avoid layout detection and instead assume every page is a table. Tables are emitted as HTML (<table>) blocks; output_format=json gives you the table blocks with their page bounding boxes.

You can also run this via the CLI with

marker_single FILENAME --use_llm --force_layout_block Table --converter_cls marker.converters.table.TableConverter --output_format json

OCR Only

If you only want to run OCR, you can also do that through the OCRConverter. Set --keep_chars to keep individual characters and bounding boxes (digital PDFs only - pages that go through the VLM return block-level HTML without character boxes).

from marker.converters.ocr import OCRConverter
from marker.models import create_model_dict

converter = OCRConverter(
    artifact_dict=create_model_dict(),
)
rendered = converter("FILEPATH")

This takes all the same configuration as the PdfConverter.

You can also run this via the CLI with

marker_single FILENAME --converter_cls marker.converters.ocr.OCRConverter

Output Formats

Markdown

Markdown output will include:

HTML

HTML output is similar to markdown output:

JSON

JSON output will be organized in a tree-like structure, with the leaf nodes being blocks. Examples of leaf nodes are a single list item, a paragraph of text, or an image.

The output will be a list, with each list item representing a page. Each page is considered a block in the internal marker schema. There are different types of blocks to represent different elements.

Pages have the keys:

The child blocks have two additional keys:

Note that child blocks of pages can have their own children as well (a tree structure).

{
      "id": "/page/10/Page/366",
      "block_type": "Page",
      "html": "<content-ref src='/page/10/SectionHeader/0'></content-ref><content-ref src='/page/10/SectionHeader/1'></content-ref><content-ref src='/page/10/Text/2'></content-ref><content-ref src='/page/10/Text/3'></content-ref><content-ref src='/page/10/Figure/4'></content-ref><content-ref src='/page/10/SectionHeader/5'></content-ref><content-ref src='/page/10/SectionHeader/6'></content-ref><content-ref src='/page/10/TextInlineMath/7'></content-ref><content-ref src='/page/10/TextInlineMath/8'></content-ref><content-ref src='/page/10/Table/9'></content-ref><content-ref src='/page/10/SectionHeader/10'></content-ref><content-ref src='/page/10/Text/11'></content-ref>",
      "polygon": [[0.0, 0.0], [612.0, 0.0], [612.0, 792.0], [0.0, 792.0]],
      "children": [
        {
          "id": "/page/10/SectionHeader/0",
          "block_type": "SectionHeader",
          "html": "<h1>Supplementary Material for <i>Subspace Adversarial Training</i> </h1>",
          "polygon": [
            [217.845703125, 80.630859375], [374.73046875, 80.630859375],
            [374.73046875, 107.0],
            [217.845703125, 107.0]
          ],
          "children": null,
          "section_hierarchy": {
            "1": "/page/10/SectionHeader/1"
          },
          "images": {}
        },
        ...
        ]
    }

Chunks

Chunks format is similar to JSON, but flattens everything into a single list instead of a tree. Only the top level blocks from each page show up. It also has the full HTML of each block inside, so you don't need to crawl the tree to reconstruct it. This enable flexible and easy chunking for RAG.

Metadata

All output formats will return a metadata dictionary, with the following fields:

{
    "table_of_contents": [
      {
        "title": "Introduction",
        "heading_level": 1,
        "page_id": 0,
        "polygon": [...]
      }
    ], // computed PDF table of contents
    "page_stats": [
      {
        "page_id":  0,
        "text_extraction_method": "pdftext",
        "block_counts": [("Span", 200), ...]
      },
      ...
    ]
}

LLM Services

When running with the --use_llm flag, you have a choice of services you can use:

These services may have additional optional configuration as well - you can see it by viewing the classes.

Internals

Marker is easy to extend. The core units of marker are:

To customize processing behavior, override the processors. To add new output formats, write a new renderer. For additional input formats, write a new provider.

Processors and renderers can be directly passed into the base PDFConverter, so you can specify your own custom processing easily.

API server & Viewer

You can run the Marker FastAPI server and interactive viewer like this:

pip install -U uvicorn fastapi python-multipart
marker_server --port 8001

This starts a server at http://localhost:8001 (use --host to change the bind address):

You can send programmatic conversion requests to /marker or /marker/upload:

import requests
import json

post_data = {
    'filepath': 'FILEPATH',
    # Accepted params: page_range, mode, force_ocr, disable_ocr, use_llm,
    # strip_existing_ocr, keep_headers_footers, paginate_output, output_format
}

requests.post("http://localhost:8001/marker", data=json.dumps(post_data)).json()

Note that this server is intended for local inspection and small-scale use. If you want a production-grade conversion API with high concurrency, try the hosted Datalab API.

Troubleshooting

There are some settings that you may find useful if things aren't working the way you expect:

Debugging

Pass the debug option to activate debug mode. This will save images of each page with detected layout and text, as well as output a json file with additional bounding box information.

Benchmarks

OmniParseBench

We evaluate end-to-end document parsing with OmniParseBench (GitHub): 16,288 pass/fail unit tests across 2,937 pages from 2,343 documents over 22 suites and 92 languages. Tests are organized into three families:

The Headline score is the macro-average of the Text, Tables, and Layout family pass rates.

Competitive comparison

Quality vs. throughput on OmniParseBench — up (higher score) and right (faster) is better:

Representative scores from the OmniParseBench leaderboard and our benchmark harness alongside Marker's four conversion modes:

System Type / Weights Headline Text Tables Layout Throughput*
Datalab API (accurate) Hosted API 94.1 92.0 94.2 96.0 —
Datalab API (balanced) Hosted API 92.6 90.1 91.6 96.2 —
Reducto Hosted API 90.8 85.4 91.2 95.8 —
LlamaParse Hosted API 90.4 88.2 92.6 90.4 —
Chandra OCR 2 Open VLM (4.5B, GPU) 90.1 87.4 87.4 95.4 —
Mistral OCR Hosted API 89.5 82.8 91.9 93.8 —
dots.mocr Open VLM (3.0B, GPU) 87.9 82.5 88.6 92.5 —
MinerU 2.5-Pro Open VLM (1.2B, GPU) 87.1 77.4 92.1 91.7 0.54 pg/s
Marker — vllm (Surya 2.5) Open VLM (0.69B, GPU) 85.9 83.8 78.3 95.7 4.5 pg/s
Surya OCR 2 Open VLM (0.67B, GPU) 83.1 80.6 74.3 94.3 2.2 pg/s
Azure Document Intelligence Hosted API 83.0 74.6 81.7 92.8 —
LightOnOCR-3-4B Open VLM (4.5B, GPU) 82.9 83.9 70.8 94.0 —
GLM-OCR Open VLM (1.3B, GPU) 81.5 71.0 84.2 89.3 —
Marker — balanced Open Hybrid (GPU + CPU) 80.5 79.2 72.9 92.5 16.9 pg/s
Nemotron 3.5 Parse Open VLM (0.63B, GPU) 80.0 72.4 77.3 90.2 —
Indra OCR (standalone) Open ONNX (12M, CPU) 78.9 68.0 75.9 92.7 30.0 pg/s
PaddleOCR-VL-1.6 Open VLM (0.96B, GPU) 78.7 61.7 83.7 90.7 ~1.2 pg/s
Marker — fast Open ONNX (CPU, no GPU) 78.6 67.8 75.7 92.4 23.6 pg/s
DeepSeek-OCR-2 Open VLM (3.4B, GPU) 75.2 64.2 70.0 91.4 ~0.8 pg/s
docling Open Pipeline (GPU / CPU) 67.5 44.4 72.0 85.9 2.1 pg/s
HunyuanOCR-1.5 Open VLM (1.0B, GPU) 64.6 50.5 61.9 81.4 —
PaddleOCR PP-StructureV3 Open Pipeline (CPU) 58.4 55.6 47.8 71.7 ≤ 0.18 pg/s
Marker — no_ocr Open Text-layer + ONNX (CPU) 42.4 22.8 21.8 82.7 57.0 pg/s
olmOCR-2 Open VLM (8.3B, no layout) 42.6** 71.3 56.6 0.0 —
Nanonets-OCR2-3B Open VLM (3.8B, no layout) 43.6** 68.2 62.6 0.0 —
liteparse Open Parser (CPU, no layout/tables) 14.0 42.0 0.0 0.0 9.7 pg/s
liteparse (--no-ocr) Open Text-layer (CPU, no layout/tables) 12.0 36.1 0.0 0.0 318.0 pg/s
Tesseract 5 Open OCR (CPU, no layout/tables) 5.9 17.6 0.0 0.0 2.9 pg/s

* Throughput is sustained concurrent pages/sec on a single host (Marker balanced / vllm, MinerU, and docling on one GPU; Marker fast / no_ocr, Indra OCR, PP-StructureV3, liteparse, and Tesseract 5 on CPU with no GPU).
** Systems that emit only Markdown without block layout annotations or HTML tables score 0.0 on those test families.

Ranked headline scores and concurrent throughput across systems:

Per-family breakdown (Text, Tables, Layout) across representative models:

Marker modes vs. docling, per OmniParseBench suite

Suite Tests balanced (GPU) fast (CPU ONNX) no_ocr (CPU) docling
olmo_arxiv_math 3,272 90.8 82.5 49.5 59.0
olmo_table_tests 718 88.4 86.3 54.0 88.1
olmo_multi_column 352 88.2 85.6 80.7 83.9
olmo_old_scans_math 450 85.5 65.2 48.7 4.8
olmo_long_tiny_text 237 78.4 85.2 59.0 61.6
olmo_old_scans 395 70.5 53.4 42.1 31.3
tables_derived 5,427 84.5 88.2 63.3 88.4
synth_copies 1,881 85.4 79.5 46.2 73.1
multiling_finepdfs 676 80.2 88.3 59.7 63.2
realdoc_pages 445 77.1 77.6 21.1 71.6
realdoc_pdfs 256 82.4 76.8 29.7 52.8
rotation_skew 377 84.6 89.1 34.4 81.1
tiny_plans 372 83.9 84.5 45.1 91.2
handwriting_samples 324 66.3 53.0 50.0 50.0
docparsing_images 299 86.3 80.6 29.1 87.0
parsebench_docs 293 91.0 91.0 83.6 86.9
forms_federal 127 74.1 59.2 16.3 75.0
forms_filled 107 75.9 77.1 47.8 81.3
forms_documentcloud 47 90.3 85.0 97.4 100.0
OmniParseBench Headline 16,288 80.5 78.6 42.4 67.5
olmOCR-bench suites (6-suite mean) 5,424 85.6 77.8 45.3 54.8
Sustained Throughput — 16.9 pg/s 23.6 pg/s 57.0 pg/s 2.1 pg/s

CPU-only parsing

If you have no GPU, Marker's fast (23.6 pg/s, 78.6 headline) and no_ocr (57.0 pg/s, 42.4 headline) modes run entirely in-process on CPU using Indra ONNX layout, reading order, table structure recognition, and line/math OCR:

olmOCR-bench

We also evaluate on the standalone olmOCR-bench harness (1,403 PDFs across 8 categories, scored with the official olmOCR-bench checker):

System Overall (8 splits) Born-digital (6 splits) Throughput
Chandra 2 (hosted) 85.8 — —
Marker — vllm (GPU) 83.7 89.5 4.5 pg/s
Gemini Flash 3.5 (API) 76.4 79.1 —
Marker — balanced (GPU) 76.0 83.5 2.9–16.9 pg/s
MinerU — pipeline (GPU) 72.7 83.3 0.54 pg/s
Marker — fast (CPU / ONNX) 66.6 71.6 7.4–23.6 pg/s
docling (GPU) 50.3 64.0 2.1 pg/s
Marker — no_ocr (CPU) 43.6 55.8 23.7–57.0 pg/s
liteparse (CPU) 22.4 27.3 8.9 pg/s
liteparse, no OCR (CPU) 20.4 25.0 1721 pg/s

Per-category breakdown on the standalone 8-split olmOCR-bench:

Category vllm balanced fast no_ocr
arXiv math 87.0 83.9 23.4 0.0
Tables 90.9 73.4 69.0 46.1
Multi column 83.3 76.6 76.0 67.0
Headers & footers 90.9 95.9 93.2 92.8
Long tiny text 94.8 71.3 68.3 43.2
Old scans math 78.6 63.8 59.8 0.0
Old scans 44.3 43.2 43.2 14.3
Baseline 99.9 99.7 99.9 85.9
Overall 83.7 76.0 66.6 43.6
Overall (born-digital only) 89.5 83.5 71.6 55.8

Throughput

Production throughput comes from concurrency, not single-stream latency. Marker runs thin conversion workers that hold small CPU models (Indra ONNX layout/OCR, OCR-error detection) and share a single inference server in balanced / vllm modes; the parent process budgets VLM concurrency across them, so throughput scales with server capacity rather than per-process VRAM.

Sustained concurrent throughput across OmniParseBench (2,937 pages) and olmOCR-bench (1,403 pages):

Mode OmniParseBench Throughput olmOCR-bench Throughput Hardware
no_ocr 57.0 pg/s 23.7–33 pg/s CPU only (pdftext + Indra ONNX layout)
fast 23.6 pg/s 7.4–33 pg/s CPU only (Indra ONNX layout + ONNX OCR)
balanced 16.9 pg/s 2.9–16.9 pg/s Hybrid (CPU Indra ONNX + GPU Surya 2.5 VLM)
vllm 4.5 pg/s 4.5 pg/s GPU (full-page Surya 2.5 VLM)

no_ocr and fast run in-process on CPU (pdftext + Indra ONNX layout and OCR, no VLM server) and need no GPU at all. balanced routes clean digital prose on CPU and sends only equations, complex tables, non-Latin scripts, and scanned pages to the GPU Surya 2.5 VLM server.

Table Conversion

Marker can extract tables from PDFs using marker.converters.table.TableConverter. Table quality is measured directly in OmniParseBench (5,386 table tests across olmo_table_tests and tables_derived) and olmOCR-bench. Digital tables are reconstructed from the PDF text layer on CPU; scanned tables and low-confidence reconstructions fall back to the VLM in balanced / vllm modes. The --use_llm flag can improve difficult tables further (multi-page merges, complex spans).

Running your own benchmarks

Everything above is reproducible:

How it works

Marker is a hybrid pipeline combining in-process indra-ocr ONNX models and the surya VLM:

It only calls the VLM where necessary, which improves speed while keeping accuracy.

Limitations

PDF is a tricky format, so marker will not always work perfectly. Here are some known limitations that are on the roadmap to address:

Note: Passing the --use_llm and --force_ocr flags will mostly solve these issues. For documents that still fail, the hosted Datalab API uses Chandra and other models, with higher accuracy than Marker.

Usage and Deployment Examples

You can always run marker locally, but if you wanted to expose it as an API, we have a few options:

marker (datalab-to/marker)

Searching Database…

41.1K ·GitHub
What is this?Marker is a document conversion tool that turns PDFs (and other document types) into markdown, JSON, HTML, or chunked output quickly and accurately, extracting tables, equations, forms, and images along the way.
Is this a Python library, a CLI tool, or both?Both — it is a Python library with converter classes like PdfConverter and TableConverter, and it also ships CLI commands (marker_single, marker) plus a Streamlit demo app for interactive testing.
How do I install and run it?Install with pip after setting up Python 3.10+ and PyTorch, then run marker_single on a single PDF or marker on a folder for batch conversion; converting non-PDF formats like DOCX or PPTX needs extra dependencies installed.
What's the tradeoff between fast mode and balanced mode?Balanced mode (default on GPU) uses the surya VLM for layout and re-OCRs any page whose embedded text looks bad for the highest quality, while fast mode (default on CPU/MPS) uses a lighter layout detector and keeps VLM calls minimal, trading some accuracy on scanned or garbled pages for speed.
Can I use the model weights commercially for free?The code is Apache 2.0 and free for any use including commercial, but the model weights use a modified AI Pubs Open Rail-M license that's only free for research, personal use, and startups under $5M in funding/revenue — above that you need a paid license.
Which LLM providers can boost accuracy?Passing --usellm lets marker call Gemini, Claude, OpenAI-compatible endpoints, Azure, Vertex, OpenRouter, or Ollama models to merge tables across pages, fix inline math, and extract form values.
What file formats besides PDF can it convert?It also handles images, PPTX, DOCX, XLSX, HTML, and EPUB files in addition to PDFs, though non-PDF formats require extra dependencies to be installed.
How accurate is Marker compared to other PDF tools?On the olmocr-bench benchmark of 1,403 PDFs, balanced mode scores 76.0% overall and 83.5% on born-digital PDFs, ahead of MinerU and docling and within range of much larger vision-language models.
Can I extract just the tables from a document?Yes, the TableConverter pipeline only detects and converts tables, emitting them as HTML blocks (or JSON with page bounding boxes) via the CLI or Python API.
Creator
datalab-to
Size
23.6 MB
Stars
41.1K
Age
3y
Commits · 90 Days