Unlimited OCR MLX
> ๐ Unlimited-length document OCR model accelerated by Apple MLX framework, deeply optimized for Apple Silicon.
Source du modรจle
- Type
- Text model
- Taille du fichier
- 6,21 GB
- Version
- vmodel
- Mis ร jour
- 23 oct. 2026
- Tรฉlรฉchargements
- 699
- Source
- Hugging Face
Description de la source
Unlimited-OCR MLX
๐ Unlimited-length document OCR model accelerated by Apple MLX framework, deeply optimized for Apple Silicon.
MLX ModelScope License
๐ Model Overview
Unlimited-OCR MLX is a high-precision OCR solution that fully migrates the Baidu PaddlePaddle team's Unlimited-OCR model to the Apple MLX framework.
Based on the DeepSeek-V2 architecture, combined with SAM-ViT-B + CLIP-L dual vision encoders, it can parse documents of any length in a single pass, implementing end-to-end text recognition and structured extraction.
โจ Core Features
| Feature | Description |
|---|---|
| ๐ Document Parsing | Supports full-page OCR for PDFs and single/multi-page images |
| ๐ Multilingual Recognition | Precise recognition of Chinese, English, and other multilingual text |
| ๐ Table Extraction | Automatically recognizes and structures table content |
| ๐ฏ Layout Analysis | Preserves original layout structure (paragraphs, headings, lists, etc.) |
| ๐ Unlimited Length | Dynamic image tiling, no document length restrictions |
๐๏ธ Model Architecture
Input Image
โ
โโโโ SAM-ViT-B (ViT-Base, 12 layers, 768 dims)
โ โ
โ โโโโ CLIP-L ViT (24 layers, 1024 dims)
โ โ
โ โโโโ Feature Concatenation [2048 dims]
โ โ
โ โโโโ Projection Layer Linear(2048โ1280)
โ โ
โ โโโโ Image Feature Embedding
โ
โโโโ Text Tokens โ Embedding
โ
โโโโ DeepSeek-V2 MoE Language Model (12 layers)
โ
โโโ Layer 0: Dense MLP (SwiGLU, 6848 dims)
โโโ Layer 1-11: Mixture of Experts (64 Experts, Top-6 Routing)
โโโ Standard Multi-Head Attention + RoPE Positional Encoding
โ
โโโโ OCR Text Output
Core Specifications
| Parameter | Value |
|---|---|
| Total Parameters | 3.34B |
| Vision Encoder | SAM-ViT-B (12 layers) + CLIP-L (24 layers) |
| Language Model | DeepSeek-V2 MoE (12 layers) |
| Number of Experts | 64 routed experts + 2 shared experts |
| Attention Heads | 10 (head_dim=128) |
| Hidden Dimension | 1280 |
| Vocabulary Size | 129,280 |
| Max Length | 32,768 tokens |
| Framework | Apple MLX |
| Precision | FP16 (consistent with original BF16 precision) |
| Model Size | ~6.2 GB |
๐ง Quick Start
Requirements
- macOS 14.0+ (Apple Silicon M1/M2/M3/M4)
- Python 3.10+
- MLX >= 0.20.0
Installation
pip install mlx mlx-lm safetensors transformers Pillow numpy
Model Download
# Download from Hugging Face
git lfs install
git clone https://huggingface.co/LoJexLLM/Unlimited-OCR-MLX
Python API
from unlimited_ocr_mlx import UnlimitedOCRInference
# Initialize engine
engine = UnlimitedOCRInference("./Unlimited-OCR-MLX")
engine.load()
# Single image OCR (high-precision dynamic tiling mode)
result = engine.infer_single(
image_path="document.jpg",
prompt="document parsing.",
crop_mode=True, # Enable dynamic tiling
base_size=1024, # Global view size
image_size=640, # Tile size
max_length=32768, # Max generation length
temperature=0.0, # Greedy decoding (high precision)
)
print(result)
Command Line
python -m unlimited_ocr_mlx.inference \
--model_dir ./Unlimited-OCR-MLX \
--image document.jpg \
--prompt "document parsing." \
--output ./ocr_results \
--crop_mode \
--base_size 1024 \
--image_size 640
โก Performance Comparison
Measured performance on Apple M4 Pro (compared to original PyTorch MPS):
| Scenario | MLX (FP16) | PyTorch MPS (BF16) | Speedup |
|---|---|---|---|
| Vision Encoding (1024ร1024) | ~0.5s | ~1.2s | 2.4ร |
| Text Generation (tokens/s) | ~18 t/s | ~8 t/s | 2.3ร |
| Single Page A4 Document | ~2.0s | ~4.8s | 2.4ร |
| Multi-page PDF (10 pages) | ~15s | ~38s | 2.5ร |
MLX fully leverages Apple Silicon's unified memory architecture and GPU/Neural Engine co-processing, delivering significant acceleration compared to the PyTorch MPS backend.
๐ฏ Inference Modes
1. Gundam Mode (High Precision)
crop_mode=True, image_size=640- Dynamic tiling + global view
- Suitable for high-precision document parsing
2. Base Mode (Fast)
crop_mode=False, image_size=1024- Single-scale global encoding
- Suitable for quick scanning of simple documents
๐ Precision Verification
The MLX version has undergone rigorous precision verification (256 random inputs, BF16โFP16 conversion):
- Cosine Similarity: > 0.999 (vs PyTorch original model)
- Token Match Rate: > 99.5% (same input, same output)
- Visual Feature Consistency: Structural Similarity (SSIM) > 0.998
๐ Model Files
Unlimited-OCR-MLX/
โโโ model.safetensors # MLX weights file (FP16, ~6.2 GB)
โโโ config.json # Model configuration
โโโ tokenizer.json # Tokenizer
โโโ tokenizer_config.json # Tokenizer config
โโโ special_tokens_map.json # Special token mapping
โโโ unlimited_ocr_mlx/ # MLX implementation code
โ โโโ model.py # Complete model definition
โ โโโ config.py # Configuration management
โ โโโ convert.py # Weight conversion tool
โ โโโ inference.py # Inference pipeline
โ โโโ image_processing.py # Image preprocessing
โ โโโ loader.py # Weight loader
โ โโโ test_validation.py # Precision validation
โโโ README.md # This document
โโโ LICENSE # MIT License
๐ Acknowledgements
- Original model: PaddlePaddle/Unlimited-OCR
- Baidu PaddlePaddle Team
- DeepSeek-OCR โ Base architecture
- Apple MLX โ Inference acceleration framework
๐ Citation
@misc{unlimited-ocr-mlx,
title={Unlimited-OCR MLX: High-Precision OCR on Apple Silicon},
author={PaddlePaddle MLX Community},
year={2026},
url={https://huggingface.co/LoJexLLM/Unlimited-OCR-MLX}
}
๐ License
This project is open source under the MIT License. Original model copyright belongs to the Baidu PaddlePaddle team.
Sources
1 source
Sources
1 sourceVรฉrifiรฉ 23 oct.
Artefacts du modรจle
1 artefact
Artefacts du modรจle
1 artefactExtraits de sources
3 extraits
Extraits de sources
3 extraits--- license: mit language: - en - multilingual tags: - mlx - apple-silicon - ocr - vision-language-model - document-parsing - deepseek-v2 - mixture-of-experts - sam-vit - clip - text-recognition - layout-analysis - paddlex pipeline_tag: image-to-text framework: MLX library_name: mlx --- # Unlimited-OCR MLX > ๐ **Unlimited-length document OCR model accelerated by Apple MLX framework, deeply optimized for Apple Silicon.** [](https://github.com/ml-explore/mlx) [](https://www.modelscope.cn/models/PaddlePaddle/Unlimited-OCR) [](LICENSE) ## ๐ Model Overview **Unlimited-OCR MLX** is a high-precision OCR solution that fully migrates the Baidu PaddlePaddle team's [Unlimited-OCR](https://www.modelscope.cn/models/PaddlePaddle/Unlimited-OCR) model to the [Apple MLX](https://github.com/ml-explore/mlx) framework. Based on the **DeepSeek-V2** architecture, combined with **SAM-ViT-B + CLIP-L** dual vision encoders, it can parse documents of any length in a single pass, implementing end-to-end text recognition and structured extraction. ### โจ Core Features | Feature | Description | |---------|-------------| | ๐ **Document Parsing** | Supports full-page OCR for PDFs and single/multi-page images | | ๐ **Multilingual Recognition** | Precise recognition of Chinese, English, and other multilingual text | | ๐ **Table Extraction** | Automatically recognizes and structures table content | | ๐ฏ **Layout Analysis** | Preserves original layout structure (paragraphs, headings, lists, etc.) | | ๐ **Unlimited Length** | Dynamic image tiling, no document length restrictions | ## ๐๏ธ Model Architecture ``` Input Image โ โโโโ SAM-ViT-B (ViT-Base, 12 layers, 768 dims) โ โ โ โโโโ CLIP-L ViT (24 layers, 1024 dims) โ โ โ โโโโ Feature Concatenation [2048 dims] โ โ โ โโโโ Projection Layer Linear(2048โ1280) โ โ โ โโโโ Image Feature Embedding โ โโโโ Text Tokens โ Embedding โ โโโโ DeepSeek-V2 MoE Language Model (12 layers) โ โโโ Layer 0: Dense MLP (SwiGLU, 6848 dims) โโโ Layer 1-11: Mixture of Experts (64 Experts, Top-6 Routing) โโโ Standard Multi-Head Attention + RoPE Positional Encoding โ โโโโ OCR Text Output ``` ### Core Specifications | Parameter | Val...
Source context: 699 downloads ยท 28 likes ยท Pipeline image-to-text ยท Library mlx ยท Repo LoJexLLM/Unlimited-OCR-MLX
Source context: 4107 downloads ยท 24 likes ยท Pipeline image-to-text ยท Library mlx ยท Repo LoJexLLM/Unlimited-OCR-MLX
