VLM 后端不在核心包内,需单独安装 vlm extra;远程推理要先复制 .env.example 为 .env 并填好对应厂商的 API Key;CLI 多行命令除最后一行外每行需以反斜杠结尾。

docling-graph
docling-projectMIT活跃维护把 PDF 等非结构化文档转成经过校验、可查询的知识图谱,方便做 RAG 和文档关系分析。
Transform unstructured documents into validated, rich and queryable knowledge graphs.
pip install docling-graph
pip install "docling-graph[vlm]"README 未说明具体显存要求;VLM 后端需额外安装 vlm extra,GPU 配置详见官方安装指南。
把非结构化文档转成经 Pydantic 校验的有向知识图谱,适合化学、金融、法律等需要精确实体关系的场景
把 PDF 等非结构化文档转成经过校验、可查询的知识图谱,方便做 RAG 和文档关系分析。
核心能力
- 用 Pydantic 模板校验抽取结果,再构建带稳定 ID 的有向图
- 支持 LLM 与 VLM 两条抽取路径,经 LiteLLM 接入 vLLM、Ollama 及多家 API
- 支持分块与多种处理模式,含 skeleton-then-flesh 稠密抽取
- 导出 CSV、Cypher 等格式,并生成交互式 HTML 可视化
- 提供确定性 provenance 账本,含边界框几何且不额外调用 LLM
容易踩的坑
- v1.9.2最新正式版2026-11-08 · 2026-11-08 15:51 UTC
Bug Fixes
Identity Deduplication
- Keep non-Latin letters in identity dedup keys (b15de72)
Thanks to @RaphaelFakhri for the report and fix.
- v1.9.12026-07-17 · 2026-07-17 12:17 UTC
- v1.9.02026-07-17 · 2026-07-17 10:03 UTC
查看更新说明
Features
Graph Serialization
- Add file-free graph.json round-trip helpers (
7175f4a) - Widen json_serializable for template value types (
4d3b5c6)
Pipeline Runtime Controls
- Add gc_collect gate and propagate typed pipeline errors (
dc02587)
Template Generation API
- Add public build_llm_call_fn constructor (
f31c558)
Bug Fixes
SSRF Protection
- Validate every resolved IP in the URL SSRF guard (
50cb9e5)
Template Generation Security
- Enforce identifier security gate at render time (
052fa28)
- Add file-free graph.json round-trip helpers (
- v1.8.02026-07-17 · 2026-07-17 00:57 UTC
查看更新说明
Features
Knowledge Graph Merge
- Add deterministic knowledge graph merge library and command (
4ec90b3) - Fix conflict detection and add queryable conflict-variant nodes (
2db2446)
Template Generation
- Generate, lint, and evaluate extraction templates (
5611953) - Scale induction with windowing, concurrency, and truncation-safe retries (
4dda718) - Add one-shot induction strategy as the default (
256e4db) - Add --strategy flag and switch template generation to metric logs with a report sidecar (
5e87bdf)
Docling-Serve Extraction
- Convert via the official docling service client (
4cd548d) - Add self-describing graph exports and CLI plumbing for graph fusion and template generation (
116e472)
Bug Fixes
Template Generation Reliability
- Handle recursive roots, component-owned edges, and cyclic nesting in the verification gates (
6210007) - Trim the generated template's verification footer to a short note (
78f65c5) - Import Self from typing_extensions for the 3.10 floor (
a7eb089)
Extraction Pipeline
- Default parallel_workers to 4 and hint to lower it on failure (
61bd9ca) - Surface ExtractionError instead of swallowing it (
363094c) - Suppress litellm's redundant stderr banner on errors (
9ba3117)
Documentation
CLI
- Add deterministic knowledge graph merge library and command (
- v1.7.12026-07-10 · 2026-07-10 18:47 UTC
查看更新说明
Bug Fixes
Dense Extraction Pipeline
- Rescue orphaned children via text anchors, chunk attribution, and emission adjacency (
81e202a) - Restrict derivable-summary license to short fields, long source stays verbatim (
14fe1c0) - Root-identity resolution over page furniture, per-batch emission adjacency rescue (
b39aaee) - Scope discovery to entity-naming rows, batch reconciliation at scale, cap coverage-pass growth (
a3e0c91) - Coerce bare-string references into identity-only instances (
d264ef6)
Alias Reconciliation
- Veto merges of same-label co-children, sibling lists are never aliases (
0679e98)
Refactoring
Deterministic Mechanisms
- Enforce graph_max_instances bounds and closed-catalog reference guard (
7c6777b) - Default llm_input_format to auto (
68ea0ce)
Documentation
System Configuration & Fundamentals
- Cardinality bounds, closed catalogs, root-identity pass, full rescue ladder (
875be9d) - Document new default auto setting for llm_input_format (
f38fef7)
Extraction Templates
- Rescue orphaned children via text anchors, chunk attribution, and emission adjacency (
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Docling Graph
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.
-
🔍 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/.dclxinputs, 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:
- template Command — generating, linting, and evaluating templates
- Schema Definition Guide
- Template Basics
- Example Templates
Documentation
Comprehensive documentation can be found on Docling Graph's Page.
Documentation Structure
The documentation follows the docling-graph pipeline stages:
- Introduction - Overview and core concepts
- Installation - Setup and environment configuration
- Schema Definition - Creating Pydantic templates
- Pipeline Configuration - Configuring the extraction pipeline
- Extraction Process - Document conversion and extraction
- Graph Management - Converting, grounding, exporting, and visualizing graphs
- CLI Reference - Command-line interface guide
- Python API - Programmatic usage
- Examples - Working code examples
- Advanced Topics - Performance, testing, error handling
- API Reference - Detailed API documentation
- Community - Contributing and development guide
Contributing
We welcome contributions! Please see:
- Contributing Guidelines - How to contribute
- Development Guide - Development setup
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.