OCR Language Support#
Docling's OCR subsystem supports multiple engines — RapidOCR, EasyOCR, Tesseract (CLI and tesserocr), macOS Vision, and others — each with its own language configuration model. Language is set on the engine-specific options class passed to PdfPipelineOptions.ocr_options .
RapidOCR: Bundled Model Sets#
RapidOCR is the most constrained engine: it bundles exactly three model sets — chinese, english, and latin — rather than supporting arbitrary language codes directly .
Language resolution happens in _resolve_rapidocr_language(), which maps user-supplied codes (ISO 639-1, ISO 639-2, and plain English names) to one of these three sets. Key rules:
en/eng/english→englishmodel setde,fr,es,it,pt,nl, and ~20 other European languages →latinmodel setzh/zho/chi/chinese→chinesemodel set- If no matching group is found, a warning is emitted and
chineseis used as the default — which silently drops inter-word spaces in Latin-script text - If multiple requested languages span different model sets (e.g.,
["en", "zh"]), only the first resolved set is used, with a warning - The
latinset subsumesenglish: requesting["en", "fr"]resolves tolatin, not a conflict
Language codes are normalized before lookup — "en-US" becomes "en", "fr_CH" becomes "fr" .
⚠️ Latin model not downloaded by default. The download_models() utility only downloads chinese and english by default. The latin set must be explicitly requested or pre-loaded . This gap caused a real regression when the docling-serve rocm72 image omitted the Latin model .
When artifacts_path is set, each model file resolves to <artifacts_path>/RapidOcr/<relative-path> . When no artifacts_path is set and paths are not pinned, language parameters are passed through RapidOCR's internal LangDet/LangRec typings API via _rapidocr_lang_type_params().
Key file: rapid_ocr_model.py
EasyOCR: Delegated Multi-Language Support#
EasyOCR supports 80+ languages and accepts a lang list of ISO 639-1 codes directly. The default is ["fr", "de", "es", "en"] . Language codes are passed verbatim to easyocr.Reader(lang_list=...) ; Docling does no pre-validation — EasyOCR itself handles language resolution and model downloads.
Models for default languages (english_g2, latin_g2) are pre-downloaded via EasyOcrModel.download_models(). For offline use, set artifacts_path; this disables auto-download and points the reader to <artifacts_path>/EasyOcr/ .
Key file: easyocr_model.py
Tesseract (CLI and tesserocr): ISO 639-2 Codes + Strict Validation#
Both Tesseract options use 3-letter ISO 639-2 codes (e.g., eng, fra, deu). The default for both is ["fra", "deu", "spa", "eng"] . Languages must have corresponding Tesseract data files installed in TESSDATA_PREFIX (or the path set via TesseractCliOcrOptions.path / TesseractOcrOptions.path).
Tesseract CLI validates language codes via _sanitize_lang(), which enforces the pattern ^[a-zA-Z0-9_/][a-zA-Z0-9_/+-]*$ before any subprocess call. This was added as a security hardening to prevent command injection . Multiple languages are joined with + and passed as a single -l flag. All subprocess calls use shell=False.
tesserocr (Python bindings) concatenates language codes with + and passes them directly to PyTessBaseAPI.
macOS Vision (OcrMacOptions)#
Uses locale codes in language-REGION format (e.g., en-US, fr-FR). Default: ["fr-FR", "de-DE", "es-ES", "en-US"] . Delegated entirely to Apple's Vision framework; no Docling-level language validation.
Quick Reference#
| Engine | lang format | Default | Resolution |
|---|---|---|---|
| RapidOCR | ISO 639-1/2 or English name | [] → chinese | Maps to chinese/english/latin model set |
| EasyOCR | ISO 639-1 | ["fr","de","es","en"] | Delegated to EasyOCR |
| Tesseract CLI | ISO 639-2 (3-letter) | ["fra","deu","spa","eng"] | Validated + passed as -l eng+fra |
| tesserocr | ISO 639-2 (3-letter) | ["fra","deu","spa","eng"] | Passed to PyTessBaseAPI as eng+fra |
| macOS Vision | Locale (en-US) | ["fr-FR","de-DE","es-ES","en-US"] | Delegated to Apple Vision |
Key Source Files#
| File | Role |
|---|---|
docling/datamodel/pipeline_options.py | All OcrOptions subclasses with lang field definitions |
docling/models/stages/ocr/rapid_ocr_model.py | _RAPIDOCR_LANGUAGE_GROUPS, _resolve_rapidocr_language(), _rapidocr_lang_type_params() |
docling/models/stages/ocr/easyocr_model.py | EasyOCR reader initialization and model download |
docling/models/stages/ocr/tesseract_ocr_cli_model.py | _sanitize_lang() and CLI language injection |