### Quick start for Docling CLI and evaluation Source: https://github.com/docling-project/docling/blob/main/docs/examples/agent_skill/docling-document-intelligence/README.md Install dependencies and perform document conversion followed by quality evaluation. Use the --pipeline vlm flag for vision-model pipelines. ```bash pip install docling docling-core # Convert to Markdown docling https://arxiv.org/pdf/2408.09869 --output /tmp/ # Convert to JSON docling https://arxiv.org/pdf/2408.09869 --to json --output /tmp/ # Evaluate quality python3 scripts/docling-evaluate.py /tmp/2408.09869.json --markdown /tmp/2408.09869.md ``` -------------------------------- ### Start vLLM Server on Linux Source: https://github.com/docling-project/docling/blob/main/docs/getting_started/rtx.md Use this command to start the vLLM inference server with optimized parameters for maximum performance on Linux systems. Ensure vLLM is installed and the model is accessible. ```bash vllm serve ibm-granite/granite-docling-258M \ --host 127.0.0.1 --port 8000 \ --max-num-seqs 512 \ --max-num-batched-tokens 8192 \ --enable-chunked-prefill \ --gpu-memory-utilization 0.9 ``` -------------------------------- ### Install the Full Docling Package Source: https://github.com/docling-project/docling/blob/main/packages/docling-slim/README.md Install the recommended, full-featured Docling package with all standard capabilities. ```bash pip install docling ``` -------------------------------- ### Install Docling Source: https://github.com/docling-project/docling/blob/main/docs/examples/service_client/docling_service_client_file_quickstart.ipynb Installs the docling library. Run this cell before proceeding. ```python %pip install -qU docling ``` -------------------------------- ### Install Docling Slim Service Client Source: https://github.com/docling-project/docling/blob/main/packages/docling-slim/README.md Install Docling Slim with the service client for interacting with the Docling Serve API. ```bash pip install docling-slim[service-client] ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/docling-project/docling/blob/main/docs/getting_started/installation.md Install all necessary dependencies for development, including optional extras, using the `uv` package manager. ```bash uv sync --all-extras ``` -------------------------------- ### Install Docling ASR Pipeline Source: https://github.com/docling-project/docling/blob/main/docs/usage/processing_audio_media.md Install the ASR pipeline alongside the base Docling package using pip or uv. ```bash pip install "docling[asr]" ``` ```bash uv add "docling[asr]" ``` -------------------------------- ### Install Docling with XBRL Support Source: https://github.com/docling-project/docling/blob/main/docs/examples/xbrl_conversion.ipynb Installs the Docling package with XBRL parsing capabilities using pip. This is the initial setup step required before working with XBRL documents. ```python %pip install -q docling ``` -------------------------------- ### Configure DocumentConverter with Tesseract OCR Source: https://github.com/docling-project/docling/blob/main/docs/getting_started/installation.md Example of setting up DocumentConverter to use Tesseract OCR for PDF processing. Ensure Tesseract is installed and configured. ```python from docling.datamodel.base_models import InputFormat from docling.datamodel.pipeline_options import ( TesseractOcrOptions, PdfPipelineOptions, ) from docling.document_converter import DocumentConverter, PdfFormatOption pipeline_options = PdfPipelineOptions() pipeline_options.do_ocr = True pipeline_options.ocr_options = TesseractOcrOptions() # Use Tesseract doc_converter = DocumentConverter( format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)} ) ``` -------------------------------- ### Install and Serve vLLM Backend Source: https://github.com/docling-project/docling/blob/main/docs/examples/agent_skill/docling-document-intelligence/pipelines.md Sets up the vLLM server to host the Granite Docling model for high-throughput batch processing. ```bash pip install vllm vllm serve ibm-granite/granite-docling-258M ``` -------------------------------- ### Configure OpenAITokenizer for Chunking Source: https://github.com/docling-project/docling/blob/main/docs/examples/agent_skill/docling-document-intelligence/SKILL.md This example shows how to set up OpenAITokenizer using tiktoken for compatibility with OpenAI embedding models, noting the required installation. ```python 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]' ``` -------------------------------- ### Run MkDocs Documentation Server Source: https://github.com/docling-project/docling/blob/main/CONTRIBUTING.md Start the local documentation server, accessible at `http://localhost:8000`. ```bash mkdocs serve ``` -------------------------------- ### Install Docling Agent Skill Source: https://github.com/docling-project/docling/blob/main/docs/examples/agent_skill/docling-document-intelligence/EXAMPLE.md Copy the Docling agent skill directory into your AI agent's skills folder to enable its functionality. This setup allows agents like Cursor or Claude to load the skill. ```bash cp -r docs/examples/agent_skill/docling-document-intelligence ~/.cursor/skills/ # Or copy from another machine / archive into e.g. ~/.claude/skills/ ``` -------------------------------- ### Load and Display Example Document Image Source: https://github.com/docling-project/docling/blob/main/docs/examples/extraction.ipynb Define a URL for an example image and use `IPython.display.HTML` to render it within the notebook for inspection. ```python file_path = ( "https://upload.wikimedia.org/wikipedia/commons/9/9f/Swiss_QR-Bill_example.jpg" ) display.HTML(f"") ``` -------------------------------- ### Install and Run docling-serve (Local Engine) Source: https://github.com/docling-project/docling/blob/main/docs/usage/api_server/deployment.md Installs the necessary package and runs the docling-serve API server using the default local compute engine. The `dev` command is suitable for development with auto-reloading. ```sh pip install "docling-serve[ui]" docling-serve run --enable-ui # production-style: reload off, binds 0.0.0.0, UI off by default # docling-serve dev # dev: auto-reload, binds 127.0.0.1, UI on (localhost only) ``` -------------------------------- ### Install LlamaIndex Docling Integration Dependencies Source: https://github.com/docling-project/docling/blob/main/docs/examples/rag_llamaindex.ipynb Install required Python packages for the RAG pipeline including LlamaIndex core, Docling readers/parsers, Hugging Face embeddings and LLM support, Milvus vector store, and file readers. The --no-warn-conflicts flag is specific to Colab environments to avoid conflicts with pre-installed packages. ```python %pip install -q --progress-bar off --no-warn-conflicts llama-index-core llama-index-readers-docling llama-index-node-parser-docling llama-index-embeddings-huggingface llama-index-llms-huggingface-api llama-index-vector-stores-milvus llama-index-readers-file python-dotenv ``` -------------------------------- ### Define Plugin Entrypoint in setup.py Source: https://github.com/docling-project/docling/blob/main/docs/concepts/plugins.md Configure plugin entrypoint using setup.py format with setuptools. This registers your plugin with the Docling ecosystem by specifying entry_points in the setup() function call. ```python from setuptools import setup setup( # ..., entry_points = { 'docling': [ 'your_plugin_name = "your_package.module"' ] } ) ``` -------------------------------- ### Setup Experiment with Temporary Folder and Articles Source: https://github.com/docling-project/docling/blob/main/docs/examples/dpk-ingest-chunk-tokenize.ipynb Creates a temporary directory for storing downloaded articles and initializes the list of articles to retrieve from Wikimedia. Calls load_corpus to download the specified articles and asserts that at least one document was successfully downloaded. ```python import os import tempfile datafolder = tempfile.mkdtemp(dir=os.getcwd()) articles = ["Science,_technology,_engineering,_and_mathematics"] assert load_corpus(articles, datafolder) > 0, "Faild to download any documents" ``` -------------------------------- ### Build LlamaIndex RAG Pipeline with DoclingReader (JSON) and Milvus for Richer Grounding Source: https://github.com/docling-project/docling/blob/main/docs/examples/rag_llamaindex.ipynb This snippet demonstrates an advanced RAG pipeline leveraging Docling's rich native JSON format. It configures the DoclingReader to export as JSON and uses a specialized DoclingNodeParser to process this format, enabling more granular document-level grounding in the query results. The setup for the vector store, indexing, and querying remains similar to the Markdown example. ```python from llama_index.node_parser.docling import DoclingNodeParser reader = DoclingReader(export_type=DoclingReader.ExportType.JSON) node_parser = DoclingNodeParser() vector_store = MilvusVectorStore( uri=str(Path(mkdtemp()) / "docling.db"), # or set as needed dim=embed_dim, overwrite=True, ) index = VectorStoreIndex.from_documents( documents=reader.load_data(SOURCE), transformations=[node_parser], storage_context=StorageContext.from_defaults(vector_store=vector_store), embed_model=EMBED_MODEL, ) result = index.as_query_engine(llm=GEN_MODEL).query(QUERY) print(f"Q: {QUERY}\nA: {result.response.strip()}\n\nSources:") ``` -------------------------------- ### Configure Flash Attention 2 for Docling Models Source: https://github.com/docling-project/docling/blob/main/docs/faq/index.md These examples show how to enable Flash Attention 2 when running Docling models on CUDA devices. You can activate it by setting an environment variable before execution or by programmatically configuring `VlmPipelineOptions` in Python. This feature requires the `flash-attn` package to be installed and can significantly enhance model performance. ```shell DOCLING_CUDA_USE_FLASH_ATTENTION2=1 ``` ```python from docling.datamodel.accelerator_options import ( AcceleratorOptions, ) pipeline_options = VlmPipelineOptions( accelerator_options=AcceleratorOptions(cuda_use_flash_attention2=True) ) ``` -------------------------------- ### Install Docling with uv Source: https://github.com/docling-project/docling/blob/main/docs/getting_started/installation.md Use this command to add the Docling package to your project using uv. ```bash uv add docling ``` -------------------------------- ### Install Tesserocr with specific options Source: https://github.com/docling-project/docling/blob/main/docs/getting_started/installation.md Provides alternative pip installation commands for the Tesserocr package to resolve potential installation issues. It forces a source build. ```bash pip uninstall tesserocr pip install --no-binary :all: tesserocr ``` -------------------------------- ### Install VLM Dependencies for Docling Source: https://github.com/docling-project/docling/blob/main/docs/examples/agent_skill/docling-document-intelligence/pipelines.md Installs the necessary packages for local VLM inference using PyTorch and Transformers. You can use the [vlm] extra or install components manually. ```bash pip install docling[vlm] # or manually: pip install torch transformers accelerate ``` -------------------------------- ### Install Docling Slim with PDF and Local Models Source: https://github.com/docling-project/docling/blob/main/packages/docling-slim/README.md Install Docling Slim with support for PDF parsing and local PyTorch models. ```bash pip install docling-slim[format-pdf,models-local] ```