Ir para o conteΓΊdo
ModelListadosExterno
Baixar

Unlimited OCR MLX

> πŸš€ Unlimited-length document OCR model accelerated by Apple MLX framework, deeply optimized for Apple Silicon.

TipoText modelVersΓ£omodelBnota

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

FeatureDescription
πŸ“„ Document ParsingSupports full-page OCR for PDFs and single/multi-page images
🌍 Multilingual RecognitionPrecise recognition of Chinese, English, and other multilingual text
πŸ“Š Table ExtractionAutomatically recognizes and structures table content
🎯 Layout AnalysisPreserves original layout structure (paragraphs, headings, lists, etc.)
πŸ”„ Unlimited LengthDynamic 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

ParameterValue
Total Parameters3.34B
Vision EncoderSAM-ViT-B (12 layers) + CLIP-L (24 layers)
Language ModelDeepSeek-V2 MoE (12 layers)
Number of Experts64 routed experts + 2 shared experts
Attention Heads10 (head_dim=128)
Hidden Dimension1280
Vocabulary Size129,280
Max Length32,768 tokens
FrameworkApple MLX
PrecisionFP16 (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):

ScenarioMLX (FP16)PyTorch MPS (BF16)Speedup
Vision Encoding (1024Γ—1024)~0.5s~1.2s2.4Γ—
Text Generation (tokens/s)~18 t/s~8 t/s2.3Γ—
Single Page A4 Document~2.0s~4.8s2.4Γ—
Multi-page PDF (10 pages)~15s~38s2.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

πŸ“„ 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
Hugging FacePrimΓ‘rioVersΓ£o 267d7adcbcd3730fdffb1eefd70ef6f486fbfc92
huggingface.co/LoJexLLM/Unlimited-OCR-MLX/tree/267d7adcbcd3730fdffb1eefd70ef6f486fbfc92

Verificado 23 de out.

Artefatos de modelo

1 artefato

model.safetensors

safetensors Β· 6,21 GB Β· SHA-256 7aefa71cd210…1a08 Β· Hugging Face

Baixar

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.** [![MLX](https://img.shields.io/badge/Framework-MLX-blue)](https://github.com/ml-explore/mlx) [![ModelScope](https://img.shields.io/badge/ModelScope-Unlimited--OCR--MLX-orange)](https://www.modelscope.cn/models/PaddlePaddle/Unlimited-OCR) [![License](https://img.shields.io/badge/License-MIT-green)](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