<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sure Sai Venkata Krishna Sahit on Medium]]></title>
        <description><![CDATA[Stories by Sure Sai Venkata Krishna Sahit on Medium]]></description>
        <link>https://medium.com/@sahitssvk?source=rss-20ee7660c1f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p6bWJ5XaMF69gebZT7eDfw.png</url>
            <title>Stories by Sure Sai Venkata Krishna Sahit on Medium</title>
            <link>https://medium.com/@sahitssvk?source=rss-20ee7660c1f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:09:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sahitssvk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Preserving Document Hierarchy and Context with Docling Hierarchical Chunking]]></title>
            <link>https://medium.com/@sahitssvk/preserving-document-hierarchy-and-context-with-docling-hierarchical-chunking-c25cd404ecde?source=rss-20ee7660c1f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c25cd404ecde</guid>
            <category><![CDATA[herierachial-chunking]]></category>
            <category><![CDATA[docling]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[retrieval]]></category>
            <dc:creator><![CDATA[Sure Sai Venkata Krishna Sahit]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 08:56:58 GMT</pubDate>
            <atom:updated>2026-11-06T08:56:58.874Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Retrieval quality is often limited not by the retriever itself, but by how documents are chunked before indexing.</em></blockquote><p>One of the most common causes of poor Retrieval-Augmented Generation (RAG) performance is the loss of structural context during ingestion. Information that was originally organized under a meaningful hierarchy of sections, subsections, lists, and procedural steps is frequently fragmented into isolated chunks that no longer retain their relationships.</p><p>This issue is closely related to the <em>*”lost in the middle”*</em> problem, where relevant information exists within retrieved content but lacks the surrounding context necessary for the model to generate a correct response.</p><p>Many RAG implementations attempt to address this challenge by increasing chunk sizes, adding overlap, or introducing reranking layers. While these techniques may improve recall, they do not preserve the original document structure. A paragraph extracted from an installation guide becomes significantly less useful when detached from its prerequisite section, configuration details, or validation steps.</p><p>To address this limitation, our ingestion pipeline leverages <strong>**Docling’s structural chunking capabilities**</strong> and extends them with a <strong>**two-level parent-child architecture**</strong> that preserves document hierarchy throughout indexing and retrieval.</p><p><strong>— -</strong></p><p><strong>## Why Fixed-Size Token Chunking Falls Short</strong></p><p>A common approach in RAG systems is fixed-size token chunking, for example:</p><p>* 512-token chunks</p><p>* 50-token overlap</p><p>* Sliding window segmentation</p><p>Although simple to implement, this strategy introduces several structural problems.</p><p><strong>### Arbitrary Semantic Boundaries</strong></p><p>Chunks are often split when a token threshold is reached rather than when a logical section ends. As a result, paragraphs, procedural instructions, tables, and code blocks can be fragmented mid-context.</p><p><strong>### Context Leakage Across Topics</strong></p><p>A single chunk may begin in one section and end in another. For example, content from <strong>**”Prerequisites”**</strong> can be merged with <strong>**”Troubleshooting”**</strong>, creating an unintuitive retrieval unit that mixes unrelated concepts.</p><p><strong>### Loss of Hierarchical Context</strong></p><p>Traditional chunks typically store only text content. They do not retain information about the chapter, section, or subsection from which the content originated.</p><p><strong>### No Relationship Between Neighboring Chunks</strong></p><p>Once indexed, chunks become independent retrieval units. There is no awareness of preceding or succeeding sections, making contextual expansion difficult during retrieval.</p><p>These limitations frequently reduce retrieval precision, especially for technical documentation, user manuals, and structured knowledge repositories.</p><p><strong>— -</strong></p><p><strong>## Structural Chunking with Docling</strong></p><p>Instead of chunking solely based on token counts, our pipeline uses the document structure produced by <strong>**DoclingDocument**</strong>, the core document representation generated by Docling.</p><p>Docling provides multiple chunking strategies through <strong>**docling-core**</strong>, each designed to preserve document semantics during segmentation.</p><p><strong>### HierarchicalChunker</strong></p><p>The <strong>**HierarchicalChunker**</strong> is used when embeddings are not required and retrieval is performed through lexical methods such as BM25.</p><p>Rather than splitting based on arbitrary token limits, the chunker follows the document’s structural hierarchy:</p><p>* Section headings</p><p>* Subheadings</p><p>* Paragraph boundaries</p><p>* Lists</p><p>* Other semantic document elements</p><p>Every generated chunk preserves its heading ancestry, allowing downstream systems to understand where that chunk lives within the broader document hierarchy.</p><p>Example metadata:</p><p>```python</p><p>chunk.meta.headings = [</p><p>“1. System Architecture”,</p><p>“1.2 Infrastructure Setup”,</p><p>“1.2.3 Network Configuration”</p><p>]</p><p>```</p><p>This metadata provides valuable context during retrieval and ranking because each chunk remains associated with its parent sections.</p><p>The `HierarchicalChunker` in <strong>**docling-core**</strong> operates on the document’s structured representation rather than raw text tokens. This enables chunk boundaries to align with author-defined sections, significantly improving retrieval relevance and contextual integrity.</p><p>References:</p><p>* Docling Chunking Concepts: <a href="https://docling-project.github.io/docling/concepts/chunking/">https://docling-project.github.io/docling/concepts/chunking/</a></p><p>* HierarchicalChunker Source: <a href="https://github.com/docling-project/docling-core">https://github.com/docling-project/docling-core</a></p><p><strong>### HybridChunker</strong></p><p>For embedding-based pipelines and structured datasets such as CSV and XLSX documents, we use Docling’s <strong>**HybridChunker**</strong>.</p><p>Unlike the HierarchicalChunker, the HybridChunker balances structural preservation with token-budget constraints required by embedding models:</p><p>```python</p><p>from docling.chunking import HybridChunker</p><p>from transformers import AutoTokenizer</p><p>tokenizer = AutoTokenizer.from_pretrained(</p><p>“sentence-transformers/all-MiniLM-L6-v2”</p><p>)</p><p>child_chunker = HybridChunker(</p><p>tokenizer=tokenizer,</p><p>max_tokens=512,</p><p>merge_peers=True</p><p>)</p><p>```</p><p>Key advantages include:</p><p>* Respecting embedding-model token limits</p><p>* Preserving document structure</p><p>* Supporting tabular content</p><p>* Merging related sibling paragraphs through `merge_peers=True`</p><p>The peer-merging capability helps reduce over-fragmentation by consolidating small adjacent sections under the same heading until the token budget is reached.</p><p>Modern embedding models have strict token constraints. The HybridChunker allows documents to remain structurally coherent while still fitting within embedding model limits. This becomes especially valuable when processing large technical manuals, reports, spreadsheets, and knowledge bases where semantic continuity is critical.</p><p>References:</p><p>* Hybrid Chunking Documentation: <a href="https://docling-project.github.io/docling/concepts/chunking/">https://docling-project.github.io/docling/concepts/chunking/</a></p><p>* Docling GitHub Repository: <a href="https://github.com/docling-project/docling">https://github.com/docling-project/docling</a></p><p><strong>— -</strong></p><p><strong>## Building a Two-Level Parent-Child Document Graph</strong></p><p>Rather than treating each chunk as an isolated Elasticsearch document, we organize content into a hierarchical graph consisting of:</p><p>1. <strong>**Child Chunks:**</strong> Granular search units.</p><p>2. <strong>**Reference Map (Ref-Map) Parent Nodes:**</strong> Contextual containers.</p><p>This design preserves both granular searchability and broader contextual relationships.</p><p><strong>### Child Chunks</strong></p><p>Child chunks contain the actual searchable content. Each child record stores:</p><p>* Text content</p><p>* Heading hierarchy</p><p>* Page numbers</p><p>* Image references</p><p>* Sequential ordering information</p><p>* Parent identifiers</p><p>These chunks are indexed for BM25 retrieval and serve as the primary search units.</p><p><strong>### Ref-Map Parent Nodes</strong></p><p>Ref-map parents act as contextual containers. Unlike child chunks, they do not contain searchable body text. Instead, they maintain:</p><p>* Logical section boundaries</p><p>* Ordered child references</p><p>* Parent-level metadata</p><p>* Sibling relationships</p><p>Avoiding searchable text in parent nodes prevents keyword dilution and ensures retrieval relevance remains focused on meaningful content. The parent structure becomes particularly useful for contextual expansion after the initial retrieval phase.</p><p><strong>— -</strong></p><p><strong>## Parent Grouping and Section Partitioning</strong></p><p>To construct the parent-child hierarchy, consecutive child chunks are grouped according to predefined boundary conditions:</p><p>```python</p><p>for child in children:</p><p>flush = False</p><p>if heading_text in section_boundary_headings:</p><p>flush = True</p><p>elif boundary_pattern and boundary_pattern.search(heading_text):</p><p>flush = True</p><p>elif (</p><p>current_group_word_count + child.word_count</p><p>&gt; ref_map_max_tokens</p><p>):</p><p>flush = True</p><p>```</p><p>Grouping boundaries are triggered through three primary mechanisms:</p><p>1. <strong>**Section Boundary Headings:**</strong> Specific headings such as <em>*Chapter*</em>, <em>*Section*</em>, or <em>*Appendix*</em> can explicitly trigger the creation of a new parent node.</p><p>2. <strong>**Pattern-Based Rules:**</strong> Regular expressions can identify structured numbering systems (e.g. `^(Chapter|Section)\s+\d+`), enabling automatic section detection across documents with consistent formatting.</p><p>3. <strong>**Context Window Constraints:**</strong> Parent groups are additionally constrained by configurable size limits (e.g. `ref_map_max_tokens = 2048`). This prevents a single contextual grouping from growing beyond what can be effectively utilized during retrieval and LLM response generation.</p><p><strong>— -</strong></p><p><strong>## Reducing Retrieval Noise with Heading Filters</strong></p><p>Technical documents often contain pages that contribute little value to retrieval, including:</p><p>* Cover pages</p><p>* Copyright notices</p><p>* Tables of contents</p><p>* Trademark disclosures</p><p>* Indexes</p><p>* Author listings</p><p>Indexing this content can pollute retrieval results and reduce ranking effectiveness.</p><p>To mitigate this issue, we apply a pre-index filtering stage:</p><p>```python</p><p>SKIP_HEADINGS = {</p><p>“front cover”,</p><p>“contents”,</p><p>“table of contents”,</p><p>“notices”,</p><p>“preface”,</p><p>“trademarks”,</p><p>“index”,</p><p>“back cover”,</p><p>“authors”</p><p>}</p><p>```</p><p>Chunks associated with these headings are removed before the parent-child graph is constructed. This ensures Elasticsearch indexes only knowledge-bearing content and avoids wasting retrieval capacity on boilerplate sections.</p><p><strong>— -</strong></p><p><strong>## Elasticsearch Schema Design</strong></p><p>Both child chunks and parent nodes are stored within a unified Elasticsearch index:</p><p>```json</p><p>{</p><p>“chunk_type”: “keyword”,</p><p>“chunk_id”: “keyword”,</p><p>“parent_id”: “keyword”,</p><p>“child_ids”: “keyword”,</p><p>“chunk_index”: “integer”,</p><p>“page_numbers”: “integer”,</p><p>“headings”: {</p><p>“type”: “text”,</p><p>“fields”: {</p><p>“keyword”: {</p><p>“type”: “keyword”</p><p>}</p><p>}</p><p>}</p><p>}</p><p>```</p><p>Several mapping optimizations improve retrieval efficiency:</p><p>* <strong>**`child_ids`:**</strong> Stored as keyword arrays for efficient batch lookups during contextual expansion.</p><p>* <strong>**`headings`:**</strong> Indexed both as full-text fields for semantic discovery and keyword fields for exact hierarchy filtering.</p><p>* <strong>**`image_refs`:**</strong> Configured with `”index”: false` to minimize storage and indexing overhead, since image retrieval is handled through chunk associations rather than direct search queries.</p><p><strong>— -</strong></p><p><strong>## Why This Architecture Improves Retrieval</strong></p><p>Traditional retrieval approaches optimize for chunk-level relevance. However, users rarely require isolated paragraphs. They need the surrounding context that gives those paragraphs meaning.</p><p>The hierarchical architecture solves this by combining:</p><p>* Precision retrieval at the child level</p><p>* Context preservation at the parent level</p><p>* Structural awareness through heading ancestry</p><p>* Dynamic expansion through sibling relationships</p><p>The result is a retrieval pipeline that can return both the exact answer and the contextual information needed to interpret it correctly.</p><p><strong>— -</strong></p><p><strong>## Conclusion</strong></p><p>Hierarchical chunking bridges the gap between fine-grained text retrieval and document-level understanding.</p><p>By combining <strong>**Docling’s structural chunking capabilities**</strong> with a custom <strong>**parent-child contextual graph**</strong>, we gain several advantages:</p><p>* Fine-grained searchable child chunks</p><p>* Preservation of document hierarchy through heading ancestry</p><p>* Context expansion using sibling relationships</p><p>* Reduced retrieval noise through structural filtering</p><p>* Improved retrieval quality for technical documentation and enterprise knowledge bases</p><p>Rather than treating documents as isolated blocks of text, this approach retains the organizational intent defined by the original author. The result is a retrieval system that is both context-aware and structurally grounded, providing a stronger foundation for production-grade RAG applications.</p><p><strong>— -</strong></p><p><strong>## References</strong></p><p><strong>### Docling</strong></p><p>1. <strong>**IBM Docling Documentation:**</strong> <a href="https://docling-project.github.io/docling/">https://docling-project.github.io/docling/</a></p><p>2. <strong>**Docling GitHub Repository:**</strong> <a href="https://github.com/docling-project/docling">https://github.com/docling-project/docling</a></p><p>3. <strong>**Docling Chunking Concepts:**</strong> <a href="https://docling-project.github.io/docling/concepts/chunking/">https://docling-project.github.io/docling/concepts/chunking/</a></p><p>4. <strong>**docling-core Repository:**</strong> <a href="https://github.com/docling-project/docling-core">https://github.com/docling-project/docling-core</a></p><p>5. <strong>**HierarchicalChunker Documentation:**</strong> <a href="https://github.com/docling-project/docling-core/tree/main/docling_core/transforms/chunker">https://github.com/docling-project/docling-core/tree/main/docling_core/transforms/chunker</a></p><p><strong>### Retrieval-Augmented Generation</strong></p><p>6. <strong>**Lewis et al. (2020).**</strong> <em>*Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.*</em> <a href="https://arxiv.org/abs/2005.11401">https://arxiv.org/abs/2005.11401</a></p><p>7. <strong>**Liu et al. (2024).**</strong> <em>*Lost in the Middle: How Language Models Use Long Contexts.*</em> <a href="https://arxiv.org/abs/2307.03172">https://arxiv.org/abs/2307.03172</a></p><p><strong>### Elasticsearch</strong></p><p>8. <strong>**Elasticsearch Official Documentation:**</strong> <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html</a></p><p>9. <strong>**Elasticsearch Mapping Documentation:**</strong> <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html</a></p><p><strong>— -</strong></p><p><strong>## What’s Next?</strong></p><p>With document hierarchy preserved and chunks indexed into a parent-child graph, we can now execute high-precision searches.</p><p>In <strong>**Part 4**</strong>, we’ll explore exact keyword search with BM25, dynamic sibling expansion, and cross-encoder reranking — building a fast, accurate, vectorless retrieval pipeline.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c25cd404ecde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand: Transforming Documents into Structured Intelligence with Docling]]></title>
            <link>https://medium.com/@sahitssvk/understand-transforming-documents-into-structured-intelligence-with-docling-1c886f1a0325?source=rss-20ee7660c1f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c886f1a0325</guid>
            <category><![CDATA[docling]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[chunking]]></category>
            <category><![CDATA[chunking-strategies]]></category>
            <category><![CDATA[semantic-chunking]]></category>
            <dc:creator><![CDATA[Sure Sai Venkata Krishna Sahit]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 08:55:21 GMT</pubDate>
            <atom:updated>2026-11-06T08:55:21.717Z</atom:updated>
            <content:encoded><![CDATA[<p>When traditional text extraction tools flatten everything into plain text, much of this information is lost. Tables become misaligned text, section boundaries disappear, and content that originally belonged together becomes disconnected.</p><p>As a result, downstream retrieval systems lose important context.</p><p>Questions such as:</p><p>&gt; “What configuration steps belong to Network Setup?”</p><p>or</p><p>&gt; “What does the architecture diagram describe?”</p><p>become harder to answer because the relationships between content elements have already been discarded.</p><p>Docling addresses this challenge by preserving both the content and the structure of a document throughout the processing lifecycle.</p><p><strong>— -</strong></p><p><strong>## Introducing the Docling Document Model</strong></p><p>At the heart of Docling is the <strong>**DoclingDocument**</strong>, a unified document representation designed to capture both textual content and document semantics.</p><p>Rather than producing a single block of text, Docling transforms a document into a collection of typed elements that represent its structural components:</p><p>* Section headers</p><p>* Paragraphs</p><p>* Tables</p><p>* Images and figures</p><p>* Lists</p><p>* Code blocks</p><p>* Metadata and provenance information</p><p>Each component is represented as a structured object instead of a plain-text fragment. This allows downstream systems to understand <em>*what*</em> content exists and <em>*where*</em> it fits within the larger document hierarchy.</p><p>&gt; <strong>**About the examples.**</strong> Every snippet and output in this article was run against <strong>**Docling 2.147.0**</strong> (`docling-core` 2.106.0) on one real document: the research paper <em>*DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis*</em> (Pfitzmann, Auer, Dolfi, Nassar, Staar; KDD ‘22). It is a 9-page, two-column PDF with tables, figures, and lists, so it exercises the hard cases. Source: [arxiv.org/pdf/2206.01062](https://arxiv.org/pdf/2206.01062). Downloaded as `2206.01062v1.pdf`. Your numbers will differ on other documents, but the shapes will match.</p><p><strong>### Your First DoclingDocument</strong></p><p>Converting a file takes a few lines. The converter picks the right parsing backend from the file type and always returns the same object:</p><p>```python</p><p>from docling.document_converter import DocumentConverter</p><p>converter = DocumentConverter()</p><p>result = converter.convert(“2206.01062v1.pdf”) # also accepts a URL or Path</p><p>doc = result.document # a DoclingDocument</p><p>print(doc.name) # file name without extension</p><p>print(len(doc.texts)) # headings, paragraphs, captions, list items, …</p><p>print(len(doc.tables)) # structured tables</p><p>print(len(doc.pictures)) # figures and images</p><p>print(len(doc.pages)) # pages</p><p>```</p><p>```text</p><p>2206.01062v1</p><p>514</p><p>5</p><p>6</p><p>9</p><p>```</p><p>Nine pages produced 5 tables and 6 pictures. The 514 text items deserve a note: 392 of them are text that Docling read <em>*inside*</em> the six pictures (284 in Figure 1 alone, a collage of four page thumbnails). They belong to their pictures, and `doc.iterate_items()` skips them by default, so a walk over the document sees 128 items instead of 514.</p><p><strong>### What the Structure Looks Like</strong></p><p>A `DoclingDocument` is a tree of typed items, not a flat string. `print_element_tree()` shows the items in reading order. The full output is over 500 lines (it includes the text read inside the figures), so here is the excerpt around the start of Section 3:</p><p>```python</p><p>doc.print_element_tree() # prints the whole tree; the excerpt below is trimmed</p><p>```</p><p>```text</p><p>322: text: Lately, new types of ML models for document-layout analysis have emerged in the community [18–21]. T</p><p>323: section_header: 3 THE DOCLAYNET DATASET</p><p>324: text: DocLayNet contains 80863 PDF pages. Among these, 7059 carry two instances of human annotations, and</p><p>325: text: In addition to open intellectual property constraints for the source documents, we required that the</p><p>326: page_header: DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis KDD ’22, August 14–18, 2022,</p><p>327: picture</p><p>328: caption: Figure 2: Distribution of DocLayNet pages across document categories.</p><p>```</p><p>Three things are visible here:</p><p>* The heading is typed as a `section_header`, not just a line of text.</p><p>* The running page header that interrupted the body at the page break is tagged `page_header`, so it can be filtered out.</p><p>* The figure’s caption is attached to its picture (indented one level) instead of floating as a stray paragraph.</p><p>Behind the tree, the document keeps each kind of item in its own collection, and the body refers to them by reference:</p><p>```text</p><p>DoclingDocument</p><p>├── body ← reading-order tree of references (#/texts/0, #/tables/0, …)</p><p>├── furniture ← page headers and footers kept out of the main flow</p><p>├── texts[] ← headings, paragraphs, list items, code, captions</p><p>├── tables[] ← cell grid, spans, captions</p><p>├── pictures[] ← image reference, captions</p><p>└── pages{} ← page size and number</p><p>```</p><p>Here is the “3 THE DOCLAYNET DATASET” heading as it appears in `doc.export_to_dict()[“texts”]`:</p><p>```json</p><p>{</p><p>“self_ref”: “#/texts/319”,</p><p>“parent”: { “$ref”: “#/body” },</p><p>“children”: [],</p><p>“content_layer”: “body”,</p><p>“label”: “section_header”,</p><p>“prov”: [</p><p>{</p><p>“page_no”: 2,</p><p>“bbox”: { “l”: 317.955, “t”: 225.742, “r”: 477.457, “b”: 216.675, “coord_origin”: “BOTTOMLEFT” },</p><p>“charspan”: [0, 23]</p><p>}</p><p>],</p><p>“orig”: “3 THE DOCLAYNET DATASET”,</p><p>“text”: “3 THE DOCLAYNET DATASET”,</p><p>“level”: 1</p><p>}</p><p>```</p><p>Every item carries its <strong>**type**</strong> (`label`), its <strong>**place in the hierarchy**</strong> (`parent`, `children`), its <strong>**content**</strong> (`text`), and its <strong>**location**</strong> (`prov`). Those are what a flat text dump throws away.</p><p><strong>— -</strong></p><p><strong>## Understanding Documents Beyond Text</strong></p><p>One of Docling’s key advantages is its ability to preserve document semantics.</p><p>Instead of treating all extracted content equally, Docling recognizes that different content types serve different purposes.</p><p><strong>### Section Headers</strong></p><p>Headers establish document hierarchy and topic boundaries.</p><p>Docling identifies headings and associates them with nesting levels, enabling AI systems to understand how sections relate to one another.</p><p>For PDFs there is one setting to know about. The layout model detects that a block is a heading but not how deep it sits, so by default every PDF heading comes back as level 1. Turning on `HeadingHierarchyOptions` makes Docling assign levels from bookmarks, numbering, and font style (more on this in the PDF section below):</p><p>```python</p><p>from docling.datamodel.base_models import InputFormat</p><p>from docling.datamodel.pipeline_options import PdfPipelineOptions, HeadingHierarchyOptions</p><p>from docling.document_converter import DocumentConverter, PdfFormatOption</p><p>from docling_core.types.doc import SectionHeaderItem</p><p>opts = PdfPipelineOptions(</p><p>heading_hierarchy_options=HeadingHierarchyOptions(enabled=True)</p><p>)</p><p>converter = DocumentConverter(</p><p>format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=opts)}</p><p>)</p><p>doc = converter.convert(“2206.01062v1.pdf”).document</p><p>for item, _ in doc.iterate_items():</p><p>if isinstance(item, SectionHeaderItem):</p><p>print(f”{‘ ‘ * (item.level — 1)}[H{item.level}] {item.text} (p.{item.prov[0].page_no})”)</p><p>```</p><p>Output outline recovered from the paper:</p><p>```text</p><p>[H1] DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis (p.1)</p><p>[H2] KEYWORDS (p.1)</p><p>[H4] ACM Reference Format: (p.1)</p><p>[H1] ABSTRACT (p.1)</p><p>[H2] CCS CONCEPTS (p.1)</p><p>[H1] 1 INTRODUCTION (p.2)</p><p>[H1] 2 RELATEDWORK (p.2)</p><p>[H1] 3 THE DOCLAYNET DATASET (p.2)</p><p>[H1] 4 ANNOTATIONCAMPAIGN (p.3)</p><p>[H1] 5 EXPERIMENTS (p.6)</p><p>[H3] Baselines for Object Detection (p.6)</p><p>[H3] Learning Curve (p.7)</p><p>[H3] Impact of Class Labels (p.7)</p><p>[H3] Impact of Document Split in Train and Test Set (p.7)</p><p>[H3] Dataset Comparison (p.7)</p><p>[H3] Example Predictions (p.8)</p><p>[H1] 6 CONCLUSION (p.8)</p><p>[H1] REFERENCES (p.8)</p><p>```</p><p>The six experiment subsections nest under “5 EXPERIMENTS” and carry page numbers. Note two things about real output: words like `RELATEDWORK` come out exactly as the PDF’s text layer has them (the space is missing in the source), and levels are inferred, so they are good but not infallible. Here the subsections land at level 3 rather than 2, and “ACM Reference Format:” is placed at level 4. The <em>*relative*</em> order is right, and that is what section paths need.</p><p><strong>### Tables</strong></p><p>Tables often contain highly structured information that loses meaning when converted into plain text.</p><p>Docling reconstructs table structures, preserving rows, columns, spans, and associated metadata so that tabular content remains usable for downstream processing.</p><p>The paper’s Table 2 (page 6) compares object-detection models. On the page it sits beside a chart, in a two-column layout. A plain text extractor (here `pdftotext`, without layout mode) reads it by columns and detaches the labels from the numbers:</p><p>```text</p><p>human Caption Footnote Formula List-item Page-footer Page-header Picture Section-header Table Text Title All</p><p>84–89 83–91 83–85 87–88 93–94 85–89 69–71 83–84 77–81 84–86 60–72 82–83</p><p>MRCNN R50 R101 68.4 71.5 70.9 71.8 60.1 63.4 81.2 80.8 …</p><p>```</p><p>Nothing in that output says that `Caption` goes with `84–89` and `68.4`. Docling keeps the grid:</p><p>```python</p><p>table = doc.tables[1]</p><p>print(table.data.num_rows, table.data.num_cols) # 14 6</p><p>print(table.export_to_markdown(doc=doc)) # ready to drop into an LLM prompt</p><p>```</p><p>```text</p><p>Table 2: Prediction performance (mAP@0.5–0.95) of object detection networks on DocLayNet test set. …</p><p>| | human | MRCNN — R50 | MRCNN — R101 | FRCNN — R101 | YOLO — v5x6 |</p><p>| — — — — — — — — | — — — — -| — — — — — — — -| — — — — — — — — | — — — — — — — — | — — — — — — — -|</p><p>| Caption | 84–89 | 68.4 | 71.5 | 70.1 | 77.7 |</p><p>| Footnote | 83–91 | 70.9 | 71.8 | 73.7 | 77.2 |</p><p>| Formula | 83–85 | 60.1 | 63.4 | 63.5 | 66.2 |</p><p>| List-item | 87–88 | 81.2 | 80.8 | 81.0 | 86.2 |</p><p>| Page-footer | 93–94 | 61.6 | 59.3 | 58.9 | 61.1 |</p><p>| Page-header | 85–89 | 71.9 | 70.0 | 72.0 | 67.9 |</p><p>| Picture | 69–71 | 71.7 | 72.7 | 72.0 | 77.1 |</p><p>| Section-header | 83–84 | 67.6 | 69.3 | 68.4 | 74.6 |</p><p>| Table | 77–81 | 82.2 | 82.9 | 82.2 | 86.3 |</p><p>| Text | 84–86 | 84.6 | 85.8 | 85.4 | 88.1 |</p><p>| Title | 60–72 | 76.7 | 80.4 | 79.9 | 82.7 |</p><p>| All | 82–83 | 72.4 | 73.5 | 73.4 | 76.8 |</p><p>```</p><p>The export includes the table’s caption above the grid. Notice the two-row header in the PDF (“MRCNN” over “R50”) has been merged into one header cell, `MRCNN — R50`.</p><p>For analysis, export to a pandas DataFrame:</p><p>```python</p><p>df = table.export_to_dataframe(doc=doc)</p><p>print(df.head(3))</p><p>print(df.shape)</p><p>```</p><p>```text</p><p>human. MRCNN.R50 MRCNN.R101 FRCNN.R101 YOLO.v5x6</p><p>0 Caption 84–89 68.4 71.5 70.1 77.7</p><p>1 Footnote 83–91 70.9 71.8 73.7 77.2</p><p>2 Formula 83–85 60.1 63.4 63.5 66.2</p><p>(12, 6)</p><p>```</p><p>Merged header cells become dotted column names such as `MRCNN.R50`, and the 12 data rows come through intact. Header handling depends on how each table is drawn, so check the first row and the column names of your own tables before relying on them.</p><p><strong>### Images and Figures</strong></p><p>Technical documents frequently include diagrams that contain critical context.</p><p>Docling identifies figures and images as distinct document elements, enabling organizations to retain visual content alongside textual explanations.</p><p>Picture items keep their caption and page, and can optionally keep the image itself:</p><p>```python</p><p>opts = PdfPipelineOptions(</p><p>heading_hierarchy_options=HeadingHierarchyOptions(enabled=True) # keep heading levels</p><p>)</p><p>opts.generate_picture_images = True # keep pixels, not just position</p><p>opts.images_scale = 2.0 # render at 2x for legibility</p><p>converter = DocumentConverter(</p><p>format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=opts)}</p><p>)</p><p>doc = converter.convert(“2206.01062v1.pdf”).document</p><p>for pic in doc.pictures:</p><p>caption = pic.caption_text(doc=doc)</p><p>image = pic.get_image(doc) # PIL.Image, or None if not generated</p><p>print(f”Page {pic.prov[0].page_no}: {caption[:48]!r} size={image.size}”)</p><p>```</p><p>```text</p><p>Page 1: ‘Figure 1: Four examples of complex page layouts ‘ size=(466, 562)</p><p>Page 3: ‘Figure 2: Distribution of DocLayNet pages across’ size=(350, 257)</p><p>Page 4: ‘Figure 3: Corpus Conversion Service annotation u’ size=(486, 460)</p><p>Page 5: ‘’ size=(499, 757)</p><p>Page 6: ‘Figure 5: Prediction performance (mAP@0.5–0.95) ‘ size=(464, 344)</p><p>Page 9: ‘Figure 6: Example layout predictions on selected ‘ size=(990, 728)</p><p>```</p><p>Five of the six figures arrive with their caption. The page 5 figure came back with an empty caption. The text “Figure 4: Examples of plausible annotation alternatives…” is present in the document as a `caption` item, but it was not linked to the picture. Caption matching is heuristic, so if captions matter to your use case, log pictures with no caption and review them.</p><p>An ingestion pipeline can store each image in object storage and index a text chunk containing the caption and a pointer to the image, so diagrams stay searchable.</p><p><strong>### Lists and Code Blocks</strong></p><p>Nested lists and code snippets are preserved as separate content types instead of being merged into surrounding paragraphs, helping maintain readability and contextual accuracy.</p><p>The paper’s introduction lists the dataset’s main features as bullet points. Docling returns them as `ListItem` objects:</p><p>```python</p><p>from docling_core.types.doc import ListItem</p><p>for item, depth in doc.iterate_items():</p><p>if isinstance(item, ListItem) and item.prov[0].page_no == 2:</p><p>print(f”- {item.text[:60]} [depth={depth}]”)</p><p>```</p><p>```text</p><p>- Human Annotation: In contrast to PubLayNet and DocBank, we r [depth=2]</p><p>- Large Layout Variability: We include diverse and complex lay [depth=2]</p><p>- Detailed Label Set: We define 11 class labels to distinguish [depth=2]</p><p>- Redundant Annotations: A fraction of the pages in the DocLay [depth=2]</p><p>- This enables experimentation with annotation uncertainty and [depth=2]</p><p>- Pre-defined Train-, Test- &amp; Validation-set: Like DocBank, we [depth=2]</p><p>```</p><p>For code blocks and nesting depth, Docling properly recognizes indentation and languages:</p><p>```python</p><p>from docling_core.types.doc import CodeItem, ListItem</p><p>md_doc = DocumentConverter().convert(“steps.md”).document</p><p>for item, depth in md_doc.iterate_items():</p><p>if isinstance(item, ListItem):</p><p>print(f”{‘ ‘ * depth}- {item.text} [depth={depth}]”)</p><p>elif isinstance(item, CodeItem):</p><p>print(f”[code:{item.code_language.value}]\n{item.text}”)</p><p>```</p><p>```text</p><p>- Open the admin console [depth=2]</p><p>- Select Network [depth=4]</p><p>- Select Interfaces [depth=2]</p><p>[code:Python]</p><p>print(“hello”)</p><p>```</p><p>The nested item sits deeper than its parent, and the code block arrives as a `CodeItem` with its language recorded, not as a paragraph.</p><p><strong>— -</strong></p><p><strong>## A Unified Model Across Multiple Document Formats</strong></p><p>Enterprise content rarely exists in a single format. Organizations manage information across:</p><p>* PDF documents</p><p>* Microsoft Word files</p><p>* PowerPoint presentations</p><p>* Excel spreadsheets</p><p>* HTML content</p><p>* Markdown files</p><p>* Plain text documents</p><p>Each format stores information differently, creating challenges for downstream applications.</p><p>Docling addresses this complexity by converting all supported formats into the same underlying document model. Regardless of whether the source is a PDF, a presentation deck, or a web page, downstream systems interact with a consistent structure.</p><p>The same code handles every format. Only the input path changes:</p><p>```python</p><p>converter = DocumentConverter()</p><p>for path in [“guide.pdf”, “guide.docx”, “guide.pptx”, “guide.html”, “guide.md”]:</p><p>d = converter.convert(path).document</p><p>headings = sum(1 for t in d.texts if t.label in (“section_header”, “title”))</p><p>print(f”{path:12} headings={headings:2} tables={len(d.tables):2} pictures={len(d.pictures):2}”)</p><p>```</p><p>```text</p><p>guide.pdf headings= 3 tables= 1 pictures= 1</p><p>guide.docx headings= 3 tables= 1 pictures= 1</p><p>guide.pptx headings= 1 tables= 1 pictures= 1</p><p>guide.html headings= 4 tables= 1 pictures= 1</p><p>guide.md headings= 3 tables= 1 pictures= 1</p><p>```</p><p>Five formats go in and the same `DoclingDocument` comes out, so chunking and indexing need no format-specific branches. Tables and pictures are found in every format.</p><p><strong>— -</strong></p><p><strong>## Intelligent Understanding for PDF Documents</strong></p><p>Among enterprise document formats, PDFs are often the most challenging.</p><p>Unlike HTML documents, PDFs typically contain visual layouts rather than explicit structural markup. A heading is not stored as an `&lt;h1&gt;` tag but simply as text rendered with a different style.</p><p>To reconstruct document structure, Docling combines multiple signals:</p><p>* Document bookmarks and outlines</p><p>* Section numbering patterns</p><p>* Typography characteristics</p><p>* Font sizes and styles</p><p>* Relative positioning on the page</p><p>Using these signals, Docling can infer hierarchical relationships between sections and rebuild the logical structure of a document.</p><p><strong>### Before and After</strong></p><p>The DocLayNet paper is a good test. It carries eight PDF bookmarks, all at the top level. The subsections inside “5 Experiments” have no bookmarks at all.</p><p>By default, Docling detects each heading but does not rank them, so every heading is level 1:</p><p>```text</p><p>[H1] 5 EXPERIMENTS</p><p>[H1] Baselines for Object Detection</p><p>[H1] Learning Curve</p><p>[H1] Impact of Class Labels</p><p>[H1] Impact of Document Split in Train and Test Set</p><p>[H1] Dataset Comparison</p><p>[H1] Example Predictions</p><p>[H1] 6 CONCLUSION</p><p>```</p><p>With heading-hierarchy inference enabled, bookmarks, numbering, and font style are combined to rebuild the outline:</p><p>```python</p><p>from docling.datamodel.pipeline_options import PdfPipelineOptions, HeadingHierarchyOptions</p><p>opts = PdfPipelineOptions(</p><p>heading_hierarchy_options=HeadingHierarchyOptions(</p><p>enabled=True, # off by default</p><p>use_bookmarks=True, # trust the PDF outline when it matches a heading</p><p>use_numbering=True, # 1 -&gt; 1.1 -&gt; 1.1.1</p><p>use_style=True, # font size and weight as a fallback</p><p>)</p><p>)</p><p>```</p><p>```text</p><p>[H1] 5 EXPERIMENTS</p><p>[H3] Baselines for Object Detection</p><p>[H3] Learning Curve</p><p>[H3] Impact of Class Labels</p><p>[H3] Impact of Document Split in Train and Test Set</p><p>[H3] Dataset Comparison</p><p>[H3] Example Predictions</p><p>[H1] 6 CONCLUSION</p><p>```</p><p>The precedence is bookmarks first, then numbering, then style. Headings with no usable signal keep level 1.</p><p><strong>### Controlling the PDF Pipeline</strong></p><p>PDF conversion exposes switches for the expensive stages, so you can pay only for what a document needs:</p><p>```python</p><p>from docling.datamodel.base_models import InputFormat</p><p>from docling.datamodel.pipeline_options import PdfPipelineOptions</p><p>from docling.document_converter import DocumentConverter, PdfFormatOption</p><p>opts = PdfPipelineOptions()</p><p>opts.do_ocr = True # needed for scanned pages; skip for born-digital PDFs</p><p>opts.do_table_structure = True # rebuild rows, columns, and spans</p><p>converter = DocumentConverter(</p><p>format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=opts)}</p><p>)</p><p>```</p><p>Guidelines for configuring options:</p><p>* <strong>**`do_ocr`:**</strong> Turn on when documents contain scanned pages or embedded images with text. Skip when files are born-digital and text is selectable.</p><p>* <strong>**`do_table_structure`:**</strong> Turn on when tables carry facts users will ask about. Turn off when documents contain no tables to save compute time.</p><p>* <strong>**`generate_picture_images`:**</strong> Turn on when you want diagrams searchable and viewable. Turn off when only text content matters.</p><p>* <strong>**`heading_hierarchy_options.enabled`:**</strong> Turn on when documents have deep outlines you want to keep. Turn off when headings are flat or only text is needed.</p><p><strong>— -</strong></p><p><strong>## Preserving Provenance and Traceability</strong></p><p>Enterprise AI systems often require more than content extraction. Users frequently need answers to questions such as:</p><p>* Which page contained this information?</p><p>* Where did this table originate?</p><p>* What section was this text extracted from?</p><p>Docling preserves provenance metadata for document elements, including information such as page locations and structural references.</p><p>Each item’s `prov` list records where it came from. For Table 2:</p><p>```python</p><p>table = doc.tables[1]</p><p>for p in table.prov:</p><p>print(f”page={p.page_no} bbox=({p.bbox.l:.0f}, {p.bbox.t:.0f}, {p.bbox.r:.0f}, {p.bbox.b:.0f}) {p.bbox.coord_origin.value}”)</p><p>```</p><p>```text</p><p>page=6 bbox=(62, 597, 286, 440) BOTTOMLEFT</p><p>```</p><p>The box is in PDF points with the origin at the bottom-left of the page. It places the table in the left column of page 6.</p><p>Walking the document while tracking current headings gives each paragraph its page and section path:</p><p>```json</p><p>{</p><p>“text”: “DocLayNet contains 80863 PDF pages. Among these, 7059 carry two instances of human annotations, and 1591 carry three.”,</p><p>“source_file”: “2206.01062v1.pdf”,</p><p>“page”: 2,</p><p>“section_path”: [“3 THE DOCLAYNET DATASET”],</p><p>“element_type”: “text”</p><p>}</p><p>```</p><p>An answer built from this chunk can now cite it: <em>*”DocLayNet contains 80,863 PDF pages (Section 3, p. 2).”*</em></p><p><strong>— -</strong></p><p><strong>## Preparing Content for Retrieval and RAG</strong></p><p>The goal of document understanding is not simply content extraction. The goal is to create a representation that downstream systems can use effectively.</p><p>By preserving:</p><p>* Document hierarchy</p><p>* Reading order</p><p>* Tables</p><p>* Visual assets</p><p>* Section relationships</p><p>* Structural metadata</p><p>Docling provides the foundation for intelligent chunking and context-aware retrieval.</p><p><strong>### A Structure-Aware Pass in Practice</strong></p><p>Because headings carry a level, you can group content under its section and keep the section path as context:</p><p>```python</p><p>stack: list[tuple[int, str]] = [] # (level, heading) of the current path</p><p>sections: dict[str, list[str]] = {}</p><p>for item, _ in doc.iterate_items():</p><p>if isinstance(item, SectionHeaderItem):</p><p>while stack and stack[-1][0] &gt;= item.level: # drop siblings and deeper headings</p><p>stack.pop()</p><p>stack.append((item.level, item.text))</p><p>continue</p><p>text = getattr(item, “text”, None)</p><p>if text:</p><p>path = “ &gt; “.join(t for _, t in stack)</p><p>sections.setdefault(path, []).append(text)</p><p>for path, texts in sections.items():</p><p>print(f”{len(texts):3} {path}”)</p><p>```</p><p>```text</p><p>4 DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis</p><p>1 DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis &gt; KEYWORDS</p><p>1 DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis &gt; KEYWORDS &gt; ACM Reference Format:</p><p>1 ABSTRACT</p><p>5 ABSTRACT &gt; CCS CONCEPTS</p><p>12 1 INTRODUCTION</p><p>2 2 RELATEDWORK</p><p>10 3 THE DOCLAYNET DATASET</p><p>22 4 ANNOTATIONCAMPAIGN</p><p>3 5 EXPERIMENTS</p><p>2 5 EXPERIMENTS &gt; Baselines for Object Detection</p><p>1 5 EXPERIMENTS &gt; Learning Curve</p><p>2 5 EXPERIMENTS &gt; Impact of Class Labels</p><p>1 5 EXPERIMENTS &gt; Impact of Document Split in Train and Test Set</p><p>3 5 EXPERIMENTS &gt; Dataset Comparison</p><p>1 5 EXPERIMENTS &gt; Example Predictions</p><p>3 6 CONCLUSION</p><p>25 REFERENCES</p><p>```</p><p>Compare that with fixed-size splitting of flat text:</p><p>* <strong>**Fixed 500-character splits of flat text:**</strong> Splits mid-sentence or mid-table, with no awareness of the surrounding section context.</p><p>* <strong>**Structure-aware chunks from `DoclingDocument`:**</strong> Respects natural section and element boundaries, retaining the full section path ancestry.</p><p><strong>— -</strong></p><p><strong>## Key Takeaways</strong></p><p>Document intelligence starts with understanding structure, not just extracting text.</p><p>Docling enables this by:</p><p>* Converting documents into a unified document model</p><p>* Preserving semantic structure and hierarchy</p><p>* Extracting tables, figures, lists, and code blocks</p><p>* Reconstructing document organization from complex layouts</p><p>* Maintaining provenance and traceability information</p><p>* Creating a consistent foundation for downstream AI workflows</p><p>The result is a structured representation that captures both the content of a document and the relationships that give that content meaning.</p><p><strong>— -</strong></p><p><strong>## References</strong></p><p>1. <strong>**Docling Documentation — Overview:**</strong> <a href="https://docling-project.github.io/docling/">https://docling-project.github.io/docling/</a></p><p>2. <strong>**Docling Documentation — DoclingDocument Concept:**</strong> <a href="https://docling-project.github.io/docling/concepts/docling_document/">https://docling-project.github.io/docling/concepts/docling_document/</a></p><p>3. <strong>**Docling GitHub Repository:**</strong> <a href="https://github.com/docling-project/docling">https://github.com/docling-project/docling</a></p><p>4. <strong>**Docling Project Organization:**</strong> <a href="https://github.com/docling-project">https://github.com/docling-project</a></p><p>5. <strong>**Docling AI Website:**</strong> <a href="https://docling.ai/">https://docling.ai/</a></p><p>6. <strong>**Pfitzmann et al. (2022).**</strong> <em>*DocLayNet: A Large Human-Annotated Dataset for Document-Layout Analysis.*</em> KDD ’22. <a href="https://arxiv.org/pdf/2206.01062">https://arxiv.org/pdf/2206.01062</a></p><p><strong>— -</strong></p><p><strong>## What’s Next?</strong></p><p>Now that documents have been transformed into structured objects, the next challenge is ensuring that retrieval systems can access information without losing context.</p><p>In <strong>**Part 3**</strong>, we’ll explore how hierarchical chunking leverages the Docling document model to preserve parent-child relationsh<em>*Retrieval quality is determined long before embeddings are created. It begins with how well a system understands the structure of a document.*</em></p><p>In Part 1, we explored how enterprise documents are discovered, validated, and ingested into the processing pipeline. Once a document enters the system, the next challenge is understanding its content in a way that preserves meaning, structure, and relationships.</p><p>Many document-processing pipelines treat files as plain text, extracting characters and splitting them into chunks with little awareness of document structure. While this approach may work for simple documents, it struggles with technical manuals, research papers, enterprise reports, and multi-column PDFs where meaning is defined not just by text, but by layout and hierarchy.</p><p>This is where <strong>**Docling**</strong> comes in. Developed as an open-source document AI framework, Docling converts diverse document formats into a unified, structured representation that can be reliably consumed by downstream search, analytics, and Retrieval-Augmented Generation (RAG) systems.</p><p><strong>— -</strong></p><p><strong>## Why Document Structure Matters</strong></p><p>A document is much more than a sequence of words.</p><p>ips, maintain semantic context, and build retrieval-ready knowledge for enterprise RAG systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c886f1a0325" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Document Intelligence Platform, Part 1: The Discovery Layer]]></title>
            <link>https://medium.com/@sahitssvk/discover-building-a-reliable-document-discovery-and-ingestion-layer-0d2364de4694?source=rss-20ee7660c1f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d2364de4694</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[data-ingestion]]></category>
            <category><![CDATA[docling]]></category>
            <dc:creator><![CDATA[Sure Sai Venkata Krishna Sahit]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 08:33:46 GMT</pubDate>
            <atom:updated>2026-11-06T08:46:28.657Z</atom:updated>
            <content:encoded><![CDATA[<p>Before an AI system can understand information, it must first locate the right content, determine whether it has changed, and decide whether it is worth processing.</p><ul><li>Manual ingestion tools</li><li>Automated workflows</li></ul><p>Workers react to each ingestion event without needing to know what triggered it.</p><p><strong>Horizontal Scalability</strong></p><p>Partitioned topics allow multiple workers to process events concurrently, increasing throughput as demand grows.</p><p><strong>Resilient Failure Handling</strong></p><p>Temporary issues such as network interruptions can be retried automatically, while permanently failing documents can be redirected to dedicated dead-letter queues for later analysis.</p><p><strong>Outcome:</strong> Discovery becomes scalable, fault-tolerant, and independent from downstream processing workloads.</p><h3>Stage 3: Distributed Processing</h3><h3>Scaling Through Independent Workers</h3><p>Once ingestion events arrive on Kafka, a pool of workers consumes and handles them in parallel. Each worker maintains its own isolated processing environment, preventing contention and ensuring predictable performance.</p><p>This design enables:</p><ul><li>Parallel processing</li><li>Improved throughput</li><li>Better utilization of compute resources</li><li>Independent failure isolation</li></ul><p>As ingestion demands increase, additional workers can be added with minimal operational changes.</p><p><strong>Outcome:</strong> The platform can process large volumes of content while maintaining stability and predictable performance.</p><h3>Stage 4: Smart Deduplication with SHA-1 Validation</h3><h3>Avoiding Unnecessary Processing</h3><p>One of the most effective optimizations in the entire pipeline occurs before any file is downloaded.</p><p>Storage providers often expose a checksum representing the current state of a document. By comparing this checksum with the version previously processed, the platform can determine whether a file has changed.</p><p>The decision process is simple:</p><ul><li><strong>New file:</strong> Process</li><li><strong>Modified file:</strong> Process</li><li><strong>Unchanged file:</strong> Skip</li><li><strong>Unknown state:</strong> Process</li></ul><p>When a file is identified as unchanged:</p><ul><li>No download occurs</li><li>No parsing occurs</li><li>No indexing occurs</li><li>No additional compute is consumed</li></ul><h3>Why This Matters</h3><p>In many enterprise environments, the majority of content remains unchanged between ingestion cycles. A synchronization operation involving thousands of files might reveal that only a small percentage actually require processing.</p><p>By filtering unchanged content before download, the platform dramatically reduces:</p><ul><li>Network traffic</li><li>Storage operations</li><li>Parsing workload</li><li>Indexing costs</li></ul><p><strong>Outcome:</strong> Processing resources are focused exclusively on content that provides new value.</p><h3>Stage 5: File Validation and Routing</h3><h3>Determining Whether a File Is Worth Processing</h3><p>Not every file uploaded into an enterprise repository should be parsed. Executables, archives, temporary files, and unsupported formats often provide little value while consuming significant resources.</p><p>To address this, the platform maintains an explicit allow-list of supported formats. Examples include:</p><ul><li>PDF</li><li>DOCX</li><li>PPTX</li><li>XLSX</li><li>CSV</li><li>HTML</li><li>Markdown</li><li>TXT</li><li>Images</li></ul><p>Files outside the approved list are logged and skipped.</p><h3>Intelligent Routing</h3><p>Once a file passes validation, it is routed to the most appropriate processing strategy:</p><ul><li><strong>PDFs:</strong> Document parsing with OCR and table extraction</li><li><strong>Office documents:</strong> Structured document parsing</li><li><strong>Spreadsheets:</strong> Tabular content extraction</li><li><strong>Text files:</strong> Lightweight document parsing</li><li><strong>Images:</strong> Image-aware processing workflows</li></ul><p>Different content types require different parsing techniques, and routing ensures each receives the appropriate treatment.</p><p><strong>Outcome:</strong> Documents are processed using strategies optimized for their structure and content.</p><h3>Handling Failure Gracefully</h3><p>Robust ingestion systems must assume failure will occur. The platform treats failures according to their nature:</p><ul><li><strong>Duplicate document:</strong> Skip</li><li><strong>Unsupported file type:</strong> Skip</li><li><strong>Temporary infrastructure issue:</strong> Retry</li><li><strong>Permanently corrupted file:</strong> Send to the dead-letter queue</li><li><strong>Service shutdown during processing:</strong> Resume later</li></ul><p>This approach prevents a single problematic document from disrupting the entire ingestion pipeline.</p><h3>Safe Shutdown and Recovery</h3><p>Enterprise systems are frequently restarted during deployments, scaling operations, or infrastructure maintenance. A graceful shutdown mechanism ensures that documents being processed are not lost.</p><p>If processing is interrupted:</p><ul><li>The active task is not marked complete.</li><li>Kafka retains ownership of the unprocessed event.</li><li>Another worker can safely resume processing later.</li></ul><p>This guarantees reliability without creating partially indexed content.</p><p><strong>Outcome:</strong> Document processing remains consistent even during infrastructure changes.</p><h3>Putting It All Together</h3><p>Consider three documents discovered during a synchronization cycle:</p><ul><li><strong>A PDF that has not changed since the last sync:</strong> Skipped immediately</li><li><strong>A recently updated Word document:</strong> Downloaded, parsed, and indexed</li><li><strong>An unsupported executable:</strong> Rejected before processing</li></ul><p>Only the modified document consumes parsing resources. This illustrates the core philosophy of the discovery layer:</p><blockquote><em>Process only what matters.</em></blockquote><h3>Key Takeaways</h3><p>A successful document intelligence platform begins long before parsing, chunking, or vector search. The discovery layer is responsible for ensuring that only relevant and changed content reaches the expensive stages of the pipeline.</p><p>Its core capabilities include:</p><ul><li>Unified connectors for multiple storage systems</li><li>Event-driven ingestion through Kafka</li><li>Scalable distributed workers</li><li>SHA-based change detection</li><li>Intelligent file-type validation</li><li>Fault-tolerant retry mechanisms</li><li>Safe shutdown and recovery processes</li></ul><p>Together, these capabilities transform scattered enterprise content into a reliable stream of processing-ready documents.</p><h3>What Comes Next?</h3><p>Once a document successfully passes discovery, validation, and deduplication, it enters the parsing stage.</p><p>In <strong>Part 2</strong>, we’ll explore how Docling transforms raw files into structured document objects by extracting layout information, content hierarchy, metadata, tables, and multimodal elements that serve as the foundation for retrieval and AI-driven experiences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d2364de4694" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Smarter AI: Building RAG Pipelines with Elasticsearch — Vectorized Thinking in Action]]></title>
            <link>https://medium.com/@sahitssvk/unlocking-smarter-ai-building-rag-pipelines-with-elasticsearch-vectorized-thinking-in-action-51e9f9f83654?source=rss-20ee7660c1f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/51e9f9f83654</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[vector-search]]></category>
            <category><![CDATA[vectordb]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[semantic-search]]></category>
            <dc:creator><![CDATA[Sure Sai Venkata Krishna Sahit]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 17:16:16 GMT</pubDate>
            <atom:updated>2026-02-04T17:16:16.095Z</atom:updated>
            <content:encoded><![CDATA[<p>Large Language Models (LLMs) have reshaped how modern systems interact with information. However, despite their generative power, they remain constrained by static training data, hallucinations, and the absence of domain-specific context.</p><p>Retrieval-Augmented Generation (RAG) addresses these limitations by grounding model responses in real, searchable knowledge sources. Instead of relying solely on parametric memory, RAG dynamically retrieves relevant information and uses it to guide generation — resulting in accurate, explainable, and continuously updatable AI systems.</p><p>At the core of high-performing RAG pipelines lies an efficient retrieval layer. Elasticsearch, with its native vector search, hybrid retrieval mechanisms, and distributed scalability, has emerged as a foundational technology enabling production-grade RAG architectures.</p><p>This article explores how Elasticsearch operationalizes “vectorized thinking” and why it has become a key value indicator for retrieval quality, system performance, and enterprise adoption of RAG.</p><h3><strong>Understanding Retrieval-Augmented Generation (RAG)</strong></h3><p>RAG is a hybrid architecture that integrates information retrieval with generative models to produce context-aware responses.</p><p>The pipeline typically consists of:</p><p><strong>Retrieval</strong><br>Relevant documents or data chunks are fetched from a knowledge store based on the user query.</p><p><strong>Augmentation</strong><br>The retrieved content is incorporated into the LLM prompt as contextual grounding.</p><p><strong>Generation</strong><br>The model generates a response informed by retrieved knowledge.</p><p>This approach significantly improves factual accuracy, enables access to proprietary data, and eliminates the need for costly model fine-tuning when information changes.</p><p>RAG has become a cornerstone in enterprise search, intelligent assistants, document analysis platforms, and AI-driven knowledge systems.</p><h4><strong>Elasticsearch as the Retrieval Backbone for RAG Systems</strong></h4><p>Traditional search engines depend primarily on lexical matching, which struggles with semantic intent and contextual relevance. Elasticsearch extends classical information retrieval with vector-based and hybrid approaches, transforming search into a semantic intelligence layer.</p><p>Its ability to unify keyword relevance, vector similarity, filtering, and real-time performance positions it as a strategic component in scalable RAG pipelines.</p><h3><strong>Core Elasticsearch Capabilities Enabling High-Quality RAG</strong></h3><p><strong>Vector Search with Approximate Nearest Neighbor (kNN)</strong></p><p>Elasticsearch supports dense vector fields that store embeddings generated from transformer-based models such as BERT or Sentence Transformers.</p><p>Using approximate nearest neighbor algorithms, Elasticsearch retrieves semantically similar content with low latency even at billion-scale vector volumes.</p><p>This semantic retrieval ensures that RAG pipelines fetch context aligned with conceptual meaning rather than surface-level keyword overlap — directly improving response relevance and reducing hallucinations.</p><p><strong>Hybrid Retrieval for Precision and Recall Optimization</strong></p><p>While vector search excels at semantic matching, lexical search remains superior for exact terms, identifiers, and structured queries.</p><p>Elasticsearch combines both approaches using hybrid retrieval strategies such as Reciprocal Rank Fusion (RRF). This fusion balances semantic understanding with keyword precision, producing consistently higher relevance scores across complex query patterns.</p><p>In RAG systems, hybrid search functions as a key quality multiplier — improving both recall depth and ranking accuracy.</p><p><strong>Native Semantic Search with ELSER</strong></p><p>Elasticsearch includes its own Learned Sparse Encoder for Retrieval (ELSER), enabling semantic search without external embedding pipelines.</p><p>ELSER generates sparse representations that capture contextual token importance while integrating directly into Elasticsearch’s indexing and scoring infrastructure.</p><p>This reduces operational complexity, latency, and cost while delivering strong semantic retrieval performance — particularly valuable for organizations deploying RAG at scale.</p><p><strong>Metadata Filtering, Security, and Context Control</strong></p><p>Enterprise RAG systems must ensure retrieved content is both relevant and authorized.</p><p><strong>Elasticsearch supports:</strong></p><p>* <strong>Role-based access control</strong><br>*<strong> Field-level filtering</strong><br>* <strong>Temporal constraints</strong><br>* <strong>Aggregations and ranking controls</strong></p><p>These features ensure that generative responses are built only from permitted, accurate, and contextually appropriate data sources — critical for compliance and trust.</p><p><strong>Distributed Scalability and Performance Engineering</strong></p><p>Elasticsearch’s shard-based distributed architecture allows RAG pipelines to scale horizontally across massive knowledge stores while maintaining low query latency.</p><p>Performance optimizations such as vector indexing strategies, caching layers, and query parallelization enable real-time retrieval even under high throughput workloads.</p><p>This scalability makes Elasticsearch suitable for production AI systems operating at enterprise scale.</p><p><strong>Quantifiable Impact on RAG System Performance</strong></p><p>Elasticsearch-driven retrieval introduces measurable improvements across key RAG quality indicators:</p><p><strong>Higher relevance and grounding accuracy<br></strong>Semantic vectors align retrieval with user intent.</p><p><strong>Lower latency generation pipelines<br></strong>Optimized kNN and hybrid queries deliver real-time responsiveness.</p><p><strong>Richer contextual prompts<br></strong>Improved document chunking and retrieval diversity increase answer depth.</p><p><strong>Reduced operational cost</strong><br>RAG eliminates continuous model fine-tuning while leveraging existing data.</p><p>Across benchmarks and production deployments, Elasticsearch-based RAG pipelines consistently outperform traditional keyword-only retrieval architectures in both precision and reliability.</p><h4><strong>High-Level RAG Pipeline Using Elasticsearch</strong></h4><p><strong>Data Ingestion and Vector Indexing</strong></p><p><strong>* Document chunking<br>* Embedding generation<br>* Vector storage in Elasticsearch</strong></p><p><strong>Hybrid Retrieval Execution</strong></p><p>```json<br>{<br> “query”: {<br> “match”: {<br> “text”: “user query”<br> }<br> },<br> “knn”: {<br> “field”: “vector_field”,<br> “query_vector”: [0.11, 0.27, …],<br> “k”: 10<br> }<br>}<br>```</p><p><strong>Context Injection and Response Generation</strong></p><p>Retrieved documents are appended to the LLM prompt, enabling grounded and explainable outputs.</p><h4>Conclusion: <br>Elasticsearch as a Strategic Enabler of Intelligent Retrieval</h4><p>Retrieval quality determines the effectiveness of any RAG system.Elasticsearch elevates retrieval from keyword matching to semantic intelligence by integrating vector search, hybrid ranking, native ML models, and enterprise-scale performance within a unified platform.<br>As vectorized data becomes the foundation of intelligent systems, Elasticsearch serves not merely as a datastore — but as a high-performance retrieval engine powering the next generation of AI applications.</p><p><strong>Author</strong>: Sure Sai Venkata Krishna Sahit<br><strong>Tags</strong>: Elasticsearch, RAG, Vector Search, Generative AI, Elastic Stack, Retrieval-Augmented Generation,vectorsearch, semanticsearch,vectorDB</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51e9f9f83654" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>