{"record":{"id":"651b117681cd1fa5","repo":"docling-project/docling","slug":"rapidocr-torch-backend-does-not-support-language","errorCode":null,"errorMessage":"RapidOCR torch backend does not support language {lang!r}. Supported: {sorted(PP_OCRV6_LANGS | _PPOCRV4_LANGS)}.","messagePattern":"RapidOCR torch backend does not support language (.+?)\\. Supported: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/models/stages/ocr/rapid_ocr_model.py","lineNumber":160,"sourceCode":"\n    - Prefer PP-OCRv6 (whose recognizer is multilingual and covers ~52 codes)\n    - Otherwise fall back to PP-OCRv4 for the torch backend or PP-OCRv5 for the others.\n    - Raises when the language cannot be served by the resolved backbone.\n\n    Callers pass a single language; reducing a multi-language request is up to them.\n    \"\"\"\n    from rapidocr.utils.model_resolver import COMMON_LANG_ALIASES, PP_OCRV6_LANGS\n    from rapidocr.utils.typings import OCRVersion\n\n    code = lang.strip().lower()\n    code = _DOCLING_LANG_NORMALIZE.get(code, code)\n    aliased = COMMON_LANG_ALIASES.get(code, code)\n\n    if aliased in PP_OCRV6_LANGS:\n        version = OCRVersion.PPOCRV6\n    elif backend == \"torch\":\n        if aliased not in _PPOCRV4_LANGS:\n            raise ValueError(\n                f\"RapidOCR torch backend does not support language {lang!r}. \"\n                f\"Supported: {sorted(PP_OCRV6_LANGS | _PPOCRV4_LANGS)}.\"\n            )\n        version = OCRVersion.PPOCRV4\n    elif aliased in _PPOCRV5_LANGS:\n        version = OCRVersion.PPOCRV5\n    else:\n        raise ValueError(\n            f\"RapidOCR {backend} backend does not support language {lang!r}. \"\n            f\"Supported: {sorted(PP_OCRV6_LANGS | _PPOCRV5_LANGS)}.\"\n        )\n\n    _log.debug(\n        \"RapidOCR resolved lang=%r backend=%r -> version=%s rec_lang=%r\",\n        lang,\n        backend,\n        version.value,\n        aliased,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/stages/ocr/rapid_ocr_model.py#L142-L178","documentation":"When resolving the OCR model for a requested language, Docling prefers PP-OCRv6 (multilingual). For the torch backend it can only fall back to PP-OCRv4, so if the language (after Docling normalization and rapidocr COMMON_LANG_ALIASES mapping) is in neither PP_OCRV6_LANGS nor _PPOCRV4_LANGS, this ValueError is raised. The message lists the union of supported codes.","triggerScenarios":"RapidOcrOptions(lang='...', backend='torch') where the language code is not covered by PP-OCRv6 or PP-OCRv4, e.g. a language only served by PP-OCRv5 models (available on onnxruntime/openvino/paddle backends).","commonSituations":"Users switching to backend='torch' for GPU inference without checking that their language is served; using exotic or regional language codes that only exist in the v5 model family; misspelled language codes that alias-resolution cannot map.","solutions":["Switch to a non-torch backend such as 'onnxruntime' or 'openvino', which can fall back to PP-OCRv5 and covers more languages.","Verify the language code appears in the sorted list printed in the error; correct typos or use the canonical rapidocr language code.","If the language is genuinely unsupported by RapidOCR, use a different OCR engine (e.g. Tesseract or EasyOCR) via OcrOptions.ocr_engine."],"exampleFix":"# before\nocr_options = RapidOcrOptions(lang=\"korean\", backend=\"torch\")\n\n# after\nocr_options = RapidOcrOptions(lang=\"korean\", backend=\"onnxruntime\")","handlingStrategy":"validation","validationCode":"from rapidocr.utils.model_resolver import PP_OCRV6_LANGS\n# at startup, before building the pipeline:\nif backend == \"torch\":\n    assert aliased_lang in PP_OCRV6_LANGS | _PPOCRV4_LANGS, (\n        f\"lang {lang!r} unsupported on torch backend; use onnxruntime/openvino\"\n    )","typeGuard":null,"tryCatchPattern":"try:\n    pipeline.initialize()\nexcept ValueError as e:\n    if \"torch backend does not support language\" in str(e):\n        # degrade to a backend with wider language coverage\n        options.backend = \"onnxruntime\"\n        pipeline.initialize()\n    else:\n        raise","preventionTips":["Pin the (lang, backend) pairs you support in a config matrix and validate at startup.","Prefer onnxruntime/openvino backends when language coverage matters more than torch execution.","Test each configured language against the actual backend in CI."],"tags":["ocr","rapidocr","language","configuration"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}