Skip to main content


Docling Graph

Docling Graph

Docs PyPI version Python 3.10 | 3.11 | 3.12 uv Ruff License MIT Pydantic v2 Docling NetworkX Typer Rich vLLM Ollama OpenSSF Best Practices LF AI & Data

Docling-Graph turns documents into validated Pydantic objects, then builds a directed knowledge graph with explicit semantic relationships.

This transformation enables high-precision use cases in chemistry, finance, and legal domains, where AI must capture exact entity connections (compounds and reactions, instruments and dependencies, properties and measurements) rather than rely on approximate text embeddings.

This toolkit supports two extraction paths: local VLM extraction via Docling, and LLM-based extraction routed through LiteLLM for local runtimes (vLLM, Ollama) and API providers (OpenAI, Gemini, IBM watsonx, Mistral and more), all orchestrated through a flexible, config-driven pipeline.

Key Capabilities

  • ✍🏻 Input formats: Docling’s supported inputs: PDF, images, DocLang, markdown, Office and more.

  • 🧠 Extraction: LLM or VLM backends, with chunking and processing modes.

  • 💎 Graphs: Pydantic to NetworkX directed graphs with stable IDs, edge and provenance metadata.

  • 📦 Export: CSV, Cypher, and other KG-friendly formats.

  • 🔍 Visualization: Interactive HTML and Markdown reports.

  • 🐛 Trace capture: Debug exports for extraction and fallback diagnostics.

Latest Changes

  • 🔗 Graph fusion: Merge multiple knowledge graphs into one. Fully audited, deterministic, and no LLM calls.

  • 🧩 Template generation: Generate Pydantic templates from example documents or ontologies (OWL/RDFS...).

  • 🦆 DocLang support: Parse .dclg/.dclx inputs, and optionally serialize document as DocLang for the LLM.

  • 📍 Data grounding: Deterministic provenance ledger with bounding-box geometry and no extra LLM calls.

  • ✨ Dense extraction: Advanced skeleton-then-flesh extraction mode for complex documents.

  • 🚀 Docling Serve support: Offload document conversion to a remote docling-serve instance.

Quick Start

Requirements

  • Python 3.10 or higher

Installation

pip install docling-graph

This installs the core package with LiteLLM for remote and local LLM providers.

VLM backend support requires the vlm extra:

pip install "docling-graph[vlm]

For detailed installation instructions (including optional extras and GPU setup), see Installation Guide.

API Key Setup (Remote Inference)

Copy .env.example to .env and fill in the values for the provider(s) you use:

cp .env.example .env

See API Keys Setup for provider-specific instructions (including Amazon Bedrock's AWS credential chain).

Basic Usage

CLI

# Initialize configuration
docling-graph init

# Convert document from URL (each line except the last must end with \)
docling-graph convert "https://arxiv.org/pdf/2207.02720" \
    --template "docs.examples.templates.rheology_research.ScholarlyRheologyPaper" \
    --processing-mode "many-to-one" \
    --extraction-contract "dense" \
    --debug

# Visualize results
docling-graph inspect outputs

Python API - Default Behavior

from docling_graph import run_pipeline, PipelineContext
from docs.examples.templates.rheology_research import ScholarlyRheologyPaper

# Create configuration
config = {
    "source": "https://arxiv.org/pdf/2207.02720",
    "template": ScholarlyRheologyPaper,
    "backend": "llm",
    "inference": "remote",
    "processing_mode": "many-to-one",
    "extraction_contract": "auto",
    "provider_override": "mistral",
    "model_override": "mistral-medium-latest",
    "structured_output": True,  # default
    "use_chunking": True,
}

# Run pipeline - returns data directly, no files written to disk
context: PipelineContext = run_pipeline(config)

# Access results
graph = context.knowledge_graph
models = context.extracted_models
metadata = context.graph_metadata

print(f"Extracted {len(models)} model(s)")
print(f"Graph: {graph.number_of_nodes()} nodes, {graph.number_of_edges()} edges")

Every node above also carries a deterministic __provenance__ attribute by default (provenance="standard"), pointing back to the source chunk and page it was extracted from — no extra LLM calls involved. See Data Grounding & Provenance.

For debugging, use --debug with the CLI to save intermediate artifacts to disk; see Trace Data & Debugging. For more examples, see Examples.

Pydantic Templates

Templates define both the extraction schema and the resulting graph structure.

from pydantic import BaseModel, Field
from docling_graph.utils import edge

class Person(BaseModel):
    """Person entity with stable ID."""
    model_config = {
        'is_entity': True,
        'graph_id_fields': ['last_name', 'date_of_birth']
    }
    
    first_name: str = Field(description="Person's first name")
    last_name: str = Field(description="Person's last name")
    date_of_birth: str = Field(description="Date of birth (YYYY-MM-DD)")

class Organization(BaseModel):
    """Organization entity."""
    model_config = {'is_entity': True}
    
    name: str = Field(description="Organization name")
    employees: list[Person] = edge("EMPLOYS", description="List of employees")

Generating a template from documents

Instead of writing the template by hand, you can induce one from a few example documents:

docling-graph template from-docs invoice1.pdf invoice2.pdf \
    --output templates/invoices.py \
    --name InvoiceDocument \
    --trial-run

The documents are converted with Docling, then LLM passes propose classes, fields, and relationships as structured data — a deterministic renderer turns that into the Python module, so no LLM ever writes code. Candidates are filtered by deterministic gates (every identity example must appear verbatim in the source) and merged across documents. --trial-run then runs a real extraction on the first document and prints an advisory quality report.

Each generator also writes an editable SPEC YAML next to the template (templates/invoices.spec.yaml). Rename an edge or flip an entity to a component with a one-line YAML edit and re-render, rather than hand-patching generated code:

docling-graph template from-spec templates/invoices.spec.yaml -o templates/invoices.py

Templates can also be compiled from an existing ontology — OWL/RDFS/SKOS, LinkML, or JSON Schema — with no LLM involved at all (needs the templategen extra: pip install 'docling-graph[templategen]'). Any template, generated or hand-written, can be checked against the rulebook:

docling-graph template from-ontology schema.ttl --root ex:InsurancePolicy -o templates/policy.py
docling-graph template lint templates.invoices.InvoiceDocument

For complete guidance, see:

Documentation

Comprehensive documentation can be found on Docling Graph's Page.

Documentation Structure

The documentation follows the docling-graph pipeline stages:

  1. Introduction - Overview and core concepts
  2. Installation - Setup and environment configuration
  3. Schema Definition - Creating Pydantic templates
  4. Pipeline Configuration - Configuring the extraction pipeline
  5. Extraction Process - Document conversion and extraction
  6. Graph Management - Converting, grounding, exporting, and visualizing graphs
  7. CLI Reference - Command-line interface guide
  8. Python API - Programmatic usage
  9. Examples - Working code examples
  10. Advanced Topics - Performance, testing, error handling
  11. API Reference - Detailed API documentation
  12. Community - Contributing and development guide

Contributing

We welcome contributions! Please see:

Development Setup

# Clone and setup
git clone https://github.com/docling-project/docling-graph
cd docling-graph

# Install with dev dependencies
uv sync --extra dev

# Run Execute pre-commit checks
uv run pre-commit run --all-files

License

MIT License - see LICENSE for details.

Acknowledgments

Docling Graph builds on outstanding open-source projects:

  • Docling - document conversion and VLM extraction
  • Pydantic - schema definition and validation
  • NetworkX - graph construction and analysis
  • LiteLLM - unified LLM provider interface
  • Cytoscape - interactive graph visualization

IBM ❤️ Open Source AI

Docling Graph has been brought to you by IBM.

Metadata

Release files for docling-graph 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docling-graph 1.9.2
File Size Uploaded Provenance Actions
docling_graph-1.9.2.tar.gz 420.1 kB With provenance Details for docling_graph-1.9.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docling-graph 1.9.2
File Interpreter ABI Platform Actions
docling_graph-1.9.2-py3-none-any.whl Python 3 none any Details for docling_graph-1.9.2-py3-none-any.whl

Total release size: 897.3 kB

Release files / docling_graph-1.9.2.tar.gz

Download URL docling_graph-1.9.2.tar.gz
Size 420.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea465bd5a7f2c2e3cf3107db823e54939aadea70d58249f79c8fb5ae3cdb21bd
BLAKE2b-256 checksum
How to use checksums
ee1d5fc8e41e575dbb8d2bd8105d043048f54087c83a4baaa27495ad70447574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / docling_graph-1.9.2-py3-none-any.whl

Download URL docling_graph-1.9.2-py3-none-any.whl
Size 477.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21befa0757b40f8448abc563d0ef08286cd80f2476e19aafdb1746c9053385b6
BLAKE2b-256 checksum
How to use checksums
962c074a86aa2cf469f168d3fcdf62642cb40b131621e38fc93428ca085385c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for docling-graph 1.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for docling_graph-1.9.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page