SuperAPI AI Directory

olmocr

A toolkit for training language models to work with PDF documents in the wild. Online demo: https://olmocr.allenai.org/

Open website

About this tool

Purpose

olmOCR is a toolkit for linearizing and converting PDFs and other image-based document formats (PNG, JPEG) into clean, readable plain text, primarily serving LLM dataset construction and model training scenarios. An online demo is also officially provided:https://olmocr.allenai.org/。

Main Capabilities

  • Convert PDF, PNG, and JPEG documents into clean Markdown format.
  • Supports formulas, tables, handwriting, and complex formatting.
  • Automatically removes headers and footers.
  • Converts to text in natural reading order even when charts, multi-column layouts, and embedded content are present.
  • The official claim is high conversion efficiency, with a cost of less than $200 per million pages (based on a 7B-parameter VLM, so a GPU is required).
  • Provides the olmOCR-Bench benchmark suite, covering more than 7,000 test cases across 1,400 documents, for measuring OCR system performance.

Version Updates

  • October 21, 2025 v0.4.0: New model released, using synthetic data to improve the olmOCR-bench score by about 4 points, and introducing RL training.
  • August 13, 2025 v0.3.0: New model released, fixing automatic rotation detection and hallucination issues on blank documents.
  • July 24, 2025 v0.2.1: The new model improves by 3 points on olmOCR-Bench, default FP8 runs significantly faster, and the number of retries required per document is greatly reduced.
  • July 23, 2025 v0.2.0: Cleaned-up trainer code, making it easier to train olmOCR models yourself.
  • June 17, 2025 v0.1.75: The inference pipeline switched from sglang to vllm, and the Docker image was updated to CUDA 12.8.
  • May 23, 2025 v0.1.70: Official Docker support and images are available.
  • May 19, 2025 v0.1.68: olmOCR-Bench released, with a score of 77.4; prompt-related defects fixed, and pipeline performance improved by 2 points.
  • March 17, 2025 v0.1.60: Performance improved by improving sampling temperature selection.
  • February 25, 2025 v0.1.58: First public release and demo.

Usage

Environment Preparation

Requires installing poppler-utils and additional fonts for rendering PDF images.

Install dependencies (Ubuntu/Debian): the source material does not provide the specific apt command content.

It is recommended to create a clean conda environment to install olmocr, because its runtimedependencies are difficult to install into an existing Python environment.

Installation Options

  • Option 1: Remote inference (lightweight). If you plan to use a remote vLLM server with the --server flag, install the base package, which avoids installing heavy GPU dependencies such as PyTorch (about 2GB+).
  • Option 2: Local GPU inference. Requires a recent NVIDIA GPU (tested on RTX 4090, L40S, A100, H100), at least 12GB of VRAM, and 30GB of available disk space.
  • Option 3: Beaker cluster execution. Used to submit jobs to a Beaker cluster via the --beaker flag.
  • Option 4: Benchmark suite. Used to run the olmOCR benchmark tests.
  • Multiple options can be combined for installation.

Troubleshooting

If a too many open files error occurs, you need to update ulimit.

Conversion Examples

  • For a quick test, you can use the web demo.
  • The specific commands for single PDF conversion (local GPU), image file conversion, multiple PDF conversion, etc. are not provided in full in the source material.
  • Parameter descriptions when using a remote inference server:
    • --server: defines an OpenAI-compatible endpoint, for example https://api.deepinfra.com/v1/openai
    • --api_key: API key, passed via the Authorization Bearer HTTP header
    • --max_concurrent_requests: The maximum number of concurrent requests sent to the inference provider
    • --workers: The maximum number of page groups processed concurrently; can be set to 1 to complete one group before continuing
    • --pages_per_group: Number of pages per group; when the external provider has a low concurrency limit, it is recommended to use a smaller value
    • --model: Model identifier, for example allenai/olmOCR-2-7B-1025; names differ across providers, and for local running you can use olmocr.
  • When using the --markdown flag, results will be stored as Markdown files in ./localworkspace/markdown/. You can also use python -m olmocr.pipeline instead of olmocr. The workspace folder ./localworkspace/ will contain both Dolma files and Markdown files (if --markdown is used).
  • If you already have a vLLM server running elsewhere (or an inference platform implementing the OpenAI API), you can point olmOCR to that server instead of starting a local instance. The model name served in vLLM must match the value passed to --model. It has been officially tested that olmOCR-2-7B-1025-FP8 works properly on some external model providers.

Multi-node/Cluster Usage

If you need to convert millions of PDFs using multiple parallel nodes, olmOCR supports reading PDFs from AWS S3 and coordinating work using an AWS S3 output bucket. Starting the first worker node sets up a simple work queue and begins conversion; subsequent worker nodes automatically fetch items from the same workspace queue. Internally at Ai2, if you need to efficiently linearize millions of PDFs via beaker, you can install Beaker support, then use the --beaker flag to prepare the workspace locally and start N GPU worker nodes in the cluster.

Docker

Pull the Docker image (large, includes the model, about 30GB). For advanced users who want to manage model downloads themselves, a base image without the model is also provided. You can process a single PDF in the current directory, process multiple PDFs, or run the container interactively for exploration and debugging. See the Docker Hub repository for more information.

Full Documentation

The specific command reference for all available options is not provided.

Reusable Code Components

  • Prompt strategy for obtaining high-quality natural text parsing using ChatGPT 4o: buildsilver.py
  • Language-based basic filtering and SEO spam removal: filter.py
  • SFT fine-tuning code for Qwen2.5-VL: train.py
  • GRPO RL trainer: grpo_train.py
  • Synthetic data generation: mine_html_templates.py
  • Processing millions of PDFs with a fine-tuned model via VLLM: pipeline.py
  • Viewing Dolma documents created from PDFs: dolmaviewer.py

Applicable Scenarios and Limitations

Suitable for scenarios that require converting large numbers of PDF or image documents into plain text/Markdown to build LLM datasets or train models, especially complex documents containing formulas, tables, handwriting, and multi-column layouts. Based on a 7B-parameter VLM, it requires a GPU; local inference requires at least 12GB of VRAM and 30GB of disk space; large-scale processing can leverage multiple nodes and AWS S3; remote inference services can also be used to lower local hardware requirements.

Development and License

olmOCR is developed and maintained by the AllenNLP team, under the Allen Institute for Artificial Intelligence (AI2). AI2 is a nonprofit institution whose mission is to benefit humanity through high-impact AI research and engineering. olmOCR is licensed under Apache 2.0.