DocMaster: A Hierarchical Structure-Aware System for Document Analysis Ziqi Chen
Yingli Zhou
Fangyuan Zhang
The Chinese University of Hong Kong, Shenzhen Shenzhen, China [email protected]
The Chinese University of Hong Kong, Shenzhen Shenzhen, China [email protected]
The Chinese University of Hong Kong Hong Kong, China [email protected]
Quanqing Xu
Chuanhui Yang
Yixiang Fang
OceanBase, AntGroup Hangzhou, China [email protected]
OceanBase, AntGroup Hangzhou, China [email protected]
The Chinese University of Hong Kong, Shenzhen Shenzhen, China [email protected]
arXiv:2607.08539v1 [cs.DB] 9 Jul 2026
Abstract Leveraging large language models (LLMs) to analyze complex documents — such as academic papers, technical manuals, and financial reports — has emerged as a mainstream and critical task in both research and industry. In practice, users must first filter relevant documents from large collections and then conduct in-depth analysis (e.g., question answering) over the selected subset, yet existing systems flatten documents into plain-text chunks, discarding the rich hierarchical structures (sections, tables, figures, equations) and degrading downstream performance. We present DocMaster, a hierarchical structure-aware document analysis system. DocMaster parses documents into hierarchical document trees preserving original layouts and constructs a structure-aware semantic index that enables accurate document filtering and in-depth analysis. We demonstrate DocMaster through an interactive web interface that enables users to upload document collections, construct treebased and multi-view semantic indices, filter relevant documents via natural-language conditions, and perform follow-up question answering over the filtered results. The source code, data, and demo are available at https://doc-master.github.io/.
1
Introduction
Leveraging large language models (LLMs) to analyze complex documents — such as academic papers, technical manuals, and financial reports — has emerged as a mainstream and critical task in both research and industry. These documents encode information within rich hierarchical structures —sections, subsections, tables, figures, and equations — that must be understood for effective analysis. In practice, users must first filter relevant documents from large collections and then conduct in-depth analysis (e.g., question answering) over the selected subset, as shown in Figure 1. For example, a researcher surveying AI papers may need to find those that “propose a retrieval-augmented method and evaluate on open-domain QA benchmarks” before extracting detailed insights. However, existing document analysis systems [4, 7, 9] flatten documents into plain-text chunks, discarding the rich hierarchical
Query Folder of Docs
Question
Filtered Docs
Doc Index
Aggregate & Analyze
Filtered Docs
Answer: ...
Figure 1: The overall workflow of document analysis.
structures and degrading downstream performance. This structureagnostic treatment introduces three key challenges. (C1) Hierarchy preservation. Flattening sections, subsections, and heterogeneous elements (text, tables, figures, equations) into flat chunks destroys structural relationships, causing systems to return contextpoor fragments that hinder accurate filtering and answering. (C2) Cross-section semantic indexing. Implicit semantic relationships span across sections—e.g., a method in Section 3 may be closely tied to an evaluation metric in Section 5. Capturing such cross-section links requires indices that go beyond simple vector similarity. (C3) Cross-section evidence aggregation. A single filter condition may require evidence scattered across distant sections, yet existing systems retrieve chunks independently without aggregating cross-section evidence. To address these challenges, we present DocMaster, a hierarchical structure-aware document analysis system. DocMaster first parses documents into hierarchical document trees, preserving original layouts and constructs structure-aware semantic indices via LLM-guided constrained clustering (PC-KMeans) and cross-section hyper-edges. It then performs tri-modal retrieval to accurately filter target documents from large collections, and finally leverages the filtered documents as grounded context for downstream question answering via retrieval-augmented generation (RAG) [5]. Our contributions are summarized as follows:
Figure 2: The DocMaster web interface: users can issue natural-language filter queries, explore the document-tree index, tune hyperparameters, and compare filtering results side by side. • We propose a hierarchical document representation that combines a structural document tree with a structure-aware semantic index, capturing both explicit hierarchy and implicit crosssection relationships (C1, C2). • We design a tri-modal retrieval strategy integrating documenttree traversal, embedding-based semantic search, and hyper-edge matching for accurate document filtering (C3). • We build an interactive web interface that enables users to upload document collections, construct tree-based and multi-view semantic indices, filter relevant documents via natural-language conditions, and perform follow-up question answering over the filtered results.
2
EQUATION. Title nodes correspond to section and subsection headers, forming the internal structure of the tree, while content nodes (text, images, tables, equations) are attached as children under their enclosing titles. Each node stores its raw content, a summary generated by GPT-4o mini, and a dense embedding computed by a sentence transformer (all-MiniLM-L6-v2 [13]). The tree is constructed bottom-up: leaf node summaries are generated first, then section summaries are recursively composed from their children.
2.3
Semantic Index Construction
Beyond the structural document tree, DocMaster constructs a semantic index capturing implicit relationships across sections. As illustrated in Figure 5, this involves three components. Structural Entropy Correlation (SEC) Score. To select informative text pairs for clustering, DocMaster scores each pair of text nodes (𝑣𝑖 , 𝑣 𝑗 ) using a Structural Entropy Correlation (SEC) measure that combines semantic similarity with structural divergence [8]:
System Overview
Figure 1 illustrates the overall pipeline of DocMaster, which proceeds through four stages: (1) document parsing, (2) document tree construction, (3) semantic index construction, and (4) filtering and retrieval.
SEC(𝑣𝑖 , 𝑣 𝑗 ) = 𝛼 · cos(e𝑖 , e 𝑗 ) − (1 − 𝛼) ·
2.1
Document Parsing
DocMaster employs MinerU [12] as its PDF extraction backend, converting documents into structured content while preserving layout information including text blocks, tables, figures, and equations.
2.2
H 𝑇 (𝑣𝑖 , 𝑣 𝑗 ) log2 |𝑉 |
(1)
where e𝑖 is the embedding of node 𝑣𝑖 , cos(·, ·) denotes cosine simÍ 𝑑𝑣 𝑑𝑣 ilarity, and H 𝑇 (𝑣𝑖 , 𝑣 𝑗 ) = − 𝑣 ∈𝑃𝑖 𝑗 2|𝐸 | log2 vol(𝑇𝑣 ) is the structural entropy along the tree path 𝑃𝑖 𝑗 between the two nodes, with 𝑑 𝑣 the degree of 𝑣, |𝐸| the number of edges in the document tree, vol(𝑇𝑣 ) the volume of the subtree rooted at 𝑣, and |𝑉 | the total number of nodes. We set 𝛼=0.6 and select the top-𝑘 pairs with highest SEC scores as anchors for clustering. Intuitively, SEC favors node pairs that are semantically similar yet structurally distant in the
Document Tree Construction
The parsed content is organized into a hierarchical document tree. Each node is typed as one of ROOT, TITLE, TEXT, IMAGE, TABLE, or 2
Query: Find out
Question: What is the
the papers about RAG from the folder
trend among the papers about graph-based index?
Input
Folder of AI papers
Answer:
True
Hypergraph
Layout Analysis & Parsing
Aggregate & Analyze
L1
Aggregate & Analyze
True
Semantic Cluster
Input
False
L0
Graphbased RAG is currently heading towards multiple directions ...
Semantic Cluster
Figure 3: End-to-end example of DocMaster. The user uploads AI papers; each PDF is parsed into a hierarchical document tree, enriched with semantic indices (PC-KMeans clusters and hyper-edges), and queried through tri-modal retrieval for filtering. The user then asks follow-up questions about the filtered papers. document tree—precisely the cross-section relationships that local retrieval misses. Pairwise-Constrained K-Means (PC-KMeans). Given the top-𝑘 anchor pairs, an LLM labels each as must-link (M) or cannotlink (C). DocMaster then clusters all text nodes into 𝐾 clusters by minimizing the PC-KMeans objective [1]:
J=
𝐾 ∑︁ ∑︁ 𝑙=1 𝑣𝑖 ∈𝐶𝑙
∥e𝑖 − 𝝁𝑙 ∥ 2 + 𝑤
∑︁
⊮[𝑐𝑖 ≠𝑐 𝑗 ] − 𝑤
(𝑣𝑖 ,𝑣 𝑗 ) ∈ M
∑︁
⊮[𝑐𝑖 =𝑐 𝑗 ]
(𝑣𝑖 ,𝑣 𝑗 ) ∈ C
(2) where 𝐾 is the number of clusters, 𝝁𝑙 is the centroid of cluster 𝐶𝑙 , 𝑐𝑖 denotes the cluster assignment of 𝑣𝑖 , and 𝑤 is the penalty weight for constraint violations. By restricting LLM calls to the 𝑘 SECselected anchor pairs, DocMaster bounds annotation cost at 𝑂 (𝑘). The must-link and cannot-link constraints inject LLM-level semantic judgment into clustering, pulling semantically related nodes together even when their embeddings are not nearest neighbors. Hyper-Edges. Within each section, DocMaster uses LLMbased grouping to identify semantically related paragraphs. Each group forms a hyper-edge connecting multiple text nodes, accompanied by a concise summary (30–50 words). Hyper-edges residing in the same PC-KMeans cluster are linked via must-link relationships, creating a semantic overlay that spans the entire document.
2.4
Figure 4: Document tree view of DocMaster, showing the hierarchical structure of an example paper.
Filtering and Retrieval
Given a natural-language filter condition, DocMaster combines evidence from three complementary retrieval strategies: (i) documenttree traversal, which searches title nodes first and then retrieves content under the most relevant sections; (ii) FAISS semantic search [6], which scores each node as 𝑠 (𝑣𝑖 , 𝑞) = 𝑤𝜏 (𝑣𝑖 ) · cos(e𝑖 , e𝑞 ) · 𝛾 𝑑𝑖 , where 𝑤𝜏 is a type weight (e.g., title=1.5, text=1.0, table=0.8), 𝑑𝑖 is the depth, and 𝛾 ∈ (0, 1) is a decay factor favoring shallower nodes; and (iii) hyper-edge matching, which searches hyper-edge summaries and retrieves all connected nodes for matching edges. The combined evidence is passed to an LLM, which renders a boolean filtering decision per document. For follow-up questions, the same retrieval pipeline supplies context passages to the LLM for RAGbased answer generation.
Figure 5: Overview of Semantic Index.
3
Demonstration
DocMaster is deployed as a web application built with a React frontend and a FastAPI backend. The demonstration showcases 3
three interactive scenarios. Figure 2 shows the system frontend; Figure 3 illustrates the end-to-end pipeline of Scenario 3; and Figures 4–5 display the document index views. Scenario 1: Document Upload and Exploration. A researcher uploads a folder of AI papers via drag-and-drop. DocMaster processes each PDF in real time, progressively building the hierarchical document tree and semantic indices; a progress bar tracks the parsing status of each document. The researcher then explores the document tree in a collapsible tree layout (Figure 4), clicking any node to inspect its raw content, LLM-generated summary, and dense embedding. Scenario 2: Semantic Index Inspection. The interface provides three switchable views for inspecting the constructed indices (Figure 5): (i) a Document Tree view showing the structural hierarchy; (ii) a Hyper-Edge view displaying semantic groupings and must-link connections across sections; and (iii) a Semantic Cluster view visualizing PC-KMeans clustering results with adjustable hyperparameters (𝛼, 𝑘, 𝐾, 𝑤). For instance, hyper-edges may link a “retrieval mechanism” paragraph in one paper’s method section to an “evaluation on open-domain QA” paragraph in its experiments— a cross-section relationship invisible to flat retrieval. Scenario 3: Live Filtering and Follow-up Q&A. The researcher enters a natural-language filter condition (e.g., “Does this paper propose a retrieval-augmented generation method?”) into the query panel. DocMaster retrieves evidence from all three retrieval strategies, highlights matching passages in the tree, and displays a boolean filtering decision per document. As shown in Figure 3, once relevant papers are identified, the researcher issues a follow-up question (e.g., “What retrieval strategies does this paper use?”) and receives a grounded answer with cited passages drawn from the filtered documents. Users can also compare filtering results across different hyperparameter settings side by side (Figure 2).
4
5
Conclusion
We presented DocMaster, a hierarchical structure-aware document analysis system that leverages LLMs to analyze complex documents. DocMaster first parses documents into hierarchical document trees preserving original layouts and constructs structureaware semantic indices, then filters relevant documents from large collections via tri-modal retrieval, and finally supports follow-up question answering over the filtered results through RAG. We demonstrated DocMaster through an interactive web interface covering the full workflow—from document-collection upload and semantic index construction to live filtering and question answering. Future work includes building cross-document semantic indices that link related content across documents and supporting incremental index updates as collections evolve.
References [1] Sugato Basu, Arindam Banerjee, and Raymond J. Mooney. 2004. Active Semi-Supervision for Pairwise Constrained Clustering. In SDM. https://api. semanticscholar.org/CorpusID:2852345 [2] Lukas Blecher, Guillem Cucurull, Thomas Scialom, and Robert Stojnic. 2023. Nougat: Neural optical understanding for academic documents. arXiv preprint arXiv:2308.13418 (2023). [3] Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George Bm Van Den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. 2022. Improving language models by retrieving from trillions of tokens. In International conference on machine learning. PMLR, 2206–2240. [4] Harrison Chase. 2022. LangChain. https://github.com/langchain-ai/langchain. Accessed: 2025-01-15. [5] Yunfan Gao, Yun Xiong, Xinyu Gao, Kangxiang Jia, Jinliu Pan, Yuxi Bi, Yixin Dai, Jiawei Sun, Haofen Wang, Haofen Wang, et al. 2023. Retrieval-augmented generation for large language models: A survey. arXiv preprint arXiv:2312.10997 2, 1 (2023), 32. [6] Jeff Johnson, Matthijs Douze, and Hervé Jégou. 2019. Billion-scale similarity search with GPUs. IEEE transactions on big data 7, 3 (2019), 535–547. [7] Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. 2020. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in neural information processing systems 33 (2020), 9459–9474. [8] Angsheng Li and Yicheng Pan. 2016. Structural Information and Dynamical Complexity of Networks. IEEE Transactions on Information Theory 62, 6 (2016), 3290–3339. doi:10.1109/TIT.2016.2555904 [9] Jerry Liu. 2022. LlamaIndex. doi:10.5281/zenodo.1234 [10] Parth Sarthi, Salman Abdullah, Aditi Tuli, Shubh Khanna, Anna Goldie, and Christopher D Manning. 2024. Raptor: Recursive abstractive processing for tree-organized retrieval. In The Twelfth International Conference on Learning Representations. [11] Kiri Wagstaff, Claire Cardie, Seth Rogers, and Stefan Schrödl. 2001. Constrained K-means Clustering with Background Knowledge. In Proceedings of the Eighteenth International Conference on Machine Learning (ICML ’01). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 577–584. [12] Bin Wang, Chao Xu, Xiaomeng Zhao, Linke Ouyang, Fan Wu, Zhiyuan Zhao, Rui Xu, Kaiwen Liu, Yuan Qu, Fukai Shang, et al. 2024. Mineru: An open-source solution for precise document content extraction. arXiv preprint arXiv:2409.18839 (2024). [13] Wenhui Wang, Furu Wei, Li Dong, Hangbo Bao, Nan Yang, and Ming Zhou. 2020. Minilm: Deep self-attention distillation for task-agnostic compression of pre-trained transformers. Advances in neural information processing systems 33 (2020), 5776–5788. [14] Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and Ming Zhou. 2020. Layoutlm: Pre-training of text and layout for document image understanding. In Proceedings of the 26th ACM SIGKDD international conference on knowledge discovery & data mining. 1192–1200. [15] Yingli Zhou, Yaodong Su, Youran Sun, Shu Wang, Taotao Wang, Runyuan He, Yongwei Zhang, Sicong Liang, Xilin Liu, Yuchi Ma, et al. 2025. In-depth Analysis of Graph-based RAG in a Unified Framework. arXiv preprint arXiv:2503.04338 (2025).
Related Work
Retrieval-Augmented Generation. RAG systems [3, 7, 15] ground LLM outputs in retrieved passages; Gao et al. [5] provide a comprehensive survey. Most systems treat documents as flat chunk sequences. RAPTOR [10] builds hierarchical trees via recursive clustering, but purely from embedding similarity without preserving the original document hierarchy or modeling cross-section relationships. Document Parsing. MinerU [12] and Nougat [2] extract structured content from PDFs; LayoutLM [14] learns layout-aware representations. DocMaster builds on MinerU and extends it with hierarchical tree construction and semantic indexing. Constrained Clustering. Wagstaff et al. [11] introduce constrained K-Means with instance-level supervision; Basu et al. [1] extend it to pairwise constraints. DocMaster adapts PC-KMeans with LLM-generated constraints derived from document semantics, combining clustering efficiency with LLM judgment. 4