Docling을 이용한 문서 분석(파싱)

 

[준비] 프로젝트 폴더 생성 후 해당 폴더에서 진행

python -m venv venv
venv\Scripts\activate
python.exe -m pip install --upgrade pip
pip install docling
pip install hf_xet
# 심볼릭 링크 사용 안함 (GitHub 소스 다운로드 시 사용)
git config --global core.symlinks false 
# 윈도우키+I에서 개발자 검색해서 개발자 모드 활성화 해야 권한 오류 예방

 

 

[실행 코드] main.py

# main.py
# https://github.com/docling-project/docling

# python -m venv venv
# venv\Scripts\activate
# python.exe -m pip install --upgrade pip
# pip install docling
# pip install hf_xet
# 심볼릭 링크 사용 안함 (GitHub 소스 다운로드 시 사용)
# git config --global core.symlinks false 
# 윈도우키+I에서 개발자 검색해서 개발자 모드 활성화 

from datetime import datetime
from docling.document_converter import DocumentConverter

source = "https://arxiv.org/pdf/2408.09869"  # document per local path or URL
converter = DocumentConverter()
result = converter.convert(source)

# print(result.document.export_to_markdown())  # output: "## Docling Technical Report[...]"

now = datetime.now()
timestamp = now.strftime("%Y%m%d_%H%M%S")  # 예: "20251108_184000"
filename = f"result{timestamp}.txt"
with open(filename, "w", encoding="utf-8") as f:
    f.write(result.document.export_to_markdown())
print(f"결과가 {filename}에 저장되었습니다.")

 

[실행] CPU 모드에서도 가능 

python main.py

 

[실행 결과]

2025-11-08 18:41:47,920 - INFO - detected formats: [<InputFormat.PDF: 'pdf'>]
2025-11-08 18:41:47,949 - INFO - Going to convert document batch...
2025-11-08 18:41:47,949 - INFO - Initializing pipeline for StandardPdfPipeline with options hash f9730ffaa6e7f8d4fb0c98c8df3f18cb
2025-11-08 18:41:47,960 - INFO - Loading plugin 'docling_defaults'
2025-11-08 18:41:47,963 - INFO - Registered picture descriptions: ['vlm', 'api']
2025-11-08 18:41:47,974 - INFO - Loading plugin 'docling_defaults'
2025-11-08 18:41:47,979 - INFO - Registered ocr engines: ['auto', 'easyocr', 'ocrmac', 'rapidocr', 'tesserocr', 'tesseract']
2025-11-08 18:41:47,994 - INFO - rapidocr cannot be used because onnxruntime is not installed.
2025-11-08 18:41:47,994 - INFO - easyocr cannot be used because it is not installed.
2025-11-08 18:41:48,151 - INFO - Accelerator device: 'cpu'
[INFO] 2025-11-08 18:41:48,160 [RapidOCR] base.py:22: Using engine_name: torch
[INFO] 2025-11-08 18:41:48,174 [RapidOCR] download_file.py:60: File exists and is valid: C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_det_infer.pth
[INFO] 2025-11-08 18:41:48,175 [RapidOCR] torch.py:54: Using C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_det_infer.pth
[INFO] 2025-11-08 18:41:48,384 [RapidOCR] base.py:22: Using engine_name: torch
[INFO] 2025-11-08 18:41:48,386 [RapidOCR] download_file.py:60: File exists and is valid: C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_ptocr_mobile_v2.0_cls_infer.pth
[INFO] 2025-11-08 18:41:48,386 [RapidOCR] torch.py:54: Using C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_ptocr_mobile_v2.0_cls_infer.pth
[INFO] 2025-11-08 18:41:48,428 [RapidOCR] base.py:22: Using engine_name: torch
[INFO] 2025-11-08 18:41:48,442 [RapidOCR] download_file.py:60: File exists and is valid: C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_infer.pth
ages\rapidocr\models\ch_ptocr_mobile_v2.0_cls_infer.pth
[INFO] 2025-11-08 18:41:48,428 [RapidOCR] base.py:22: Using engine_name: torch
[INFO] 2025-11-08 18:41:48,442 [RapidOCR] download_file.py:60: File exists and is valid: C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_infer.pth
[INFO] 2025-11-08 18:41:48,428 [RapidOCR] base.py:22: Using engine_name: torch
[INFO] 2025-11-08 18:41:48,442 [RapidOCR] download_file.py:60: File exists and is valid: C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_infer.pth
n\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_infer.pth
[INFO] 2025-11-08 18:41:48,442 [RapidOCR] torch.py:54: Using C:\project_python\docling\venv\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_infer.pth
2025-11-08 18:41:48,564 - INFO - Auto OCR model selected rapidocr with torch.
2025-11-08 18:41:48,571 - INFO - Accelerator device: 'cpu'
2025-11-08 18:41:49,961 - INFO - Accelerator device: 'cpu'
2025-11-08 18:41:50,227 - INFO - Processing document 2408.09869v5.pdf
2025-11-08 18:42:53,559 - INFO - Finished converting document 2408.09869v5.pdf in 66.58 sec.
결과가 result20251108_184253.txt에 저장되었습니다.

 

[결과 문서]  result20251108_184253.txt

<!-- image -->

## Docling Technical Report

## Version 1.0

Christoph Auer Maksym Lysak Ahmed Nassar Michele Dolfi Nikolaos Livathinos Panos Vagenas Cesar Berrospi Ramis Matteo Omenetti Fabian Lindlbauer Kasper Dinkla Lokesh Mishra Yusik Kim Shubham Gupta Rafael Teixeira de Lima Valery Weber Lucas Morin Ingmar Meijer Viktor Kuropiatnyk Peter W. J. Staar

AI4K Group, IBM Research R¨ uschlikon, Switzerland

## Abstract

This technical report introduces Docling , an easy to use, self-contained, MITlicensed open-source package for PDF document conversion. It is powered by state-of-the-art specialized AI models for layout analysis (DocLayNet) and table structure recognition (TableFormer), and runs efficiently on commodity hardware in a small resource budget. The code interface allows for easy extensibility and addition of new features and models.

## 1 Introduction

 

<중간 생략>

 

Table 1: Runtime characteristics of Docling with the standard model pipeline and settings, on our test dataset of 225 pages, on two different systems. OCR is disabled. We show the time-to-solution (TTS), computed throughput in pages per second, and the peak memory used (resident set size) for both the Docling-native PDF backend and for the pypdfium backend, using 4 and 16 threads.

| CPU                     | Thread budget   | native backend   | native backend   | native backend   | pypdfium backend   | pypdfium backend   | pypdfium backend   |
|-------------------------|-----------------|------------------|------------------|------------------|--------------------|--------------------|--------------------|
|                         |                 | TTS              | Pages/s          | Mem              | TTS                | Pages/s            | Mem                |
| Apple M3 Max (16 cores) | 4 16            | 177 s 167 s      | 1.27 1.34        | 6.20 GB          | 103 s 92 s         | 2.18 2.45          | 2.56 GB            |
| Intel(R) Xeon E5-2690   | 4 16            | 375 s 244 s      | 0.60 0.92        | 6.16 GB          | 239 s 143 s        | 0.94 1.57          | 2.42 GB            |

## 5 Applications

Thanks to the high-quality, richly structured document conversion achieved by Docling, its output qualifies for numerous downstream applications. For example, Docling can provide a base for detailed enterprise document search, passage retrieval or classification use-cases, or support knowledge extraction pipelines, allowing specific treatment of different structures in the document, such as tables, figures, section structure or references. For popular generative AI application patterns, such as retrieval-augmented generation (RAG), we provide quackling , an open-source package which capitalizes on Docling's feature-rich document output to enable document-native optimized vector embedding and chunking. It plugs in seamlessly with LLM frameworks such as LlamaIndex [8]. Since Docling is fast, stable and cheap to run, it also makes for an excellent choice to build document-derived datasets. With its powerful table structure recognition, it provides significant benefit to automated knowledge-base construction [11, 10]. Docling is also integrated within the open IBM data prep kit [6], which implements scalable data transforms to build large-scale multi-modal training datasets.

 

<중간 생략>

 

Author

Affiliation

teria for documents were described in Section 3. A large effort went into ensuring that all documents are free to use. The data sources in DocBank, are often only distinguishable by discriminating on 3 https://arxiv.org/ Figure 4: Table 1 from the DocLayNet paper in the original PDF (A), as rendered Markdown (B) and in JSON representation (C). Spanning table cells, such as the multi-column header 'triple interannotator mAP@0.5-0.95 (%)', is repeated for each column in the Markdown representation (B), which guarantees that every data point can be traced back to row and column headings only by its grid coordinates in the table. In the JSON representation, the span information is reflected in the fields of each table cell (C).

and

, as seen

Phase 1: Data selection and preparation.

Our inclusion cri-

<끝>

 

반응형

+ Recent posts