Hierarchical semantic-driven retrieval enhancement generation method and system
By constructing a hierarchical semantic-driven retrieval enhancement generation method, the problems of semantic fragmentation and resource waste in RAG technology in long documents and professional texts are solved, and efficient and accurate document retrieval and question answering are achieved.
Patent Information
- Application Number
- CN202510706077.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-12
AI Technical Summary
Existing RAG technology is prone to semantic fragmentation and contextual disconnection when processing long documents and complex professional texts. In addition, the fixed retrieval strategy lacks dynamic perception, resulting in inaccurate retrieval results and waste of computing resources.
A hierarchical semantics-driven retrieval enhancement generation method is constructed. By performing hierarchical parsing and recursive semantic boundary splitting on documents, combined with a large language model for knowledge point extraction and summary generation, top-down multi-level title path transmission and bottom-up semantic convergence are adopted to dynamically adjust the retrieval threshold to achieve adaptive hierarchical retrieval.
It effectively preserves the hierarchical structure and semantic boundaries of documents, improves the accuracy and efficiency of long documents and professional field questions and answers, reduces computing resource consumption, and generates more coherent and accurate answers.
Smart Images

Figure CN120632119A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of hierarchical semantic-driven retrieval enhancement generation, and in particular to a hierarchical semantic-driven retrieval enhancement generation method and system. Background Art
[0002] With the rapid development of artificial intelligence and natural language processing technologies, Retrieval-Augmented Generation (RAG) technology based on Large Language Models (LLMs) has become an effective means of solving knowledge-intensive tasks. By combining the semantic retrieval of external knowledge bases with the generation capabilities of language models, RAG significantly improves tasks such as complex question-answering, multi-turn conversations, and text summarization. This provides a new approach to overcoming the limitations of traditional language models in terms of knowledge timeliness and domain-specific understanding.
[0003] Most existing RAG technologies use fixed-length text blocks and simple flat index structures, ignoring the natural hierarchical structure and semantic boundaries of documents. This approach often leads to semantic fragmentation and contextual disconnection when processing long documents and complex professional texts, reducing the accuracy of retrieval results and the coherence of generated content. In addition, mainstream RAG methods usually adopt a fixed top-k retrieval strategy, lacking dynamic perception of the query and document semantic distribution, and are prone to missing key information or introducing a large amount of irrelevant redundant information, increasing computing resource consumption and affecting system efficiency. Although some studies have attempted to optimize through recursive abstraction, multi-level aggregation or hybrid retrieval mechanisms, how to achieve adaptive dynamic adjustment of retrieval while maintaining the semantic integrity of the document level remains a difficult problem that needs to be solved in the current technical field.
[0004] Therefore, in the retrieval enhancement generation technology based on large language models, how to build an index system that can not only retain the natural hierarchical structure and semantic boundaries of the document, but also dynamically adjust the retrieval scope according to the semantic similarity distribution, and improve the accuracy and efficiency of long documents and professional field questions and answers, has become an urgent problem that needs to be solved. Summary of the Invention
[0005] This application provides a hierarchical semantic-driven retrieval enhancement generation method and system, which aims to solve the problem of how to build an index system that can not only preserve the natural hierarchical structure and semantic boundaries of documents, but also dynamically adjust the retrieval scope according to the semantic similarity distribution, thereby improving the accuracy and efficiency of long documents and professional field questions and answers.
[0006] In a first aspect, a hierarchical semantic-driven retrieval enhancement generation method is provided, the method comprising:
[0007] Perform hierarchical document parsing on a multi-level document collection containing chapters, titles, and paragraphs, structuring each document into a tree structure, where each node in the tree structure includes a node identifier, a parent node identifier, a multi-level title path, a sequence number, a core knowledge point, a content summary, the original content, and a list of child node identifiers;
[0008] For the text content of the nodes in the tree structure, a recursive semantic boundary splitting strategy is adopted to recursively split the node content exceeding the preset maximum length threshold based on sentence and paragraph delimiters, generate child nodes and maintain the parent-child relationship;
[0009] Based on a large language model, we use designed prompt words to extract knowledge points and generate summaries from the text content of each node, forming a refined node-level semantic representation. The knowledge points are composed of multiple keywords, and the summary is a brief description of the node content.
[0010] Bidirectional semantic enhancement: The root node title to the current node title are sequentially spliced to form a top-down multi-level title path. The knowledge points and summary information of all child nodes are passed from bottom to top to generate the comprehensive knowledge points and summary of the parent node, forming a semantic completion of the hierarchical structure.
[0011] In response to a user input query, the query text is converted into a vector representation generated based on a pre-trained text embedding model; a similarity distribution is calculated based on the query vector and the combined semantic representation of each node's multi-level title path, knowledge point, and summary, and the cosine similarity is used to measure the degree of semantic match between the query and the node to obtain a similarity set for all nodes at the current level;
[0012] The threshold of the current level is dynamically adjusted according to the statistical distribution characteristics of the similarity. The threshold calculation formula is:
[0013] θ raw =β·s max -(1-γ·CV)·(s max -μ);
[0014] Where: θ raw : The original dynamic threshold calculated based on the similarity distribution characteristics; s max : the maximum value of the similarity of the current level; μ: the average value of the similarity of the current level; σ: the standard deviation of the similarity of the current level; CV = σ / μ: coefficient of variation, indicating the degree of dispersion of the similarity distribution; β: basic retention coefficient (0 < β ≤ 1), controlling the basic threshold ratio; γ: distribution sensitivity coefficient (0 ≤ γ ≤ 1), controlling the sensitivity to the similarity distribution;
[0015] Through the recursive hierarchical retrieval algorithm, starting from the root node, the nodes with similarity greater than or equal to the threshold θ are screened out, where θ is the final threshold adjusted by the safety mechanism. If the node is a non-leaf node, the screening operation is repeated on the child nodes until the leaf node is reached, forming the final candidate retrieval result set.
[0016] In the above solution, optionally, after extracting knowledge points and generating content summaries from the text content of each node using the designed prompt words based on the large language model, the method further includes:
[0017] Achieve top-down semantic transfer by constructing a multi-level heading path for each node, encoding its contextual information in the document hierarchy into a structure-aware semantic representation;
[0018] Achieve bottom-up semantic convergence. For each non-leaf node, aggregate the knowledge points and summary information of all its child nodes based on the large language model to generate the comprehensive knowledge points and content summary of the parent node, forming a hierarchical semantic expression system from concrete to abstract.
[0019] In the above solution, optionally, after forming the final candidate search result set, the method further includes:
[0020] Set up a search security mechanism, including setting a lower limit for the similarity threshold, limiting the minimum and maximum number of nodes retained at each layer, and the maximum number of overall returned results, to prevent a large number of irrelevant nodes from being selected due to a too low threshold or key information from being missed due to a too high threshold;
[0021] The search result set is integrated with the input query in a structured format, which includes a multi-level title path, sequence number and original content of each node, and the integrated context is input into the large language model to complete the search-enhanced text generation answer.
[0022] In the above solution, optionally, the recursive semantic boundary splitting strategy specifically includes:
[0023] (a) Determine whether the node text length exceeds a preset maximum length threshold;
[0024] (b) If the threshold is exceeded, segment splitting is performed based on delimiters such as period, comma, and line break;
[0025] (c) Repeat steps (a) and (b) for each segment after splitting until the text length of all sub-nodes does not exceed the threshold;
[0026] (d) Generate child nodes and update the child node list and node sequence information of the parent node.
[0027] In the above scheme, optionally, the knowledge point extraction and content summary generation are completed by calling a large language model and combining preset prompt words. The prompt words include knowledge point keyword extraction and summary content description, ensuring that the knowledge point covers the core content of the node and the summary expresses the overall semantics of the node.
[0028] In the above solution, optionally, the top-down multi-level title path is formed by sequentially concatenating the root node title to the current node title, and each level of title in the path participates in the construction of the node semantic representation as structural context information;
[0029] The bottom-up semantic convergence adopts aggregated prompt words based on a large language model, inputs the knowledge points and summary information of all child nodes into the model, generates comprehensive knowledge points and summaries of parent nodes, and forms semantic completion of a hierarchical structure.
[0030] In the above scheme, optionally, during the recursive hierarchical retrieval process, node similarity is calculated based on the concatenated text of the node's multi-level title path, knowledge points and abstracts, a node vector is generated through a text embedding model, and cosine similarity is calculated with the query vector.
[0031] In the above solution, optionally, the security mechanism includes:
[0032] Set an absolute lower limit for the similarity threshold to avoid selecting nodes with too low similarity;
[0033] Set the minimum number of nodes to be retained at each level to ensure that the hierarchical search results cover the necessary nodes;
[0034] Set the maximum number of nodes to be retained at each layer to control the retrieval granularity and prevent redundancy;
[0035] Set an upper limit on the total number of search results to limit the length of the input context of the generated model.
[0036] In the above scheme, the optional, structured integrated context data format includes a multi-level title path string, node sequence number, and original text content of each retrieval node, ensuring that the generated model input contains complete hierarchical semantic context information.
[0037] In a second aspect, a hierarchical semantics-driven retrieval enhancement generation system is provided, the system comprising:
[0038] Document parsing module, used to parse the chapter titles of the input document and construct multi-level tree structure nodes;
[0039] A recursive splitting module is used to perform semantic boundary splitting on node content according to a preset length threshold to generate child nodes;
[0040] The semantic enhancement module is used to call the large language model to extract node knowledge points, generate summaries, and implement top-down and bottom-up semantic transmission and aggregation;
[0041] Vector calculation module, used to generate vector representations of queries and nodes and calculate similarity distribution;
[0042] Adaptive threshold calculation module, used to dynamically calculate the retrieval threshold based on similarity statistical features;
[0043] A recursive retrieval module is used to recursively filter tree structure nodes based on a threshold value and output a retrieval result set;
[0044] The safety mechanism module is used to control the number of nodes to be retained and the upper and lower limits of similarity thresholds to prevent information overload or shortage;
[0045] Generate an interface module to integrate search results with queries to form a structured context and call a large language model to complete text generation.
[0046] Compared with the prior art, this application has at least the following beneficial effects:
[0047] This application is based on further analysis and research of existing technical problems, and it is recognized that in the retrieval enhancement generation technology based on large language models, how to construct an index system that can not only retain the natural hierarchical structure and semantic boundaries of the document, but also dynamically adjust the retrieval scope according to the distribution of semantic similarity, and improve the accuracy and efficiency of long documents and professional field questions and answers, has become an urgent problem to be solved. By constructing a tree-like hierarchical structure based on the document chapter titles, the natural hierarchical relationship and semantic boundaries of the document are effectively retained, and the semantic fragmentation and context breakage problems caused by traditional fixed-length block segmentation are solved. This method adopts a recursive semantic boundary splitting strategy to refine over-long text nodes, which not only ensures the integrity of semantics, but also meets the model input length limit and avoids the loss of semantic information. At the same time, the node knowledge point extraction and summary generation are realized through the large language model, combined with the top-down multi-level title path transmission and bottom-up content aggregation, which enhances the structural perception and semantic expression ability of the node, and makes up for the deficiency of the traditional method in the lack of hierarchical context. In the retrieval stage, based on the similarity distribution between the query and the node semantic representation, the adaptive retrieval threshold is dynamically calculated to replace the fixed top-k retrieval strategy, so as to realize the intelligent screening of different queries and hierarchical nodes, balance the information coverage and redundancy suppression, and significantly improve the retrieval efficiency and accuracy. In addition, the safety mechanism of setting the threshold and the number of retrievals ensures that the retrieval process neither misses key information nor interferes with irrelevant content, thereby optimizing the consumption of computing resources. Finally, the structured retrieval results are integrated with the query to provide a complete and coherent context input for the generation model, thereby improving the accuracy and coherence of the generated answers. In summary, the technical solution of the present application effectively solves the key technical problems of semantic structure destruction, retrieval rigidity and information redundancy in the background technology when large language models process hierarchically complex documents, realizes the semantic integrity preservation and efficient dynamic retrieval of hierarchical documents, and significantly improves the performance and resource utilization efficiency of long documents and professional field questions and answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A flowchart of a hierarchical semantics-driven search enhancement generation method provided in one embodiment of the present application;
[0049] Figure 2 A schematic diagram of the HiSem-RAG method framework provided in one embodiment of the present application;
[0050] Figure 3 A schematic diagram of the accuracy and resource consumption experimental results provided for one embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0052] In one embodiment, Figure 1 As shown, a hierarchical semantic-driven retrieval enhancement generation method is provided, comprising the following steps:
[0053] Perform hierarchical document parsing on a multi-level document collection containing chapters, titles, and paragraphs, structuring each document into a tree structure, where each node in the tree structure includes a node identifier, a parent node identifier, a multi-level title path, a sequence number, a core knowledge point, a content summary, the original content, and a list of child node identifiers;
[0054] For the text content of the nodes in the tree structure, a recursive semantic boundary splitting strategy is adopted to recursively split the node content exceeding the preset maximum length threshold based on sentence and paragraph delimiters, generate child nodes and maintain the parent-child relationship;
[0055] Based on a large language model, we use designed prompt words to extract knowledge points and generate summaries from the text content of each node, forming a refined node-level semantic representation. The knowledge points are composed of multiple keywords, and the summary is a brief description of the node content.
[0056] Bidirectional semantic enhancement: The root node title to the current node title are sequentially spliced to form a top-down multi-level title path. The knowledge points and summary information of all child nodes are passed from bottom to top to generate the comprehensive knowledge points and summary of the parent node, forming a semantic completion of the hierarchical structure.
[0057] In response to a user input query, the query text is converted into a vector representation generated based on a pre-trained text embedding model; a similarity distribution is calculated based on the query vector and the combined semantic representation of each node's multi-level title path, knowledge point, and summary, and the cosine similarity is used to measure the degree of semantic match between the query and the node to obtain a similarity set for all nodes at the current level;
[0058] The threshold of the current level is dynamically adjusted according to the statistical distribution characteristics of the similarity. The threshold calculation formula is:
[0059] θ raw =β·s max -(1-γ·CV)·(s max -μ);
[0060] Where: θ raw : The original dynamic threshold calculated based on the similarity distribution characteristics; s max: the maximum value of the similarity of the current level; μ: the average value of the similarity of the current level; σ: the standard deviation of the similarity of the current level; CV = σ / μ: coefficient of variation, indicating the degree of dispersion of the similarity distribution; β: basic retention coefficient (0 < β ≤ 1), controlling the basic threshold ratio; γ: distribution sensitivity coefficient (0 ≤ γ ≤ 1), controlling the sensitivity to the similarity distribution;
[0061] Through the recursive hierarchical retrieval algorithm, starting from the root node, the nodes with similarity greater than or equal to the threshold θ are screened out, where θ is the final threshold adjusted by the safety mechanism. If the node is a non-leaf node, the screening operation is repeated on the child nodes until the leaf node is reached, forming the final candidate retrieval result set.
[0062] In this embodiment, after extracting knowledge points and generating content summaries from the text content of each node using the designed prompt words based on the large language model, the following steps are also included:
[0063] Achieve top-down semantic transfer by constructing a multi-level heading path for each node, encoding its contextual information in the document hierarchy into a structure-aware semantic representation;
[0064] Achieve bottom-up semantic convergence. For each non-leaf node, aggregate the knowledge points and summary information of all its child nodes based on the large language model to generate the comprehensive knowledge points and content summary of the parent node, forming a hierarchical semantic expression system from concrete to abstract.
[0065] In this embodiment, after forming the final candidate search result set, the following steps are further included:
[0066] Set up a search security mechanism, including setting a lower limit for the similarity threshold, limiting the minimum and maximum number of nodes retained at each layer, and the maximum number of overall returned results, to prevent a large number of irrelevant nodes from being selected due to a too low threshold or key information from being missed due to a too high threshold;
[0067] The search result set is integrated with the input query in a structured format, which includes a multi-level title path, sequence number and original content of each node, and the integrated context is input into the large language model to complete the search-enhanced text generation answer.
[0068] In this embodiment, the recursive semantic boundary splitting strategy specifically includes:
[0069] (a) Determine whether the node text length exceeds a preset maximum length threshold;
[0070] (b) If the threshold is exceeded, segment splitting is performed based on delimiters such as period, comma, and line break;
[0071] (c) Repeat steps (a) and (b) for each segment after splitting until the text length of all sub-nodes does not exceed the threshold;
[0072] (d) Generate child nodes and update the child node list and node sequence information of the parent node.
[0073] In this embodiment, the knowledge point extraction and content summary generation are completed by calling a large language model and combining preset prompt words. The prompt words include knowledge point keyword extraction and summary content description, ensuring that the knowledge point covers the core content of the node and the summary expresses the overall semantics of the node.
[0074] In this embodiment, the top-down multi-level title path is formed by sequentially concatenating the root node title to the current node title, and each level of title in the path participates in the construction of the node semantic representation as structural context information;
[0075] The bottom-up semantic convergence adopts aggregated prompt words based on a large language model, inputs the knowledge points and summary information of all child nodes into the model, generates comprehensive knowledge points and summaries of parent nodes, and forms semantic completion of a hierarchical structure.
[0076] In this embodiment, during the recursive hierarchical retrieval process, node similarity is calculated based on the concatenated text of the node's multi-level title path, knowledge points, and abstracts. A node vector is generated through a text embedding model, and cosine similarity is calculated with the query vector.
[0077] In this embodiment, the security mechanism includes:
[0078] Set an absolute lower limit for the similarity threshold to avoid selecting nodes with too low similarity;
[0079] Set the minimum number of nodes to be retained at each level to ensure that the hierarchical search results cover the necessary nodes;
[0080] Set the maximum number of nodes to be retained at each layer to control the retrieval granularity and prevent redundancy;
[0081] Set an upper limit on the total number of search results to limit the length of the input context of the generated model.
[0082] In this embodiment, the structured integrated context data format includes a multi-level title path string, a node sequence number, and the original text content of each search node, ensuring that the generated model input contains complete hierarchical semantic context information.
[0083] In one embodiment, a hierarchical semantics-driven RAG method is provided.
[0084] Traditional retrieval-augmented generation (RAG) methods have limitations when processing documents with hierarchical structures, mainly manifested in the loss of semantic integrity, destruction of structural information, and insufficient information coverage and redundancy caused by fixed retrieval strategies. To improve the accuracy of question-answering in hierarchical documents and reduce computing resource consumption, a hierarchical semantic-driven retrieval-augmented generation method, Hierarchical Semantic RAG (HiSem-RAG), is proposed. The method consists of three key modules: first, by constructing a hierarchical semantic index, the semantic boundaries and original structural relationships between chapters and paragraphs are preserved, effectively reconstructing the document context; second, a bidirectional semantic enhancement mechanism introduces title and abstract information to achieve information supplementation and two-way propagation between contexts; finally, a distribution-aware adaptive threshold retrieval strategy dynamically adjusts the retrieval scope based on the similarity distribution, thereby suppressing redundancy and saving computing costs while ensuring retrieval accuracy. On the professional question-answering dataset EleQA, HiSem-RAG achieved an overall accuracy of 82.00%, an improvement of 5.04 and 3.98 percentage points over the HyDE and RAPTOR methods, respectively, while also saving computational resources. On the long-document question-answering dataset LongQA, it achieved a ROUGE-L score of 0.599 and a BERT_F1 value of 0.839. Ablation experiments demonstrated significant complementarity between the modules, with even more impressive results on the long-document question-answering task. These results demonstrate the potential of this method to improve the quality and efficiency of semantic retrieval in complex document contexts.
[0085] Retrieval-augmented generation (RAG) technology was developed to address the limitations of large language models in terms of knowledge timeliness, domain-specific understanding, and generation stability. By combining external knowledge retrieval with the generation capabilities of language models, RAG enables the model to dynamically acquire the latest and most specialized semantic information during inference, thus breaking through the knowledge boundaries of "closed-loop" parameter learning.
[0086] Since RAG was first proposed by Lewis et al., it has been widely used in tasks such as question answering, summarization, and multi-round dialogue. Early RAG methods were mostly based on dense passage retrieval (DPR), using a dual encoder structure to generate vector representations for queries and documents respectively, and achieving efficient semantic retrieval through similarity matching. As research deepens, RAG systems have continued to evolve in two key aspects: semantic index construction and retrieval mechanism design. The former has developed from a simple fixed-length block index to a complex index structure that is semantically aware, structurally aware, and hierarchically aware; the latter has expanded from single vector matching to hybrid retrieval and adaptive mechanisms. For example, Self-RAG uses a model self-reflection mechanism to dynamically determine when to call external knowledge, significantly improving the adaptability of the method.
[0087] Despite rapid progress, current RAG methods still face the following two key bottlenecks when processing documents with complex structures, large spans, and dense information:
[0088] Lack of semantic structure: Most methods mechanically segment documents into fixed-length segments for retrieval, ignoring the natural hierarchical organization of documents, such as the relationships between titles, paragraphs, and chapters. This approach easily destroys semantic boundaries and logical frameworks, resulting in fragmented and weakly contextualized retrieval results. This makes it difficult for models to accurately capture key information and generate effective results, especially when processing long documents.
[0089] Rigid retrieval quantity: Current mainstream methods generally use a fixed top-k strategy, which lacks the ability to perceive the knowledge distribution within a document. When the K value is too small, key knowledge is easily missed; when the K value is too large, a large amount of irrelevant content is introduced, increasing the computational overhead of the language model, resulting in generation interference and wasted resources.
[0090] To improve the accuracy of question-answering in complex documents while ensuring quality and reducing resource consumption, this paper proposes a hierarchical semantics-driven retrieval enhancement generation method. This method fully utilizes the hierarchical structure and semantic distribution characteristics of documents to achieve the unified goals of semantic enhancement and efficiency optimization through three key designs:
[0091] Hierarchical semantic index construction: Based on the natural structure of the document, such as chapters, titles, and paragraphs, a multi-granularity semantic unit index is constructed, preserving the original semantic boundaries and structural hierarchy, enabling hierarchical retrieval from chapters to paragraphs.
[0092] Bidirectional semantic enhancement mechanism: Introducing semantic information such as titles, knowledge points, and summaries to achieve vertical and horizontal information transfer and semantic completion, enhancing cross-level semantic connections;
[0093] Distribution-aware adaptive threshold retrieval strategy: Dynamically sets the retrieval threshold based on the similarity distribution of semantic units at each layer, replacing the fixed top-k approach to achieve a dynamic balance between information integrity and computational efficiency.
[0094] A comprehensive evaluation of HiSem-RAG on both professional domain question answering and long document question answering tasks demonstrated that the method outperformed existing baselines across multiple evaluation metrics, effectively conserving computational resources while maintaining high generation quality. Further ablation experiments validated the synergistic effect between the three core modules, making it particularly suitable for question answering scenarios with complex hierarchical structures and dense content.
[0095] In this embodiment, if Figure 2As shown in Figure 2, the core concept of HiSem-RAG is to build an indexing system that preserves document hierarchical structure and supports intelligent retrieval. The approach consists of two main components: the establishment of a hierarchical semantic index structure and a distribution-aware adaptive threshold retrieval mechanism based on this structure. This design fully leverages the inherent hierarchical nature of documents, providing efficient and accurate retrieval services while preserving semantic integrity.
[0096] Hierarchical document parsing is a fundamental step in the HiSem-RAG method, and its core goal is to preserve the natural structure of the document and convert the original linear text into a tree structure with hierarchical semantic relationships. This process mainly includes three steps: title hierarchy identification is used to clarify the structural boundaries of the document; tree structure construction organizes the document into multi-level node representations; and long content recursive splitting further divides the content of over-long paragraphs in nodes at each level to control the retrieval granularity and context length. This method is essentially a processing mechanism that combines hierarchical structure modeling and semantic block control. It not only preserves the semantic integrity of the document, but also provides a structured foundation suitable for long document processing, providing support for subsequent efficient retrieval and generation.
[0097] First, unlike traditional fixed-length chunking, we parse the multi-level title structure of the document and convert the document into a tree structure with a hierarchical relationship. Formally, given a document d with a hierarchical structure, we parse it into a tree structure T = {n1,n2,...,n m}. Among them, node n i Represents a semantic unit in the document, which can be a chapter, section, or other content fragments divided based on titles. This structure reflects the natural hierarchical organization of the document. Each node can be a carrier of content or a container of other nodes. Each node n i Contains the following information:
[0098] Node identifier id: the unique identifier of the node;
[0099] Parent node identifier parent_id: the parent node pointer of the node;
[0100] Multi-level title path T path : The concatenation from the root node to the node title;
[0101] Sequence number index: the sequence number of the node after recursive splitting;
[0102] Core knowledge point K: the knowledge point of the node content;
[0103] Content summary S: a concise expression of the content of this node;
[0104] Original content: the original content of the node (empty for non-leaf nodes);
[0105] Child node id list children: the ids of all child nodes of the node (leaf nodes are empty).
[0106] In order to deal with the possibility of excessively long node content, a recursive character splitting strategy is adopted to ensure that the split content fits the input limit of the model by identifying the delimiters of sentences and paragraphs, while maintaining the semantic integrity as much as possible. i If the content of content exceeds the preset threshold L max , recursive splitting is performed, and the split content fragments are used as their child nodes and the original position relationship is retained through the sequence information index to ensure semantic coherence.
[0107] To further improve the expressive quality of semantic units, we designed a bidirectional semantic enhancement mechanism. Based on the document hierarchy, this mechanism models information flow from two directions: top-down transmission of structural context to provide location awareness, and bottom-up aggregation of content summaries to enhance semantic generalization.
[0108] Semantic block compression and key knowledge extraction: First, the large language model is used to compress and reconstruct the content of each node, extract the knowledge points K and generate a summary S:
[0109] (K, S) = LLM(P, content)#(1)
[0110] The specific design of the prompt word P is shown in the first row of Table 1. This step effectively filters out redundant content, retains important information, and improves the compactness and usability of the node semantic representation.
[0111] Table 1 Overview of prompt word design:
[0112]
[0113]
[0114] Top-down semantic transfer: To enhance the structural positioning capability of each node, we construct its multi-level heading path T in the document hierarchy. path This representation reflects the context of the node in the entire document and helps improve the structure perception ability of retrieval. Assume that there are k nodes n1, n2, ..., n on the path from the root node to the current node in the document hierarchy. k , where n1 is the root node, n k Is the current node, title(n i ) represents node n i The title of the current node is the complete title path T path Defined as:
[0115]
[0116] Bottom-up semantic convergence: To strengthen the overall understanding of subordinate content by high-level nodes, we perform content aggregation on all nodes, aggregating the knowledge points and summaries of all their child nodes:
[0117] (K agg ,S agg )=LLM(P agg ,{(title i ,K i ,S i )} i∈Children )#(3)
[0118] Among them, K agg Represents the aggregated parent node knowledge point, S agg Represents the aggregated parent node summary, P agg is a specially designed aggregation prompt word, the specific design of which is shown in the second row of Table 1. This structure enables high-level nodes to summarize the core semantics of the subordinate content, while lower-level nodes contain detailed information, forming a complete semantic hierarchy from abstract to concrete, providing a multi-granular index structure for subsequent retrieval. The specific algorithm for constructing a hierarchical semantic index is shown in Algorithm 1.
[0119] Algorithm 1, hierarchical semantic index construction algorithm:
[0120] Input: Markdown file collection docs, maximum block size max_size;
[0121] Output: hierarchical semantic index index;
[0122]
[0123]
[0124] Based on hierarchical semantic indexing, this embodiment designs a distribution-aware adaptive threshold retrieval mechanism that fully leverages the hierarchical characteristics of documents to achieve intelligent retrieval. Traditional retrieval systems typically use a fixed top-k strategy to select relevant documents, returning a fixed number of the most similar results regardless of the similarity distribution of the query results. This approach has significant limitations: when multiple semantic units are highly relevant to the query, important information may be missed; and when most semantic units have low relevance to the query, noise may be introduced.
[0125] Our hierarchical recursive retrieval algorithm starts from the root node and explores related nodes layer by layer. For a user query q, we calculate the similarity between its vector representation and the semantically enhanced representation of each node in the current layer, using the "multi-level title path + knowledge point + summary" as the similarity calculation object:
[0126] sim(q,n i )=cosine(Embed(q),Embed(T path (n i )+K i +S i ))#(4);
[0127] Among them, cosine represents the cosine similarity function, Embed(q) is the vector representation of the query, T path (n i ) is the multi-level title path of the node, K i is the knowledge point of the node, S i is the summary of the node. In this way, we obtain a similarity array that reflects the relevance between the query and the semantically enhanced representation of each node.
[0128] In response to these similarity distributions, we proposed a distribution-aware adaptive threshold mechanism that dynamically adjusts the threshold of the current level based on the statistical distribution characteristics of the similarity. Only nodes with similarity greater than or equal to the threshold will be selected as candidate nodes for the next level of retrieval, all the way to the leaf node. The threshold calculation formula is:
[0129] θ raw =β·s max -(1-γ·CV)·(s max -μ)#(5);
[0130] Where: θ raw : The original dynamic threshold calculated based on the similarity distribution characteristics; s max : The maximum value of the similarity of the current level; μ: The average value of the similarity of the current level; σ: The standard deviation of the similarity of the current level; CV = σ / μ: Coefficient of variation, indicating the degree of dispersion of the similarity distribution; β: Basic retention coefficient (0 < β ≤ 1), controlling the basic threshold ratio; γ: Distribution sensitivity coefficient (0 ≤ γ ≤ 1), controlling the sensitivity to the similarity distribution.
[0131] This mechanism sets the initial threshold based on the maximum similarity. When the similarity distribution is more dispersed (the CV value is larger), the system adopts a more relaxed screening standard; when the distribution is concentrated (the CV value is smaller), the system adopts a more stringent standard.
[0132] However, in practical applications, some extreme cases may occur. For example, when all nodes have low similarity, the original threshold may be too low, resulting in a large number of low-correlation nodes being selected, which in turn causes the length of the transferred context to exceed the input threshold of the large model. To cope with these extreme cases, the algorithm sets up a comprehensive safety mechanism to calculate the final threshold θ:
[0133] Similarity threshold lower limit θ min , ensuring that nodes with too low similarity are not selected;
[0134] Each layer retains at least k min The minimum number of nodes to be retained is limited to prevent filtering too many potentially related nodes;
[0135] Each layer retains at most k max Upper limit control of each node to avoid introducing too much noise;
[0136] The overall limit on the maximum number of results returned controls the scale of the search.
[0137] After the search is complete, HiSem-RAG enters the generation phase, integrating the user query and search results into a structured context for the large language model to generate answers. Unlike the search phase, the generation phase uses "multi-level heading path + sequence number + original content" as the context components.
[0138] Through this distribution-aware recursive retrieval mechanism, the system demonstrates remarkable intelligent adaptability: when the query's relevance to some nodes is significantly higher than to others, the system automatically raises the threshold to retain only those highly relevant nodes. When all nodes have similar and high relevance to the query, the system appropriately lowers the threshold to retain more potentially relevant information, thus achieving a dynamic balance between retrieval accuracy and resource consumption in different query scenarios. The specific algorithm implementation is shown in Algorithm 2.
[0139] Algorithm 2: Distribution-aware adaptive threshold retrieval algorithm:
[0140] Input: query q, document hierarchy tree root node root, node dictionary nodes;
[0141] Output: related node list results;
[0142]
[0143] ifIsLeafNode(node)thenresults←results∪{(node,sim)}
[0144] else SearchLevel(GetChildren(node),level+1) / / recursively search child nodes
[0145] By organically combining the hierarchical semantic indexing structure with the distribution-aware adaptive threshold retrieval mechanism, HiSem-RAG provides a complete solution for processing professional documents with complex hierarchical structures. It can balance the comprehensiveness and accuracy of retrieval and provide high-quality contextual information for large language models.
[0146] To verify the effectiveness of the HiSem-RAG method, we evaluated various benchmarks on the public power domain expertise dataset EleQA and the self-built long-form Question Answering (LongQA) dataset.
[0147] EleQA is a publicly available, high-quality dataset in the power engineering field, covering core expertise in power system operation, equipment maintenance, and safety regulations. This dataset contains 32,610 professional regulations and 19,560 question-answer pairs. The dataset features a balanced distribution of question types, a wide range of coverage, and a high degree of professionalism and structure. It serves as an important benchmark for evaluating models' ability to understand and apply vertical domain knowledge.
[0148] LongQA focuses on long-document question answering, aiming to test the comprehensive capabilities of RAG systems in handling long texts, multi-layered structures, and complex semantic relationships. Based on pre-set screening criteria, we selected 27 long documents from technical documents and e-books that are representative in terms of structure, subject matter, and breadth of content, with an average length of 480,000 characters per document. These documents exhibit a high degree of hierarchical organization and structural complexity, covering knowledge from multiple professional fields, which helps to comprehensively test the model's cross-segment reasoning and information integration capabilities.
[0149] To construct question-and-answer pairs, this example employs a three-stage process: manual annotation, large-scale model-assisted generation, and expert review. First, questions are manually designed to cover information needs at different levels and across different spans, ensuring a diverse range of question types. The large-scale model is then used to compress the content of the designated document and suggest answers, generating preliminary answers. Finally, annotators with domain backgrounds review each answer, supplementing or revising the model-generated segments to ensure the accuracy and completeness of the question-and-answer quality.
[0150] Ultimately, we constructed 279 high-quality question-answer pairs, with an average question-answer length of 511.23 characters. The main challenges of the LongQA dataset lie in its large document span, complex semantic relationships between paragraphs, and the need for multi-step reasoning and cross-level information integration. It is suitable for research tasks that place high demands on long text processing capabilities.
[0151] The two datasets complement each other in terms of scale, structure, knowledge domain, and evaluation focus, and together form the experimental basis for a comprehensive performance evaluation of the HiSem-RAG method. Table 2 shows their key statistical characteristics and comparison dimensions.
[0152] Table 2 Experimental dataset statistics:
[0153]
[0154] This study designed three sets of systematic experiments: baseline model comparison experiments, resource consumption comparison experiments, and ablation experiments, which were used to evaluate the overall performance, resource consumption, and contribution of each component of the HiSem-RAG method.
[0155] The baseline model comparison experiment aims to comprehensively evaluate the advantages of HiSem-RAG over existing RAG methods. We selected five representative RAG methods as the comparison baseline, covering traditional retrieval models and advanced RAG techniques.
[0156] For traditional retrieval models, two benchmark methods were selected: BM25 and DPR. BM25 calculates relevance based on the term frequency-inverse document frequency statistical method and does not rely on neural networks. DPR uses a dual-tower neural network encoder to map queries and documents into a shared vector space for similarity calculation.
[0157] In terms of advanced RAG technology, three currently leading methods were selected: HyDE generates hypothetical documents as retrieval agents through large models to enhance query representation; Meta-Chunking adopts an adaptive chunking strategy, combining perplexity and boundary signals to optimize text segmentation; RAPTOR constructs a document tree structure based on recursive abstraction technology to achieve multi-level information integration and hierarchical retrieval.
[0158] In all experiments, we use the same base model configuration: GLM-4-flash for the large language model and BGE-M3 for the text embedding model.
[0159] The resource consumption comparison experiment aims to evaluate the effectiveness of the distribution-aware adaptive threshold mechanism in improving retrieval efficiency and reducing computational overhead. To verify the effectiveness of this mechanism, we designed a resource consumption comparison under different retrieval strategies and analyzed the trade-off between the number of retrievals and model performance.
[0160] In the experimental setup, we replaced the fixed number of searches (topk = 5) in DPR and HyDE with a dynamic search strategy based on an adaptive threshold (ranging from 1 to 7). We also replaced the adaptive threshold in HiSem-RAG with a fixed search strategy for each layer (topk = 2, 3). We compared and analyzed the differences in resource consumption between the fixed search strategy and the adaptive threshold strategy.
[0161] Ablation experiments analyze the independent contributions of HiSem-RAG's components and their synergistic effects to validate the rationality of the system design. We systematically remove or replace key components and observe changes in system performance to assess the importance of each module.
[0162] Specifically, this example constructs three simplified versions: (1) removing the hierarchical indexing module and using traditional fixed-window partitioning; (2) removing the semantic enhancement module and omitting the use of title information transfer and knowledge point extraction; and (3) removing the distribution-aware adaptive threshold module and adopting a fixed number of retrieval strategies. By comparing the performance of these simplified versions with the full HiSem-RAG on two datasets, we can quantitatively evaluate the impact of each component on different types of tasks and gain a deeper understanding of its mechanisms.
[0163] We designed differentiated evaluation metrics for different question types to comprehensively and accurately assess the performance of each method. For multiple-choice, judgment, and fill-in-the-blank questions, we used accuracy as the primary evaluation metric, which directly reflects the model's ability to correctly answer questions. Accuracy is defined as the ratio of the number of questions for which the model gave the correct answer to the total number of questions:
[0164]
[0165] Evaluation criteria vary depending on the question type. Multiple-choice and true / false questions are evaluated using strict matching criteria, while fill-in-the-blank questions use a semantic judgment approach, combining a large language model and expert review to assess the correctness of the answers. The standard prompts used for fill-in-the-blank questions are shown in the third row of Table 1.
[0166] For question-answering, we use three evaluation metrics: BERT score, ROUGE-L, and MRR@K. The BERT score is an evaluation method based on semantic similarity. By comparing the proximity of generated text to reference text in the semantic space, it can capture responses that differ in expression but share similar semantics. This metric does not rely on superficial text matching but instead examines deep semantic understanding, making it particularly suitable for evaluating the quality of open-ended question answering. It is calculated based on word-level semantic similarity:
[0167]
[0168] Where BERT_C is the word set of the generated answer, |BERT_C| is the number of word units of the generated answer, BERT_Ref is the word set of the standard answer, |BERT_Ref| is the number of word units of the standard answer, BERT_P is the precision rate, BERT_R is the recall rate, sim(x i ,y j ) represents the word x in the candidate sentencei and the word y in the reference sentence j The cosine similarity between .
[0169] ROUGE-L is a sequence matching-based evaluation method that calculates the longest common subsequence between the generated text and the reference text to assess whether the generated answer accurately covers the core information and maintains the rationality of the word order. Compared to the exact matching of n-grams, ROUGE-L focuses more on the overall similarity of the text structure and can tolerate local changes in the word order in the text. This indicator is calculated as follows:
[0170]
[0171] Where ROUGE_X represents the standard answer, ROUGE_Y represents the generated answer, LCS represents the longest common subsequence length, ROUGE_R represents the recall rate, and ROUGE_P represents the precision rate. We set the balance factor β = 1 to balance the precision and recall rates.
[0172] Mean Reciprocal Rank (MRR) is an important metric for evaluating the ranking quality of a retrieval system, focusing specifically on the ranking position of the correct answer in the retrieval results. This metric gives higher weight to correct results that are ranked at the top, reflecting the retrieval system's ability to rank relevant documents higher. MRR@K restricts consideration to only the top K results, and is calculated as:
[0173]
[0174] Where |Q| is the total number of queries, rank i represents the ranking of the correct answer to the i-th query in the retrieval results, and I(·) is an indicator function that ensures that only results with a ranking no greater than K are counted.
[0175] All experiments were conducted in an environment equipped with an Intel(R) Xeon(R) Platinum 8375C CPU@2.90GHz processor and an NVIDIA A800 80GB graphics processor.
[0176] In the HiSem-RAG method, adaptive retrieval thresholds are set, with a base retention coefficient of 0.9, a distribution sensitivity coefficient of 0.8, and a minimum node retention of 1, ensuring that at least one document node is retained at each level of retrieval. The maximum number of document nodes retained per level is limited to 7. An absolute similarity threshold of 0.3 sets the minimum similarity requirement for retrieval results. The final maximum number of retrieval results is set at 15 to balance information integrity and processing efficiency. The block length threshold is set at 2048 to ensure that text blocks at each level do not exceed the model's processing capacity.
[0177] The experimental results of the baseline model comparison are shown in Table 3.
[0178] Table 3. Comparison experimental results of baseline models:
[0179]
[0180] Experimental results show that the HiSem-RAG method has demonstrated good results in multiple evaluation dimensions. On the EleQA dataset, the overall accuracy of HiSem-RAG reached 82.00%, outperforming other baseline methods. Analysis of question types shows that HiSem-RAG achieved good results in the evaluation of multiple-choice questions and true-or-false questions, which is mainly due to the synergy of its three core mechanisms: hierarchical semantic indexing helps to maintain the integrity of semantic boundaries between paragraphs, bidirectional semantic enhancement conveys contextual information through title paths and knowledge point summaries, and adaptive thresholds effectively adjust retrieval strategies. It is worth noting that in the fill-in-the-blank question evaluation, HyDE is slightly ahead of HiSem-RAG and RAPTOR. This may be because it has certain advantages in accurately locating information fragments by generating hypothetical documents as retrieval agents. This also suggests the necessity of optimizing retrieval strategies for different task types.
[0181] In the LongQA question-answering evaluation, HiSem-RAG not only performed well in terms of generation quality indicators, but also achieved a ROUGE-L index of 0.599, a significant improvement over other methods. In the semantic similarity evaluation, BERT_F1 achieved a value of 0.839, also showing a certain advantage. These results show that hierarchical semantic indexing and dynamic similarity threshold mechanisms are helpful for processing long documents. When faced with long documents with an average of nearly 480,000 characters, HiSem-RAG can better preserve the document structure and adjust the retrieval granularity based on the query characteristics, alleviating the information fragmentation problem that traditional methods may face when processing long documents.
[0182] The retrieval ranking quality analysis also supports the above observations. In terms of the MRR@1 metric, HiSem-RAG achieved 0.458, approximately 8 percentage points higher than the second-place Meta-Chunking, indicating that this method is better at ranking relevant documents at the top. It is worth noting that HiSem-RAG's MRR@3 and MRR@5 values are relatively close, indicating that its search results are more concentrated in the top three, which helps reduce search noise. In contrast, RAPTOR's MRR metric increases more significantly with the K value, indicating that the relevance distribution of its search results is relatively dispersed.
[0183] HiSem-RAG, through the organic combination of hierarchical semantic indexing, bidirectional semantic enhancement, and distribution-aware adaptive thresholding, enables flexible adjustment of retrieval strategies while maintaining the overall structure of documents. It demonstrates significant advantages in most tasks, especially long document processing, and has practical value for handling complex knowledge question answering and long document comprehension tasks. Of course, there is still room for improvement in specific tasks, such as fill-in-the-blank questions, which also points to a direction for future research.
[0184] To verify the effectiveness of the distribution-aware adaptive threshold mechanism, we conducted a resource consumption comparison experiment, applied the adaptive threshold to the existing RAG method, and analyzed the impact of the adaptive threshold on the performance of HiSem-RAG. We changed the fixed number of searches (topk = 5) of DPR and HyDE to a dynamic search based on the adaptive threshold (ranging from 1 to 7), and replaced the adaptive threshold of HiSem-RAG with a fixed search strategy for each layer (topk = 2, 3). The experimental results are shown in Figure 2. Figure 3 shown.
[0185] Experimental results demonstrate that the adaptive threshold mechanism effectively balances retrieval quality and resource consumption. Applying this mechanism to traditional RAG methods can reduce resource consumption while maintaining nearly unchanged accuracy. For example, after adding an adaptive threshold to DPR, accuracy only decreased slightly by 0.06%, but token consumption decreased by 5.46%. After adding an adaptive threshold to HyDE, accuracy improved slightly while token consumption decreased by 5.75%. This demonstrates that the adaptive threshold can intelligently adjust the number of queries based on the characteristics of the query, avoiding excessive and irrelevant retrieval.
[0186] The analysis of different configurations of HiSem-RAG is more illustrative. When 2 document blocks are fixedly retrieved per layer, although the token consumption is the lowest (32.1 million), the accuracy is significantly limited (73.63%), indicating that insufficient information is retrieved; when 3 document blocks are fixedly retrieved per layer, the accuracy is improved to 76.62%, but the token consumption surges to 59.2 million, indicating obvious information redundancy. More importantly, despite consuming more resources, the accuracy of the fixed retrieval of 3 blocks is still significantly lower than that of the adaptive threshold scheme (82.00%). This is because a fixed top-k value may not only introduce redundancy, but also limit the flexibility of the retrieval range. In some layers, more document blocks may need to be retrieved to obtain key information, while in other layers, 1-2 document blocks may be sufficient.
[0187] The adaptive threshold HiSem-RAG can dynamically adjust the search scope according to different levels and query characteristics. It can expand the search scope (up to 7 document blocks) when necessary and narrow the search scope when information is concentrated, thereby improving accuracy while saving about 11% of computing resources. This mechanism enables the model to break out of the limitations of the fixed window and conduct more extensive exploration in certain key areas, avoiding the problem of missing important documents whose similarity is not the absolute highest due to the preset search quantity. These results prove that the fixed top-k search strategy has inherent limitations. Too small k values will lead to insufficient information, while too large k values will introduce redundant content and additional computational burden. The adaptive threshold mechanism can flexibly determine the optimal search quantity at different levels and for different queries by dynamically adjusting the search scope, which not only ensures the quality and breadth of the search, but also avoids unnecessary waste of resources.
[0188] To verify the effectiveness of each component module of HiSem-RAG, this study conducted a systematic ablation experiment, removing the three core modules of hierarchical indexing, semantic enhancement, and adaptive threshold respectively. The results are shown in Table 4.
[0189] Table 4 Ablation experiment results:
[0190]
[0191] Ablation experiments show the contributions of HiSem-RAG's components on different datasets. The three core modules show significant effects on both tasks, but their impact and mechanisms vary.
[0192] The hierarchical indexing module played a fundamental role on both datasets. On EleQA, removing the hierarchical index resulted in a 6.61% drop in overall accuracy, while on LongQA, ROUGE-L decreased by 23.4% and MRR@1 decreased by 27.3%. This phenomenon reflects the limitations of traditional fixed-window segmentation methods, which can easily undermine the semantic integrity of the text. Hierarchical indexing maintains the semantic coherence of text fragments by preserving the natural boundaries of paragraphs, enabling the model to more accurately grasp the logical structure of the document content. This integrity is particularly important in long document scenarios, as long texts often contain multi-level semantic structures. Maintaining their integrity helps the retrieval system better understand the organization of the document.
[0193] The semantic enhancement module has the most significant impact on system performance. Removing this module resulted in a 6.92% decrease in EleQA's overall accuracy, a 42.2% drop in LongQA's ROUGE-L, and a 67.9% decrease in MRR@1. This demonstrates that semantic enhancement plays a key role in connecting document fragments and supplementing contextual information: title information transfer supplements the semantic connections lost during the segmentation process, while knowledge point extraction and summary generation effectively filter out retrieval-irrelevant content. Experimental data shows that the lack of this semantic connection significantly impacts retrieval ranking quality, especially when processing long documents, where each fragment often requires more context to be accurately understood.
[0194] The adaptive threshold module has different effects on different task types. On EleQA, the module has the greatest impact on fill-in-the-blank questions. After removal, the accuracy dropped from 74.13% to 62.90%; on LongQA, MRR@1 dropped from 0.458 to 0.383. This verifies the limitations of the fixed retrieval quantity strategy, while the adaptive threshold can dynamically adjust the retrieval scope according to the query characteristics and explore a wider range of relevant areas in the hierarchical structure. This flexible mechanism is particularly important for fill-in-the-blank questions that require precise positioning of information, because key information may be distributed in areas where the similarity is not the highest but the correlation is strong. In long document processing, this mechanism improves retrieval quality while reducing information redundancy by balancing the breadth and depth of retrieval.
[0195] Overall, ablation experiments demonstrate the complementary effects of the three core modules. Hierarchical indexing provides the model with semantically complete building blocks, semantic enhancement supplements context and deepens text understanding, and adaptive threshold optimization retrieval strategies expand relevant information coverage. This combined design enables HiSem-RAG to adapt to different question-answering tasks, maintaining high performance while reducing computational resource consumption.
[0196] The HiSem-RAG method proposed in this embodiment effectively improves the performance of the retrieval-enhanced large language model by organically combining three mechanisms: hierarchical semantic index construction, bidirectional semantic enhancement, and distribution-aware adaptive thresholding. Experiments show that HiSem-RAG outperforms existing methods on multiple types of questions and datasets, especially in long-document question-answering scenarios. Hierarchical indexing maintains the integrity of the document structure, semantic enhancement deepens text understanding, and distribution-aware adaptive thresholding optimizes the retrieval strategy and reduces resource consumption. Ablation experiments verify the complementary effects of the three modules and their important contribution to the overall performance of the system, providing a new solution for information retrieval and generation in complex knowledge scenarios. Future research will focus on expanding the universality of the HiSem-RAG method so that it can be applied to more types of documents. We plan to study how to apply hierarchical thinking to unstructured texts that lack clear chapter markers, develop more powerful implicit structure recognition algorithms, explore methods for constructing cross-modal semantic hierarchies in multimodal documents, and domain-adaptive methods that automatically adjust hierarchical indexing strategies based on the characteristics of different domains. Through these studies, we hope to break through the current limitations of reliance on document structure, provide efficient retrieval-enhanced generation solutions for a wider range of document types, and further improve the performance of large language models in knowledge-intensive tasks.
[0197] In one embodiment, a hierarchical semantics-driven search enhancement generation system is provided, comprising:
[0198] Document parsing module, used to parse the chapter titles of the input document and construct multi-level tree structure nodes;
[0199] A recursive splitting module is used to perform semantic boundary splitting on node content according to a preset length threshold to generate child nodes;
[0200] The semantic enhancement module is used to call the large language model to extract node knowledge points, generate summaries, and implement top-down and bottom-up semantic transmission and aggregation;
[0201] Vector calculation module, used to generate vector representations of queries and nodes and calculate similarity distribution;
[0202] Adaptive threshold calculation module, used to dynamically calculate the retrieval threshold based on similarity statistical features;
[0203] A recursive retrieval module is used to recursively filter tree structure nodes based on a threshold value and output a retrieval result set;
[0204] The safety mechanism module is used to control the number of nodes to be retained and the upper and lower limits of similarity thresholds to prevent information overload or shortage;
[0205] Generate an interface module to integrate search results with queries to form a structured context and call a large language model to complete text generation.
[0206] The specific implementation content of each module can be found in the above definition of the hierarchical semantic-driven retrieval enhancement generation method, which will not be repeated here.
[0207] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A hierarchical semantic-driven retrieval enhancement generation method, characterized in that: The method comprises: Perform hierarchical document parsing on a multi-level document collection containing chapters, titles, and paragraphs, structuring each document into a tree structure, where each node in the tree structure includes a node identifier, a parent node identifier, a multi-level title path, a sequence number, a core knowledge point, a content summary, the original content, and a list of child node identifiers; For the text content of the nodes in the tree structure, a recursive semantic boundary splitting strategy is adopted to recursively split the node content exceeding the preset maximum length threshold based on sentence and paragraph delimiters, generate child nodes and maintain the parent-child relationship; Based on a large language model, we use designed prompt words to extract knowledge points and generate summaries from the text content of each node, forming a refined node-level semantic representation. The knowledge points are composed of multiple keywords, and the summary is a brief description of the node content. Bidirectional semantic enhancement: The root node title to the current node title are sequentially spliced to form a top-down multi-level title path. The knowledge points and summary information of all child nodes are passed from bottom to top to generate the comprehensive knowledge points and summary of the parent node, forming a semantic completion of the hierarchical structure. In response to a user input query, the query text is converted into a vector representation generated based on a pre-trained text embedding model; a similarity distribution is calculated based on the query vector and the combined semantic representation of each node's multi-level title path, knowledge point, and summary, and the cosine similarity is used to measure the degree of semantic match between the query and the node to obtain a similarity set for all nodes at the current level; The threshold of the current level is dynamically adjusted according to the statistical distribution characteristics of the similarity. The threshold calculation formula is: i raw =β·s max -(1-γ·CV)·(s max -m); Where: θ raw : The original dynamic threshold calculated based on the similarity distribution characteristics; s max : the maximum value of the similarity of the current level; μ: the average value of the similarity of the current level; σ: the standard deviation of the similarity of the current level; CV = σ / μ: coefficient of variation, indicating the degree of dispersion of the similarity distribution; β: basic retention coefficient (0 < β ≤ 1), controlling the basic threshold ratio; γ: distribution sensitivity coefficient (0 ≤ γ ≤ 1), controlling the sensitivity to the similarity distribution; Through the recursive hierarchical retrieval algorithm, starting from the root node, the nodes with similarity greater than or equal to the threshold θ are screened out, where θ is the final threshold adjusted by the safety mechanism. If the node is a non-leaf node, the screening operation is repeated on the child nodes until the leaf node is reached, forming the final candidate retrieval result set.
2. The method according to claim 1, characterized in that After extracting knowledge points and generating content summaries from the text content of each node using the designed prompt words based on the large language model, the following steps are also included: Achieve top-down semantic transfer by constructing a multi-level heading path for each node, encoding its contextual information in the document hierarchy into a structure-aware semantic representation; Achieve bottom-up semantic convergence. For each non-leaf node, aggregate the knowledge points and summary information of all its child nodes based on the large language model to generate the comprehensive knowledge points and content summary of the parent node, forming a hierarchical semantic expression system from concrete to abstract.
3. The method according to claim 1, characterized in that After forming the final candidate search result set, the method further includes: Set up a search security mechanism, including setting a lower limit for the similarity threshold, limiting the minimum and maximum number of nodes retained at each layer, and the maximum number of overall returned results, to prevent a large number of irrelevant nodes from being selected due to a too low threshold or key information from being missed due to a too high threshold; The search result set is integrated with the input query in a structured format, which includes a multi-level title path, sequence number and original content of each node, and the integrated context is input into the large language model to complete the search-enhanced text generation answer.
4. The method according to claim 1, wherein The recursive semantic boundary splitting strategy specifically includes: Step a: Determine whether the node text length exceeds the preset maximum length threshold; Step b: If the threshold is exceeded, segment the data based on delimiters such as period, comma, and line break. Step c: Repeat steps a and b for each segment after splitting until the text length of all sub-nodes does not exceed the threshold; Step d: Generate child nodes and update the child node list and node sequence information of the parent node.
5. The method according to claim 1, characterized in that The knowledge point extraction and content summary generation are completed by calling a large language model and combining preset prompt words. The prompt words include knowledge point keyword extraction and summary content description, ensuring that the knowledge point covers the core content of the node and the summary expresses the overall semantics of the node.
6. The method according to claim 2, characterized in that The top-down multi-level title path is formed by sequentially splicing the root node title to the current node title, and each level of title in the path participates in the construction of node semantic representation as structural context information; The bottom-up semantic convergence adopts aggregated prompt words based on a large language model, inputs the knowledge points and summary information of all child nodes into the model, generates comprehensive knowledge points and summaries of parent nodes, and forms semantic completion of a hierarchical structure.
7. The method according to claim 1, characterized in that In the recursive hierarchical retrieval process, node similarity calculation is based on the concatenated text of the node's multi-level title path, knowledge points and summary, and a node vector is generated through a text embedding model, and the cosine similarity is calculated with the query vector.
8. The method according to claim 3, characterized in that The safety mechanism includes: Set an absolute lower limit for the similarity threshold to avoid selecting nodes with too low similarity; Set the minimum number of nodes to be retained at each level to ensure that the hierarchical search results cover the necessary nodes; Set the maximum number of nodes to be retained at each layer to control the retrieval granularity and prevent redundancy; Set an upper limit on the total number of search results to limit the length of the input context of the generated model.
9. The method according to claim 3, characterized in that The structured and integrated context data format includes the multi-level title path string, node sequence number and original text content of each retrieval node, ensuring that the generated model input contains complete hierarchical semantic context information.
10. A hierarchical semantic-driven retrieval enhancement generation system, characterized in that: include: Document parsing module, used to parse the chapter titles of the input document and construct multi-level tree structure nodes; A recursive splitting module is used to perform semantic boundary splitting on node content according to a preset length threshold to generate child nodes; The semantic enhancement module is used to call the large language model to extract node knowledge points, generate summaries, and implement top-down and bottom-up semantic transmission and aggregation; Vector calculation module, used to generate vector representations of queries and nodes and calculate similarity distribution; Adaptive threshold calculation module, used to dynamically calculate the retrieval threshold based on similarity statistical features; A recursive retrieval module is used to recursively filter tree structure nodes based on a threshold value and output a retrieval result set; The safety mechanism module is used to control the number of nodes to be retained and the upper and lower limits of similarity thresholds to prevent information overload or shortage; Generate an interface module to integrate search results with queries to form a structured context and call a large language model to complete text generation.
Citation Information
Cited By
Construction method of text knowledge base, computer equipment and program product
CN120804233A
Semantic enhancement adaptive partitioning method and system for natural resource large model questions and answers
CN120822526A
Semantic enhancement adaptive partitioning method and system for natural resource large model question and answer
CN120822526B
Engineering knowledge base construction and deep retrieval method
CN120893548A
A Method for Engineering Knowledge Base Construction and Deep Retrieval
CN120893548B