Skip to main content
Docling parses PDF, DOCX, PPTX, HTML, and other formats into a rich unified representation including document layout, tables etc., making them ready for generative AI workflows like RAG. This integration provides Docling’s capabilities via the DoclingLoader document loader.

Overview

Integration details

ClassPackageLocalSerializableJS support
langchain_docling.loaderlangchain-docling

Loader features

SourceDocument Lazy LoadingNative Async Support
DoclingLoader
The presented DoclingLoader component enables you to:
  • use various document types in your LLM applications with ease and speed, and
  • leverage Docling’s rich format for advanced, document-native grounding.
DoclingLoader supports two different export modes:
  • ExportType.DOC_CHUNKS (default): if you want to have each input document chunked and to then capture each individual chunk as a separate LangChain Document downstream, or
  • ExportType.MARKDOWN: if you want to capture each input document as a separate LangChain Document
The example allows exploring both modes via parameter EXPORT_TYPE; depending on the value set, the example pipeline is then set up accordingly.

Setup

For best conversion speed, use GPU acceleration whenever available; e.g. if running on Colab, use a GPU-enabled runtime.

Initialization

Basic initialization looks as follows:
For advanced usage, DoclingLoader has the following parameters:
  • file_path: source as single str (URL or local file) or iterable thereof
  • converter (optional): any specific Docling converter instance to use
  • convert_kwargs (optional): any specific kwargs for conversion execution
  • export_type (optional): export mode to use: ExportType.DOC_CHUNKS (default) or ExportType.MARKDOWN
  • md_export_kwargs (optional): any specific Markdown export kwargs (for Markdown mode)
  • chunker (optional): any specific Docling chunker instance to use (for doc-chunk mode)
  • meta_extractor (optional): any specific metadata extractor to use

Load

Note: a message saying "Token indices sequence length is longer than the specified maximum sequence length..." can be ignored in this case — more details in this docling-core GitHub issue.
Inspecting some sample docs:

Lazy load

Documents can also be loaded in a lazy fashion:

End-to-end example

  • The following example pipeline uses HuggingFace’s Inference API; for increased LLM quota, token can be provided via env var HF_TOKEN.
  • Dependencies for this pipeline can be installed as shown below (--no-warn-conflicts meant for Colab’s pre-populated Python env; feel free to remove for stricter usage):
Defining the pipeline parameters:
Now we can instantiate our loader and load documents:
Determining the splits:
Inspecting some sample splits:

Ingestion

RAG

Notice that the sources contain rich grounding information, including the passage headings (i.e. section), page, and precise bounding box.

API reference