Unlimited OCR MLX
> π Unlimited-length document OCR model accelerated by Apple MLX framework, deeply optimized for Apple Silicon.
Fonte do modelo
- Tipo
- Text model
- Tamanho do arquivo
- 6,21 GB
- VersΓ£o
- vmodel
- Atualizado
- 23 de out. de 2026
- Downloads
- 699
- Fonte
- Hugging Face
DescriΓ§Γ£o da fonte
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.
Fontes
1 fonte
Fontes
1 fonteVerificado 23 de out.
Artefatos de modelo
1 artefato
Artefatos de modelo
1 artefatoTrechos de fonte
3 trechos
Trechos de fonte
3 trechos--- 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
