Docling Loader validation error — `format_options` keyword

NightPanda Expert 1h ago 459 views 10 likes 2 min read

I've been wrestling with Docling + LangChain for a PDF ingestion pipeline on Windows. After sorting out the usual suspects — cv2 missing, then the cl.exe compiler error fixed by installing the full MSVC build tools — I stripped the pipeline down to the bare minimum to avoid the heavy layout models:

from pathlib import Path
from langchain_docling.loader import DoclingLoader
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.datamodel.base_models import InputFormat
from docling.document_converter import PdfFormatOption

data_dir = Path(r"C:\Users\Quadrant\AWS-S3-Assistant\data")
pdf_files = list(data_dir.glob("*.pdf"))

pipeline_options = PdfPipelineOptions(
    do_ocr=False,
    do_table_structure=False,
    do_picture_classification=False,
    do_picture_description=False,
    do_chart_extraction=False,
    do_code_enrichment=False,
    do_formula_enrichment=False,
    generate_page_images=False,
    generate_picture_images=False,
    generate_table_images=False,
)

for file_path in pdf_files:
    print(f"\nProcessing: {file_path.name}")

    loader = DoclingLoader(
        file_path=str(file_path),
        export_type="markdown",
        convert_kwargs={
            "format_options": {
                InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
            }
        }
    )

    docs = loader.load()
    print(f"Documents loaded: {len(docs)}")
    for d in docs[:3]:
        print(d.page_content[:500])

But loader.load() blows up with:

pydantic_core._pydantic_core.ValidationError: 1 validation error for DocumentConverter.convert
format_options
  Unexpected keyword argument [type=unexpected_keyword_argument, input_value={<InputFormat.PDF: 'pdf'>: PdfFormatOption(pipeline_options=..., backend_options=None)}, input_type=dict]

The traceback points to langchain_docling.loaderDocumentConverter.convert → Pydantic validation. The validator sees a dict keyed by InputFormat.PDF ('pdf') but rejects it as an unexpected keyword argument.

What I've checked so far

1. Docling version: docling==2.15.1, langchain-docling==0.1.3
2. Docling's own docs show format_options accepting a dict[InputFormat, FormatOption] — that's exactly what I'm passing.
3. Source dive: langchain_docling/loader.py line 134 calls self._converter.convert(...) with **self.convert_kwargs. The convert_kwargs dict gets unpacked directly into DocumentConverter.convert().

So the mismatch is between what LangChain's wrapper passes and what Docling's convert() signature actually validates via Pydantic.

Suspected root cause

Docling 2.x may have changed convert() to accept format_options as a positional-only or differently named parameter, or the Pydantic model for convert() doesn't declare format_options as a field at all. The wrapper is blindly forwarding a kwarg that the underlying method's validator doesn't recognize.

Workaround I'm testing

Dropping convert_kwargs entirely and configuring the converter at construction time:

from docling.document_converter import DocumentConverter

converter = DocumentConverter(
    format_options={
        InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
    }
)

loader = DoclingLoader(
    file_path=str(file_path),
    export_type="markdown",
    converter=converter  # pass pre-configured instance
)

Haven't confirmed this works yet — the DoclingLoader signature in 0.1.3 may not expose a converter parameter.


Anyone hit this exact validation error? Is there a version combo where the wrapper and core align, or a different way to inject pipeline options without triggering the Pydantic validator?

Help Wanted

All Replies (3)

Q
QuinnPilot Novice 56m ago
Also pin docling==2.15.1 — newer breaks format_options parsing
0 Reply
L
Leo37 Novice 54m ago
Did you hit the cl.exe error on Windows too?
0 Reply
R
Riley82 Advanced 54m ago
Rolled back to 2.15.1 last week — same headache
0 Reply

Write a Reply

Markdown supported