图像安装
- 作者仓库星标 60,915
- 作者更新于 实时读取
- 作者仓库 docling
- 领域
- 文档
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @docling-project · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 兼容的系统
- macOS
- 底层运行要求
- Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: docling-document-intelligence
description: > Use this skill to parse, convert, chunk, and analyze documents with Docling. It handles both l…
category: 文档
runtime: Python
---
# docling-document-intelligence 输出预览
## PART A: 任务判断
- 适用问题:PRD、RFC、README、项目说明或知识库整理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Scope / Step-by-Step Instructions / 1. Resolve the input”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于PRD、RFC、README、项目说明或知识库整理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Scope / Step-by-Step Instructions / 1. Resolve the input”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、会按任务需要访问外部网络、需要准备 Vendor-specific API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/tmp` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件。
先用一个小任务确认它会围绕“Scope / Step-by-Step Instructions / 1. Resolve the input”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: docling-document-intelligence
description: > Use this skill to parse, convert, chunk, and analyze documents with Docling. It handles both l…
category: 文档
source: docling-project/docling
---
# docling-document-intelligence
## 什么时候使用
- 把项目文档方向的常用动作沉淀成 Agent 可调用的技能 适合处理README、PRD、RFC、教程和知识库文档,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的…
- 面向PRD、RFC、README、项目说明或知识库整理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Scope / Step-by-Step Instructions / 1. Resolve the input」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "docling-document-intelligence" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Scope / Step-by-Step Instructions / 1. Resolve the input
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Python | 读取文件、写入/修改文件 | 会按任务需要访问外部网络
安全层 -> 需要准备 Vendor-specific API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Docling Document Intelligence Skill
Use this skill to parse, convert, chunk, and analyze documents with Docling.
It handles both local file paths and URLs, and outputs either Markdown or
structured JSON (DoclingDocument).
Conversion uses the docling CLI (installed with pip install docling).
The Python API is used only for features the CLI does not expose (chunking,
VLM remote-API endpoint configuration, hybrid force_backend_text mode).
Scope
| Task | Covered |
|---|---|
| Parse PDF / DOCX / PPTX / HTML / image | ✅ |
| Convert to Markdown | ✅ |
| Export as DoclingDocument JSON | ✅ |
| Chunk for RAG (hybrid: heading + token) | ✅ (Python API) |
| Analyze structure (headings, tables, figures) | ✅ (Python API) |
| OCR for scanned PDFs | ✅ (auto-enabled) |
| Multi-source batch conversion | ✅ |
Step-by-Step Instructions
1. Resolve the input
Determine whether the user supplied a local path or a URL.
The docling CLI accepts both directly.
docling path/to/file.pdf
docling https://example.com/a.pdf
2. Choose a pipeline
Docling has two pipeline families. Pick based on document type and hardware.
| Pipeline | CLI flag | Best for | Key tradeoff |
|---|---|---|---|
| Standard (default) | --pipeline standard |
Born-digital PDFs, speed | No GPU needed; OCR for scanned pages |
| VLM | --pipeline vlm |
Complex layouts, handwriting, formulas | Needs GPU; slower |
See pipelines.md for the full decision matrix, OCR engine table (EasyOCR, RapidOCR, Tesseract, macOS), and VLM model presets.
3. Convert the document
CLI (preferred for straightforward conversions)
# Markdown (default output)
docling report.pdf --output /tmp/
# JSON (structured, lossless)
docling report.pdf --to json --output /tmp/
# VLM pipeline
docling report.pdf --pipeline vlm --output /tmp/
# VLM with specific model
docling report.pdf --pipeline vlm --vlm-model granite_docling --output /tmp/
# Custom OCR engine
docling report.pdf --ocr-engine tesserocr --output /tmp/
# Disable OCR or tables for speed
docling report.pdf --no-ocr --output /tmp/
docling report.pdf --no-tables --output /tmp/
# Remote VLM services
docling report.pdf --pipeline vlm --enable-remote-services --output /tmp/
The CLI writes output files to the --output directory, named after the
input file (e.g. report.pdf → report.md or report.json).
CLI reference: https://docling-project.github.io/docling/reference/cli/
Python API (for advanced features)
Use the Python API when you need features the CLI does not expose:
chunking, VLM remote-API endpoint configuration, or hybrid
force_backend_text mode.
Docling 2.81+ API note: DocumentConverter(format_options=...) expects
dict[InputFormat, FormatOption] (e.g. InputFormat.PDF → PdfFormatOption).
Using string keys like {"pdf": PdfPipelineOptions(...)} fails at runtime with
AttributeError: 'PdfPipelineOptions' object has no attribute 'backend'.
Standard pipeline (default):
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions
converter = DocumentConverter()
result = converter.convert("report.pdf")
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=PdfPipelineOptions(do_ocr=True, do_table_structure=True),
),
}
)
result = converter.convert("report.pdf")
VLM pipeline — local (GraniteDocling via HF Transformers):
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import VlmPipelineOptions
from docling.datamodel import vlm_model_specs
from docling.pipeline.vlm_pipeline import VlmPipeline
pipeline_options = VlmPipelineOptions(
vlm_options=vlm_model_specs.GRANITEDOCLING_TRANSFORMERS,
generate_page_images=True,
)
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_cls=VlmPipeline,
pipeline_options=pipeline_options,
)
}
)
result = converter.convert("report.pdf")
VLM pipeline — remote API (vLLM / LM Studio / Ollama):
This is only available via the Python API; the CLI does not expose endpoint URL, model name, or API key configuration.
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import VlmPipelineOptions
from docling.datamodel.pipeline_options_vlm_model import ApiVlmOptions, ResponseFormat
from docling.pipeline.vlm_pipeline import VlmPipeline
vlm_opts = ApiVlmOptions(
url="http://localhost:8000/v1/chat/completions",
params=dict(model="ibm-granite/granite-docling-258M", max_tokens=4096),
prompt="Convert this page to docling.",
response_format=ResponseFormat.DOCTAGS,
timeout=120,
)
pipeline_options = VlmPipelineOptions(
vlm_options=vlm_opts,
generate_page_images=True,
enable_remote_services=True, # required — gates all outbound HTTP
)
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_cls=VlmPipeline,
pipeline_options=pipeline_options,
)
}
)
result = converter.convert("report.pdf")
Hybrid mode (force_backend_text) — Python API only:
Uses deterministic PDF text extraction for text regions while routing images and tables through the VLM. Reduces hallucination on text-heavy pages.
pipeline_options = VlmPipelineOptions(
vlm_options=vlm_model_specs.GRANITEDOCLING_TRANSFORMERS,
force_backend_text=True,
generate_page_images=True,
)
result.document is a DoclingDocument object in all cases.
4. Choose output format
Markdown (default, human-readable):
docling report.pdf --to md --output /tmp/
Or via Python: result.document.export_to_markdown()
JSON / DoclingDocument (structured, lossless):
docling report.pdf --to json --output /tmp/
Or via Python: result.document.export_to_dict()
If the user does not specify a format, ask: "Should I output Markdown or structured JSON (DoclingDocument)?"
5. Chunk for RAG (hybrid strategy)
Chunking is only available via the Python API.
Default: hybrid chunker — splits first by heading hierarchy, then subdivides oversized sections by token count. This preserves semantic boundaries while respecting model context limits.
The tokenizer API changed in docling-core 2.8.0. Pass a BaseTokenizer
object, not a raw string:
HuggingFace tokenizer (default):
from docling.chunking import HybridChunker
from docling_core.transforms.chunker.tokenizer.huggingface import HuggingFaceTokenizer
tokenizer = HuggingFaceTokenizer.from_pretrained(
model_name="sentence-transformers/all-MiniLM-L6-v2",
max_tokens=512,
)
chunker = HybridChunker(tokenizer=tokenizer, merge_peers=True)
chunks = list(chunker.chunk(result.document))
for chunk in chunks:
embed_text = chunker.contextualize(chunk)
print(chunk.meta.headings) # heading breadcrumb list
print(chunk.meta.origin.page_no) # source page number
OpenAI tokenizer (for OpenAI embedding models):
import tiktoken
from docling_core.transforms.chunker.tokenizer.openai import OpenAITokenizer
tokenizer = OpenAITokenizer(
tokenizer=tiktoken.encoding_for_model("text-embedding-3-small"),
max_tokens=8192,
)
# Requires: pip install 'docling-core[chunking-openai]'
For chunking strategies and tokenizer details, see the Docling documentation
on chunking and HybridChunker.
6. Analyze document structure
Use the DoclingDocument object directly to inspect structure:
doc = result.document
for item, level in doc.iterate_items():
if hasattr(item, 'label') and item.label.name == 'SECTION_HEADER':
print(f"{'#' * level} {item.text}")
for table in doc.tables:
print(table.export_to_dataframe()) # pandas DataFrame
print(table.export_to_markdown())
for picture in doc.pictures:
print(picture.caption_text(doc)) # caption if present
For the full API surface, see Docling's structure and table export docs.
7. Evaluate output and iterate (required for "best effort" conversions)
After every conversion where the user cares about fidelity (not quick previews), run the bundled evaluator on the JSON export, then refine the pipeline if needed. This is how the agent checks its work and improves the run without guessing.
Step A — Produce JSON and optional Markdown
docling "<source>" --to json --output /tmp/
docling "<source>" --to md --output /tmp/
Step B — Evaluate
python3 scripts/docling-evaluate.py /tmp/<filename>.json --markdown /tmp/<filename>.md
If the user expects tables (invoices, spreadsheets in PDF), add
--expect-tables. Tighten gates with --fail-on-warn in CI-style checks.
The script prints a JSON report to stdout: status (pass | warn | fail),
metrics, issues, and recommended_actions (concrete docling CLI
flags to try next).
Step C — Refinement loop (max 3 attempts unless the user says otherwise)
- If
statusiswarnorfail, apply one primary change fromrecommended_actions(e.g. switch--pipeline vlm, change--ocr-engine, ensure tables are enabled). - Re-convert with
docling, re-runscripts/docling-evaluate.py. - Stop when
statusispass, or after 3 iterations — then summarize what worked and any remaining issues for the user.
Step D — Self-improvement log (skill memory)
After a successful pass or after the final iteration, append one entry to improvement-log.md in this skill directory:
- Source type (e.g. scanned PDF, digital PDF, DOCX)
- First-run problems (from
issues) - Pipeline + flags that fixed or best mitigated them
- Final
statusand one line of subjective quality notes
This log is optional for the user to git-ignore; it is for local learning so future runs on similar documents start closer to the right pipeline.
8. Agent quality checklist (manual, if script unavailable)
If scripts/docling-evaluate.py cannot run, still verify:
| Check | Action if bad |
|---|---|
| Page count matches source (roughly) | Re-run; try --pipeline vlm if layout is complex |
| Markdown is not near-empty | Enable OCR / VLM |
| Tables missing when visually obvious | Remove --no-tables; try --pipeline vlm |
\ufffd replacement characters |
Different --ocr-engine or --pipeline vlm |
| Same line repeated many times | --pipeline vlm or hybrid force_backend_text (Python API) |
Common Edge Cases
| Situation | Handling |
|---|---|
| Scanned / image-only PDF | Standard pipeline with OCR, or --pipeline vlm for best quality |
| Password-protected PDF | --pdf-password PASSWORD; will raise ConversionError if wrong |
| Very large document (500+ pages) | Standard pipeline with --no-tables for speed |
| Complex layout / multi-column | --pipeline vlm; standard may misorder reading flow |
| Handwriting or formulas | --pipeline vlm only — standard OCR will not handle these |
| URL behind auth | Pre-download to temp file; pass local path |
| Tables with merged cells | table.export_to_markdown() handles spans; VLM often more accurate |
| Non-UTF-8 encoding | Docling normalises internally; no special handling needed |
| VLM hallucinating text | force_backend_text=True via Python API for hybrid mode |
| VLM API call blocked | --enable-remote-services (CLI) or enable_remote_services=True (Python) |
| Apple Silicon | --vlm-model granite_docling with MLX backend, or GRANITEDOCLING_MLX preset (Python API) |
Pipeline reference
Full decision matrix, all OCR engine options, VLM model presets, and API server configuration: pipelines.md
Output conventions
- Always report the number of pages and conversion status.
- When evaluation is in scope, report evaluator
status, topissues, and which refinement attempt produced the final output. - For Markdown output: wrap in a fenced code block only if the user will copy/paste it; otherwise render directly.
- For JSON output: pretty-print with
indent=2unless the user specifies otherwise. - For chunks: report total chunk count, min/max/avg token counts.
- For structure analysis: summarise heading tree + table count + figure count before going into detail.
Dependencies
pip install docling docling-core
# For OpenAI tokenizer support:
pip install 'docling-core[chunking-openai]'
The docling CLI is included with the docling package — no separate install needed.
Check installed versions (prefer distribution metadata — docling may not set __version__):
from importlib.metadata import version
print(version("docling"), version("docling-core"))
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核