---
title: "Top 7 Open Source OCR Models for Document Processing"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/top-7-open-source-ocr-models
---

![Blog post image for Top 7 Open Source OCR Models for Document Processing - The best open source OCR models for converting documents, images, and PDFs to text. Compare olmOCR, PaddleOCR, OCRFlux, and more, with performance benchmarks and implementation examples.](/_astro/hero.DIJ2knuO_ZwxxbC.webp)

[Home](/)›[Codesnippets](/codesnippets)›[All Categories](/codesnippets/categories)›[Ai ml](/codesnippets/categories/ai-ml)

Codesnippets

[Ai ml](/codesnippets/categories/ai-ml)[Computer vision](/codesnippets/categories/computer-vision)[Document processing](/codesnippets/categories/document-processing)[Python](/codesnippets/python)

# Top 7 Open Source OCR Models for Document Processing

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)Published: 09 Jan 202604 Mins read07 Mins listen

[Markdown for AI(opens in a new tab)](/post/top-7-open-source-ocr-models/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

TL;DR

The best open source OCR models for converting documents, images, and PDFs to text. Compare olmOCR, PaddleOCR, OCRFlux, and more, with performance benchmarks and implementation examples.

Series

[AI & LLM Engineering](/series/ai--llm-engineering)1/1

All posts in this series (1)

Code Snippets1

1.  [Top 7 Open Source OCR Models for Document ProcessingYou are here](/codesnippets/post/top-7-open-source-ocr-models)

### Top 7 Open Source OCR Models for Document Processing

Contents

[What modern OCR models do](#what-modern-ocr-models-do)[Beyond basic text extraction](#beyond-basic-text-extraction)[Local processing](#local-processing)[olmOCR-2-7B-1025](#olmocr-2-7b-1025)[High-performance document OCR](#high-performance-document-ocr)[Key features](#key-features)[PaddleOCR VL](#paddleocr-vl)[Efficient multilingual OCR](#efficient-multilingual-ocr)[Key features](#key-features)[OCRFlux-3B](#ocrflux-3b)[Multimodal document conversion](#multimodal-document-conversion)[Key features](#key-features)[MiniCPM-V 4.5](#minicpm-v-45)[Mobile-optimized OCR](#mobile-optimized-ocr)[Key features](#key-features)[InternVL2.5-4B](#internvl25-4b)[Compact multimodal understanding](#compact-multimodal-understanding)[Key features](#key-features)[Granite Vision 3.3 2b](#granite-vision-33-2b)[Document understanding specialist](#document-understanding-specialist)[Key features](#key-features)[TrOCR Large (SROIE Fine-tuned)](#trocr-large-sroie-fine-tuned)[Specialized text recognition](#specialized-text-recognition)[Key features](#key-features)[Choosing the right model](#choosing-the-right-model)[Use case considerations](#use-case-considerations)[Performance optimization](#performance-optimization)[Implementation best practices](#implementation-best-practices)[Preprocessing](#preprocessing)[Error handling](#error-handling)[Output formatting](#output-formatting)

**AI Tool**

Turn your documents into accurate digital copies with these open source OCR models. Instead of fighting messy text extraction, you get clean markdown from PDFs, images, and scanned documents.

## [What modern OCR models do](#what-modern-ocr-models-do)

### [Beyond basic text extraction](#beyond-basic-text-extraction)

These models do more than read text. They recognize document structure, tables, diagrams, math equations, and multiple languages, and turn all of it into well-formatted markdown.

### [Local processing](#local-processing)

Run these models on your own machine without sending sensitive documents to cloud services. You keep control over your data and get accuracy close to enterprise services.

## [olmOCR-2-7B-1025](#olmocr-2-7b-1025)

### [High-performance document OCR](#high-performance-document-ocr)

Allen Institute’s flagship OCR model. It is fine-tuned from Qwen2.5-VL-7B-Instruct using GRPO reinforcement learning and scores 82.4 on the olmOCR-bench evaluation.

```
1from transformers import AutoTokenizer, AutoModelForCausalLM2import torch3
4# Load the model5model_id = "allenai/olmOCR-2-7B-1025"6tokenizer = AutoTokenizer.from_pretrained(model_id)7model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")8
9# Process document10messages = [11    {"role": "user", "content": "Convert this document to markdown"},12    {"role": "user", "content": f"[IMAGE_PLACEHOLDER]"}13]14
15inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)16outputs = model.generate(inputs, max_new_tokens=4096)17result = tokenizer.decode(outputs[0], skip_special_tokens=True)
```

### [Key features](#key-features)

-   **Mathematical equations**: Handles complex math expressions
-   **Table recognition**: Keeps table structure and formatting intact
-   **Layout understanding**: Manages multi-column documents and complex layouts
-   **Large-scale processing**: Built for processing millions of documents
-   **Automated retries**: Includes error handling and automatic rotation correction

## [PaddleOCR VL](#paddleocr-vl)

### [Efficient multilingual OCR](#efficient-multilingual-ocr)

An ultra-compact vision-language model. It integrates the NaViT visual encoder with the ERNIE language model and supports 109 languages with minimal resource usage.

```
1import paddle2from paddlenlp import Taskflow3
4# Initialize OCR pipeline5ocr = Taskflow("document_parsing")6
7# Process document8result = ocr({"doc": "path/to/document.pdf"})9print(result)
```

### [Key features](#key-features-1)

-   **109 languages**: Chinese, English, Japanese, Arabic, Hindi, Thai
-   **Complex elements**: Tables, formulas, charts recognition
-   **High accuracy**: Strong performance on OmniDocBench
-   **Fast inference**: Optimized for real-world deployment
-   **Compact size**: Efficient use of memory and compute

## [OCRFlux-3B](#ocrflux-3b)

### [Multimodal document conversion](#multimodal-document-conversion)

A preview release from ChatDOC, fine-tuned from Qwen2.5-VL-3B-Instruct for clean markdown output from PDFs and images.

```
1from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor2from qwen_vl_utils import process_vision_info3
4# Load model5model = Qwen2_5_VLForConditionalGeneration.from_pretrained(6    "ChatDOC/OCRFlux-3B",7    torch_dtype=torch.bfloat16,8    device_map="auto"9)10processor = AutoProcessor.from_pretrained("ChatDOC/OCRFlux-3B")11
12# Process image13messages = [14    {15        "role": "user",16        "content": [17            {"type": "image", "image": "path/to/image.jpg"},18            {"type": "text", "text": "Convert to markdown"}19        ]20    }21]22
23text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)24image_inputs, video_inputs = process_vision_info(messages)25inputs = processor(text=[text], images=image_inputs, videos=video_inputs, return_tensors="pt").to(model.device)26
27generated_ids = model.generate(**inputs, max_new_tokens=4096)28generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
```

### [Key features](#key-features-2)

-   **Clean markdown**: Structured output with proper formatting
-   **Cross-page tables**: Merges table data across multiple pages
-   **Consumer hardware**: Runs on GTX 3090 and similar GPUs
-   **Scalable deployment**: vLLM inference support
-   **High accuracy**: Strong parsing quality

## [MiniCPM-V 4.5](#minicpm-v-45)

### [Mobile-optimized OCR](#mobile-optimized-ocr)

The latest model in the MiniCPM-V series. Built on Qwen3-8B and SigLIP2-400M, it handles text recognition in images, documents, and video.

```
1from transformers import AutoModel, AutoTokenizer2import torch3
4# Load model5model = AutoModel.from_pretrained('openbmb/MiniCPM-V-4.5', trust_remote_code=True)6tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V-4.5', trust_remote_code=True)7model.eval().cuda()8
9# Process image10image = Image.open('path/to/image.jpg').convert('RGB')11question = 'Convert this document to text'12
13msgs = [{'role': 'user', 'content': [image, question]}]14result = model.chat(msgs=msgs, tokenizer=tokenizer, sampling=True, temperature=0.7)15print(result)
```

### [Key features](#key-features-3)

-   **Mobile deployment**: Optimized for edge devices
-   **Multi-image processing**: Handles multiple images simultaneously
-   **Video OCR**: Text recognition in video content
-   **Benchmark results**: Leading performance across evaluations
-   **Practical efficiency**: Everyday application ready

## [InternVL2.5-4B](#internvl25-4b)

### [Compact multimodal understanding](#compact-multimodal-understanding)

An efficient vision-language model. It combines the InternViT vision encoder with the Qwen2.5 language model for OCR and document understanding.

```
1import torch2from transformers import AutoTokenizer, AutoModel3
4# Load model5model = AutoModel.from_pretrained(6    'OpenGVLab/InternVL2_5-4B',7    torch_dtype=torch.bfloat16,8    low_cpu_mem_usage=True,9    trust_remote_code=True10).eval().cuda()11
12tokenizer = AutoTokenizer.from_pretrained(13    'OpenGVLab/InternVL2_5-4B',14    trust_remote_code=True15)16
17# Process image18image = Image.open('path/to/image.jpg').convert('RGB')19question = 'Extract all text from this image'20
21response = model.chat(tokenizer, image, question)22print(response)
```

### [Key features](#key-features-4)

-   **Dynamic resolution**: 448x448 pixel tile processing
-   **Resource efficient**: Suitable for constrained environments
-   **Text recognition**: Strong OCR performance
-   **Reasoning tasks**: Advanced multimodal understanding
-   **Compact architecture**: 4 billion parameters total

## [Granite Vision 3.3 2b](#granite-vision-33-2b)

### [Document understanding specialist](#document-understanding-specialist)

IBM’s vision-language model, built on Granite 3.1-2b-instruct with a SigLIP2 vision encoder for automated content extraction.

```
1from transformers import AutoProcessor, AutoModelForVision2Seq2import torch3
4# Load model5processor = AutoProcessor.from_pretrained("ibm-granite/granite-vision-3.3-2b")6model = AutoModelForVision2Seq.from_pretrained("ibm-granite/granite-vision-3.3-2b", device_map="auto")7
8# Process image9image = Image.open("path/to/document.png").convert("RGB")10text_prompt = "<|start_of_text|>"11
12inputs = processor(text=text_prompt, images=image, return_tensors="pt").to(model.device)13generated_ids = model.generate(**inputs, max_new_tokens=500)14generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
```

### [Key features](#key-features-5)

-   **Table extraction**: Automated table content extraction
-   **Chart recognition**: Infographics and plot understanding
-   **Multi-page support**: Handles multi-page documents
-   **Image segmentation**: Advanced visual processing
-   **Safety**: Improved security features

## [TrOCR Large (SROIE Fine-tuned)](#trocr-large-sroie-fine-tuned)

### [Specialized text recognition](#specialized-text-recognition)

A transformer-based OCR model. Its encoder-decoder architecture combines the BEiT image transformer with the RoBERTa text transformer.

```
1from transformers import TrOCRProcessor, VisionEncoderDecoderModel2import torch3
4# Load model5processor = TrOCRProcessor.from_pretrained('microsoft/trocr-large-printed')6model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-printed')7
8# Process image9image = Image.open('path/to/image.jpg').convert('RGB')10pixel_values = processor(images=image, return_tensors="pt").pixel_values11generated_ids = model.generate(pixel_values)12
13generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]14print(generated_text)
```

### [Key features](#key-features-6)

-   **Single-line text**: Optimized for printed text recognition
-   **High accuracy**: Strong performance on benchmarks
-   **Transformer architecture**: Modern deep learning approach
-   **Pre-trained models**: Uses large-scale training data
-   **Sequence processing**: Handles text as sequential tokens

## [Choosing the right model](#choosing-the-right-model)

### [Use case considerations](#use-case-considerations)

-   **High accuracy**: olmOCR-2-7B-1025, OCRFlux-3B
-   **Efficiency**: PaddleOCR VL, InternVL2.5-4B
-   **Multilingual**: PaddleOCR VL, MiniCPM-V 4.5
-   **Mobile/Edge**: MiniCPM-V 4.5, InternVL2.5-4B
-   **Specialized**: TrOCR (printed text), Granite Vision (documents)

### [Performance optimization](#performance-optimization)

Hardware is usually the limiting factor.

-   **GPU memory**: Match model size to available VRAM
-   **Batch processing**: Use models supporting multiple images
-   **Quantization**: Consider quantized versions for efficiency
-   **Local deployment**: All models support local inference

## [Implementation best practices](#implementation-best-practices)

### [Preprocessing](#preprocessing)

Resize oversized images before inference so they fit the model’s input budget.

```
1# Image preprocessing2def preprocess_image(image_path):3    image = Image.open(image_path).convert('RGB')4    # Resize if needed5    if max(image.size) > 2240:6        image = image.resize((2240, 2240), Image.Resampling.LANCZOS)7    return image
```

### [Error handling](#error-handling)

Catch failures per document so one bad file does not stop a batch.

```
1def safe_ocr_processing(model, image_path):2    try:3        image = preprocess_image(image_path)4        result = model.process(image)5        return result6    except Exception as e:7        logging.error(f"OCR processing failed: {e}")8        return None
```

### [Output formatting](#output-formatting)

Wrap the extracted text with metadata so downstream code knows which model produced it.

```
1def format_ocr_output(raw_text, confidence_scores=None):2    """Format OCR output with metadata"""3    return {4        "text": raw_text,5        "confidence": confidence_scores,6        "timestamp": datetime.now().isoformat(),7        "model_version": "olmOCR-2-7B-1025"8    }
```

These open source OCR models cover most document processing needs today. Choose based on what your workload demands: accuracy, speed, language coverage, or the hardware you have available.

Was this useful?

## Tags

[#OCR](/codesnippets/tags/ocr)[#Computer Vision](/codesnippets/tags/computer-vision)[#Document Processing](/codesnippets/tags/document-processing)[#Open Source](/codesnippets/tags/open-source)[#AI Models](/codesnippets/tags/ai-models)[#Python](/codesnippets/tags/python)[#Machine Learning](/codesnippets/tags/machine-learning)[#Text Recognition](/codesnippets/tags/text-recognition)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing&url=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models&title=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing&summary=The%20best%20open%20source%20OCR%20models%20for%20converting%20documents%2C%20images%2C%20and%20PDFs%20to%20text.%20Compare%20olmOCR%2C%20PaddleOCR%2C%20OCRFlux%2C%20and%20more%2C%20with%20performance%20benchmarks%20and%20implementation%20examples.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing%20https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models&text=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models&title=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models&t=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models&media=&description=The%20best%20open%20source%20OCR%20models%20for%20converting%20documents%2C%20images%2C%20and%20PDFs%20to%20text.%20Compare%20olmOCR%2C%20PaddleOCR%2C%20OCRFlux%2C%20and%20more%2C%20with%20performance%20benchmarks%20and%20implementation%20examples. "Share on Pinterest")[Email](<mailto:?subject=Top%207%20Open%20Source%20OCR%20Models%20for%20Document%20Processing&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fcodesnippets%2Fpost%2Ftop-7-open-source-ocr-models>)

## Comments

## You might also enjoy

More posts on similar topics

[![Redis Caching Patterns: Cache-Aside, Write-Through & Cache Invalidation](/_astro/hero.Ck2oLF89_ZPiYlL.webp)](/codesnippets/post/redis-caching-patterns-architecture)

## [Redis Caching Patterns: Cache-Aside, Write-Through & Cache Invalidation](/codesnippets/post/redis-caching-patterns-architecture)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Backend](/codesnippets/categories/backend)
-   [Performance](/codesnippets/categories/performance)

Need to scale your backend without throwing money at servers? Start with Redis caching patterns. Most databases can handle hundreds of queries per second, but thousands? Your app slows to a crawl

[#Redis](/codesnippets/tags/redis)[#Caching](/codesnippets/tags/caching)[#Performance](/codesnippets/tags/performance)+6 tags

[read more](/codesnippets/post/redis-caching-patterns-architecture)

[![AWS EC2 Instance Management with Boto3: Start, Stop, and Query Instances](/_astro/hero.PnHlvJay_ZkFqWG.webp)](/codesnippets/post/aws-ec2-instance-management-boto3-python)

## [AWS EC2 Instance Management with Boto3: Start, Stop, and Query Instances](/codesnippets/post/aws-ec2-instance-management-boto3-python)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Cloud](/codesnippets/categories/cloud)
-   [Aws](/codesnippets/categories/aws)
-   [Devops](/codesnippets/categories/devops)
-   [Automation](/codesnippets/categories/automation)

If you've ever spent 20 minutes clicking through the AWS Console just to stop a handful of dev instances, you already know the pain. It's tedious, it doesn't scale, and one wrong click can ruin your a

[#AWS](/codesnippets/tags/aws)[#EC2](/codesnippets/tags/ec2)[#Boto3](/codesnippets/tags/boto3)+6 tags

[read more](/codesnippets/post/aws-ec2-instance-management-boto3-python)

[![Essential Bash Variables for Every Script](/_astro/hero.B4bDowyY_YQpD7.webp)](/codesnippets/post/essential-bash-variables)

## [Essential Bash Variables for Every Script](/codesnippets/post/essential-bash-variables)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Shell scripting](/codesnippets/categories/shell-scripting)
-   [Devops](/codesnippets/categories/devops)

Overview Quick Tip You know what's worse than writing scripts? Writing scripts that break every time you move them to a different machine. Built-in Bash variables fix that. The problem wi

[#Bash](/codesnippets/tags/bash)[#Shell Scripting](/codesnippets/tags/shell-scripting)[#Linux](/codesnippets/tags/linux)+4 tags

[read more](/codesnippets/post/essential-bash-variables)

[![Per-App Shell History for Bash](/_astro/hero.Da_6jPH6_Z1EorRD.webp)](/codesnippets/post/bash-per-app-history)

## [Per-App Shell History for Bash](/codesnippets/post/bash-per-app-history)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Shell scripting](/codesnippets/categories/shell-scripting)
-   [Productivity](/codesnippets/categories/productivity)

Organize your Bash history per terminal app. Ever jumped between iTerm2, Ghostty, and VS Code's terminal only to have your command history get all mixed up? This Bash snippet keeps things clean b

[#Bash](/codesnippets/tags/bash)[#Shell Scripting](/codesnippets/tags/shell-scripting)[#Productivity](/codesnippets/tags/productivity)+3 tags

[read more](/codesnippets/post/bash-per-app-history)

[![Per-App Shell History for Zsh](/_astro/hero.DRenzVy__1xwzSL.webp)](/codesnippets/post/zsh-per-app-history)

## [Per-App Shell History for Zsh](/codesnippets/post/zsh-per-app-history)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Shell scripting](/codesnippets/categories/shell-scripting)
-   [Productivity](/codesnippets/categories/productivity)

Organize your shell history per terminal app. Ever jumped between iTerm2, Ghostty, and VS Code's terminal only to have your command history get all mixed up? This Zsh snippet keeps things clean b

[#Zsh](/codesnippets/tags/zsh)[#Shell Scripting](/codesnippets/tags/shell-scripting)[#Productivity](/codesnippets/tags/productivity)+3 tags

[read more](/codesnippets/post/zsh-per-app-history)

[![Optimizing your python code with \_\_slots\_\_?](/_astro/hero.DP_vYsHU_gYDXn.webp)](/codesnippets/post/python-slots-optimization)

## [Optimizing your python code with \_\_slots\_\_?](/codesnippets/post/python-slots-optimization)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Python](/codesnippets/categories/python)
-   [Productivity](/codesnippets/categories/productivity)

Memory optimization with slots Understanding the problem Optimizing data models in big data workflows with slots In big data and MLOps workflows, you often work with massive

[#Python](/codesnippets/tags/python)[#MemoryOptimization](/codesnippets/tags/memoryoptimization)[#DataScience](/codesnippets/tags/datascience)+4 tags

[read more](/codesnippets/post/python-slots-optimization)

6 related posts
