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 runs a version of our latest open source model, Chandra — higher accuracy than Marker, with zero data retention by default, SOC 2 Type 2, and custom BAAs.

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

Get started with $5 in free credits — sign up.

Performance

We measure marker on olmocr-bench, a third-party benchmark of 1,403 PDFs with tests covering math, tables, multi-column layout, scans, and hard edge cases. Balanced mode scores 76.0% overall — 83.5% on born-digital PDFs — ahead of MinerU and docling and within range of much larger VLMs, while fast mode runs the layout + text-layer path far cheaper (and a no-OCR mode goes faster still). Scores are the olmocr-bench overall (macro-average across the 8 categories).

See below for the full per-category scores, the competitive comparison, 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 App

I've included a streamlit app that lets you interactively try marker with some basic options. Run it with:

pip install -U streamlit streamlit-ace
marker_gui

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": "SectionHea

marker (datalab-to/marker)

Searching Database…

40.5K ·GitHub
这是什么?Marker 是一款文档转换工具,能快速、准确地把 PDF(以及其他类型的文档)转换为 markdown、JSON、HTML 或分块输出,同时提取表格、公式、表单和图片。
这是 Python 库、命令行工具,还是两者都是?两者都是。它是一个 Python 库,提供 PdfConverter、TableConverter 等转换器类,同时也提供命令行工具(marker_single、marker),以及一个用于交互式测试的 Streamlit 演示应用。
我该如何安装和运行?在设置好 Python 3.10+ 和 PyTorch 后,使用 pip 安装,然后对单个 PDF 运行 marker_single,或对文件夹运行 marker 进行批量转换;转换 DOCX、PPTX 等非 PDF 格式需要额外安装依赖。
快速模式和均衡模式之间有什么取舍?均衡模式(GPU 上的默认模式)使用 surya VLM 进行版面分析,并对嵌入文本看起来有问题的页面重新进行 OCR,以获得最高质量;快速模式(CPU/MPS 上的默认模式)使用更轻量的版面检测器,并尽量减少 VLM 调用,代价是在扫描件或文字乱码的页面上准确率会有所下降,但速度更快。
我能免费将模型权重用于商业用途吗?代码采用 Apache 2.0 许可,可免费用于包括商业在内的任何用途;但模型权重采用修改版的 AI Pubs Open Rail-M 许可,仅对研究、个人使用以及融资或营收低于 500 万美元的初创公司免费,超出此范围则需要购买付费许可。
哪些 LLM 服务商可以提升准确率?添加 --usellm 参数后,marker 可以调用 Gemini、Claude、OpenAI 兼容接口、Azure、Vertex、OpenRouter 或 Ollama 上的模型,用于合并跨页表格、修复行内公式以及提取表单字段值。
除了 PDF,它还能转换哪些文件格式?除 PDF 外,它还支持图片、PPTX、DOCX、XLSX、HTML 和 EPUB 文件,但非 PDF 格式需要安装额外的依赖。
与其他 PDF 工具相比,Marker 的准确率如何?在包含 1,403 个 PDF 的 olmocr-bench 基准测试中,均衡模式的综合得分为 76.0%,在原生数字 PDF 上得分为 83.5%,优于 MinerU 和 docling,并与大得多的视觉语言模型相差不大。
我能只提取文档中的表格吗?可以。TableConverter 流程只检测并转换表格,通过命令行或 Python API 输出为 HTML 块(或带页面边界框的 JSON)。
Creator
datalab-to
Size
20.5 MB
Stars
40.5K
Age
2y
Commits · 90 Days