표가 포함된 PDF에서 RAG가 정답을 놓치지 않도록
Docling으로 파싱한 PDF의 표·캡션·설명 단락을 하나의 검색 단위(Evidence Unit)로 묶어 RAG 정답률을 높이는 파이썬 라이브러리입니다.
RAG 파이프라인에서 표가 포함된 PDF는 정답률이 유독 낮다. 원인은 파싱이 아니라 청킹이다.
Docling은 표와 캡션을 정확히 인식하고 연결까지 하지만(table.captions), 청킹 단계에서 이 연결이 다시 끊어진다.
flowchart LR
subgraph HC["Docling HybridChunker"]
direction TB
C1["캡션<br/>'Table 3: 지역별 매출'"]
C2["표 데이터<br/>지역 · Q1 · Q2 ..."]
C3["각주<br/>'(단위: 백만 달러)'"]
C4["설명 단락<br/>'서울은 신규 지점 2곳 개점 영향으로...'"]
end
EU["Evidence Chunker<br/>캡션 + 표 데이터 + 각주 + 설명<br/><b>하나의 검색 단위로 통합</b>"]
C1 -.-> EU
C2 -.-> EU
C3 -.-> EU
C4 -.-> EU
style HC fill:transparent,stroke:transparent,stroke-width:1.5px,color:#2E3440
style C1 fill:#ECEFF4,stroke:#D08770,stroke-width:1px,color:#2E3440
style C2 fill:#ECEFF4,stroke:#D08770,stroke-width:1px,color:#2E3440
style C3 fill:#ECEFF4,stroke:#D08770,stroke-width:1px,color:#2E3440
style C4 fill:#ECEFF4,stroke:#D08770,stroke-width:1px,color:#2E3440
style EU fill:#88C0D0,stroke:#5E81AC,stroke-width:2.5px,color:#2E3440
flowchart LR
PDF([PDF]) --> Docling[Docling]
Docling --> Parser[Parser]
Parser --> Chunker["EvidenceChunker"]
Chunker --> Split[Split]
Split --> Export[Export]
Export --> RAG([RAG])
%% GitHub 호환용 Nord Deep 스타일 지정
style PDF fill:#EBCB8B,stroke:#D08770,stroke-width:1.5px,color:#2E3440
style Docling fill:#E5E9F0,stroke:#8FBCBB,stroke-width:1.5px,color:#3B4252
style Parser fill:#D8DEE9,stroke:#4C566A,stroke-width:1.5px,color:#2E3440
style Chunker fill:#88C0D0,stroke:#5E81AC,stroke-width:2.5px,color:#2E3440
style Split fill:#A3BE8C,stroke:#4C566A,stroke-width:1.5px,color:#2E3440
style Export fill:#B48EAD,stroke:#4C566A,stroke-width:1.5px,color:#2E3440
style RAG fill:#EBCB8B,stroke:#D08770,stroke-width:1.5px,color:#2E3440
Docling HybridChunker는, 표 숫자와 설명 단락이 함께 있어야 풀리는 질문이 들어오면, 캡션·표·설명이 서로 다른 청크에 흩어져 있어 하나의 청크만으로는 답을 구성할 수 없다는 구조적 문제가 있다.
이에, Evidence Chunker는 같은 표의 캡션+숫자+각주+설명을 한 청크(EU)로 묶어 반환한다. Docling의 강력한 기능(파싱, 레이아웃 분석, 캡션-표 연결)은 사용하되, Docling만으로는 해결되지 않는 문제(청킹 단계에서 캡션·표·문맥이 다시 갈라지는 문제)를 해결한다.
Evidence Chunker는 같은 536문항에서 baseline 대비 정답을 188개까지 끌어올린다(EM 35.1%, +34.2pp). 자세한 유형별·대조군 수치는 Benchmark 참고.
90개 PDF, 2,725문항 기준(baseline: Docling HybridChunker 단독)
| 지표 | baseline | Evidence Chunker | 갭 |
|---|---|---|---|
| Recall | 0.574 | 0.625 | +5.1pp |
| EM | 0.314 | 0.569 | +25.5pp |
| repository | 비고 |
|---|---|
| Evidence-Chunker | 메인 라이브러리 (pip install evidence-chunker) |
| Wiki | 위키 |
Apache License 2.0