Aller au contenu
ModelPrรฉsentรฉExterne
Tรฉlรฉcharger

Unlimited OCR MLX

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

TypeText modelVersionmodelBClasse

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

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.

Sources

1 source
Hugging FacePrincipalVersion 267d7adcbcd3730fdffb1eefd70ef6f486fbfc92
huggingface.co/LoJexLLM/Unlimited-OCR-MLX/tree/267d7adcbcd3730fdffb1eefd70ef6f486fbfc92

Vรฉrifiรฉ 23 oct.

Artefacts du modรจle

1 artefact

model.safetensors

safetensors ยท 6,21 GB ยท SHA-256 7aefa71cd210โ€ฆ1a08 ยท Hugging Face

Tรฉlรฉcharger

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.** [![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