RAG reordering method for tree structure document based on pruning optimization

By introducing a RAG reordering method based on pruning optimization in tree structure document processing, combining probability theory and pruning strategy, the problems of node redundancy, complex correlation judgment and bottleneck in the traditional method are solved, and efficient and accurate document processing and retrieval effects are achieved.

CN119808714APending Publication Date: 2025-04-11NANJING SINOVATIO TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411863219.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

Traditional tree structure document processing methods face problems such as node redundancy, complex correlation judgment and bottleneck inference speed, especially in the application scenarios of large-scale language models.

Method used

The RAG reordering method based on pruning optimization is adopted, combined with machine learning, probability theory and pruning strategies, and the nodes in the tree structure document are scored and sorted through probability theory deduction, optimize the organization of the tree structure document, and improve the efficiency and accuracy of query.

Benefits of technology

Through precise node correlation evaluation and pruning operations, redundant information is reduced, system processing efficiency and inference speed of large-scale language models are improved, and the accuracy and user experience of search results are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119808714A_ABST
    Figure CN119808714A_ABST
Patent Text Reader

Abstract

The invention relates to a pruning optimization-based RAG reordering method for a tree structure document, belongs to the technical field of computer science and information processing, and relates to a pruning optimization-based RAG reordering method for a tree structure document in combination with a machine learning algorithm and a probability theory based on a pruning strategy and an RAG (Retrieval-Augmented Generation) technology. And carrying out node score calculation, pruning optimization and reordering processing on the multi-way tree structure document, so as to improve the reasoning efficiency and response speed of the large-scale language model in knowledge retrieval and generation tasks. The method is suitable for application scenes needing efficient document processing, quick response and high accuracy, such as search engines, intelligent question-answering systems and knowledge base management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a sorting method, in particular to a RAG re-sorting method based on pruning optimization for tree-structured documents, and belongs to the technical field of computer science and information processing. Background Art

[0002] With the continuous advancement of information technology and the explosive growth of data scale, tree-structured documents have been widely used in various information management and processing systems. This structure is widely used to organize complex data sets, such as knowledge graphs, hierarchical data warehouses, content management systems, and search engine indexing systems. In these applications, the multi-level characteristics of the tree structure enable it to efficiently organize, store, and retrieve information. However, with the continuous increase and complexity of data, traditional tree-structured document processing methods face many challenges.

[0003] Node redundancy and data expansion: In large-scale application scenarios, tree-structured documents usually contain a large number of nodes. These nodes represent different levels of information, which may include page content, document metadata, relationship links, etc. However, as time goes by and documents continue to expand, the number of nodes in the tree structure may increase rapidly, resulting in the accumulation of a large amount of redundant information. These redundant nodes not only increase storage and computing overhead, but may also confuse highly relevant information and reduce the retrieval efficiency of the system.

[0004] Complexity of relevance judgment: Traditional tree-structured document processing methods usually rely on simple keyword matching or rule-driven algorithms. These methods are often unable to accurately judge the complex associations between nodes and queries when faced with large-scale and diverse data sets. For example, relying solely on keyword matching may ignore semantic relevance, resulting in inaccurate retrieval results. In addition, the hierarchical relationship between document nodes also increases the complexity of relevance judgment, especially in multi-branch tree structures, where each node may have relationships with multiple upper and lower nodes, making the evaluation of relevance more difficult.

[0005] Inference speed bottleneck: With the widespread application of large language models (such as the Transformer architecture), how to efficiently process and reorder tree-structured documents has become an important technical challenge. Large language models usually need to process large amounts of data in real time in knowledge retrieval and generation tasks, and the complexity of the tree structure and the large number of nodes often lead to a significant reduction in inference speed. This speed bottleneck is particularly prominent in application scenarios that require high concurrency and low latency, directly affecting user experience and the overall performance of the system. Summary of the invention

[0006] The present invention is aimed at the technical problems existing in the prior art, and provides a RAG re-ranking method based on pruning optimization for tree-structured documents. Based on machine learning, probability theory and optimization of pruning strategies, in order to overcome the above challenges, in recent years, researchers have begun to explore the application of machine learning, especially deep learning technology, to the processing flow of tree-structured documents. Among them, RAG (Retrieval-Augmented Generation) technology provides an effective solution. By combining the two modes of retrieval and generation, it can better utilize the potential information in the document structure and improve the accuracy of the query.

[0007] In this context, the present invention proposes an innovative optimization method that combines pruning strategies with RAG technology, and scores and sorts the nodes in tree-structured documents through probability theory derivation. The system first obtains relevant tree-structured documents based on user queries. Next, the system uses probability theory and similarity models to score and evaluate each node in the document. This process is aided by a pre-trained Rerank model, which has obtained the ability to predict node relevance through a large amount of data learning. However, the core work of the present invention lies in the definition and derivation of a node score calculation formula based on probability theory. Through precise formulas and derivations, combined with the principles of probability theory, the relevance of each node is accurately evaluated. These scores are used to guide subsequent pruning and reordering processes, ultimately optimizing the organization of tree-structured documents and improving query efficiency and accuracy.

[0008] The main purpose of the present invention is to provide a method for reordering and optimizing tree-structured documents, aiming to solve the problems of node redundancy, complex relevance judgment and reasoning speed bottleneck existing in the prior art. By introducing pruning strategies, RAG (Retrieval-Augmented Generation) technology and a node scoring system based on probability theory, the present invention can effectively improve the processing efficiency and retrieval accuracy of tree-structured documents. Specifically, the present invention aims to improve the reasoning efficiency and response speed of large-scale language models in knowledge retrieval and generation tasks by accurately evaluating the relevance of nodes and optimizing the organizational structure of tree-structured documents based on these evaluation results. This method is particularly suitable for application scenarios that require efficient document processing, such as search engines, intelligent question-answering systems and knowledge base management.

[0009] In the pruning strategy, the system combines these scores, removes irrelevant or redundant leaf nodes, and retains the smallest inclusion tree that is most likely to contain the answer. This process not only reduces redundant information, but also improves the efficiency of system processing. In the subsequent re-ranking process, the system will further use the scores of the TopK nodes to optimize the sorting of tree-structured documents to ensure that the final selected reference documents can effectively improve the reasoning speed and accuracy of large-scale language models.

[0010] In order to achieve the above object, the technical solution of the present invention is as follows: a RAG reordering method based on pruning optimization for tree-structured documents, the method comprising the following steps:

[0011] The parameters involved are:

[0012] Query: A question entered by a user, usually used to retrieve relevant information from a knowledge base.

[0013] Node: Recall a node in a document, which represents a unit of information in the document, such as a paragraph, sentence, or table.

[0014] Path: A list of multiple nodes (Node), representing a path from the root node (root) to the leaf node (leaf).

[0015] Tree: A multi-branch tree structure consisting of multiple paths (Path), representing the hierarchical structure of the document.

[0016] Node_text: The standardized form of the node text, that is, the text representation after the node content is standardized.

[0017] Path_text: A text string formed by concatenating the standardized text of all nodes in the current path.

[0018] Node_score: The score of the current node, reflecting the importance of the node under a specific query.

[0019] Path_score: The score of the current path, which is calculated by combining the scores of each node in the path, and reflects the relevance of the entire path under a specific query.

[0020] Tree_score: The overall score of the current tree-structured document, which is calculated by combining the scores of all paths and reflects the relevance of the entire document under a specific query.

[0021] Reference_document: The reference document that is finally spliced ​​into prompt is a standardized text that contains the charts in the original text and maintains the same order as the original text. This document is used as the reasoning input of the large model to ensure the integrity and relevance of the content.

[0022] Step 1: Parse the document and obtain the text pair

[0023] After obtaining the initial document, the depth-first search algorithm (DFS) is used to parse the tree-structured document (Tree) to construct nodes (Node) and paths (Path), where Path is composed of Node and Tree is composed of Path.

[0024] Compared with global tiled retrieval technology solutions such as Q Anything, LangChain, and LlamaIndex, the system's technical solution of retaining the original structure of the document during document parsing has the following advantages and characteristics:

[0025] 1. Context Preservation:

[0026] Global tiling: It will split the document into independent fragments without structure, resulting in the loss of contextual relationships, especially when dealing with problems that require combining chapters, levels or paragraphs.

[0027] Structure preservation: The document's chapter titles, hierarchical relationships, and original layout are preserved, which helps to better understand and use the document content when searching or answering, and improves the accuracy of the question-answering system.

[0028] 2. Content traceability:

[0029] Global tiling: It is difficult for users to know the context of the specific answer and they cannot intuitively trace back to the original source.

[0030] Structure preservation: By preserving the document structure, search results can be associated with specific chapters or paragraphs, making it easier for users to locate source content and improving user trust.

[0031] 3. Retrieval efficiency:

[0032] Global tiling: The retrieval range is wide but the accuracy is low, especially when the document contains redundant information, which will increase the noise.

[0033] Structure Preservation: Use structural information to limit queries, such as filtering by section priority or hierarchy, to optimize retrieval efficiency and reduce irrelevant results.

[0034] 4. Enhanced readability and display experience:

[0035] Global tiling: The result may be messy and lack of organization.

[0036] Structure preservation: The retrieved content can be presented according to the original hierarchical structure of the document, making it easier for users to quickly browse and understand it.

[0037] 5. Advantages of processing long documents:

[0038] Global tiling: The processing efficiency of long documents is low, especially when the blocks are large, which can easily lead to an increase in model load.

[0039] Structure preservation: Through hierarchical block division, long documents can be processed in segments while maintaining global consistency to reduce the load.

[0040] 6. Ability to solve complex problems:

[0041] Global Tiling: performs moderately well on problems that require reasoning across sections.

[0042] Structure preservation: Relying on the document structure, the system can focus on relevant chapters and help answer multi-level or cross-domain questions, performing better.

[0043] The specific process is as follows:

[0044] Step 1-1, obtain the initial document,

[0045] The system retrieves relevant tree-structured documents from the knowledge base based on the user's query.

[0046] These documents usually have a multi-level, multi-branch tree structure, and each document can be regarded as a tree.

[0047] Each node represents an information unit in the document, including paragraphs, sentences, and tables. Figure 2 .

[0048] Step 1-2, Depth First Search (DFS) analysis,

[0049] Through the DFS algorithm, the tree structure document is traversed, starting from the root node (root), and visiting each node in turn until the leaf node (leaf).

[0050] During the traversal process, the system builds a path, which is a list of multiple nodes connected in sequence, representing the path from the root node to the leaf node.

[0051] Each path records the complete information flow from the root node to a specific leaf node in the document.

[0052] Step 1-3, build Node and Path,

[0053] During the DFS traversal process, the system records each visited node and its content in turn, and combines these nodes into a path in order.

[0054] Each Path consists of multiple Nodes, and the system will calculate and record the corresponding path text (Path_text) for each Path.

[0055] Step 1-4: Build text pairs. After parsing the document and building the path, the system builds text pairs for each node in the path.

[0056] Step 1-4-1, construct Node_text and Path_text:

[0057] The text content of each node is standardized to generate Node_text.

[0058] For each path, concatenate the Node_text of all nodes in the path in order to generate Path_text.

[0059] Step 1-4-2: Text pair construction:

[0060] The system forms a text pair (Query, Path_text) with Query and each Path_text;

[0061] Step 2: Node score calculation and node pruning

[0062] Compared with Q Anything, LangChain, LlamaIndex and other technical solutions, the system has the following advantages and characteristics in calculating the node scores in the document:

[0063] 1. Multi-dimensional scoring strategy

[0064] Common solutions: Usually only a single node relevance is scored through a retrieval model, lacking a deep understanding of document structure and semantic diversity.

[0065] System solution:

[0066] Comprehensively consider the document structure weight (such as the importance of chapters and paragraphs), node context (such as parent-child node relationship), semantic similarity and user query intent matching.

[0067] The scoring is more comprehensive and can adapt to a variety of complex scenarios.

[0068] 2. Introduce document structure information

[0069] General solution: It is impossible to distinguish the weights of different levels or nodes in the document. For example, the importance of the document title and the main text content is the same, which affects the rationality of the result sorting.

[0070] System solution:

[0071] By analyzing the document structure (such as hierarchical relationships, chapter weights), each node is assigned a basic weight. For example:

[0072] The title node has higher priority.

[0073] Key content paragraphs receive higher scores.

[0074] This approach preserves the semantic context of the document, ensuring that the result is more consistent with the logical structure of the document.

[0075] 3. Dynamically adjust node scores

[0076] General solution: The scoring rules are fixed and the results cannot be dynamically adjusted according to different user intentions.

[0077] System solution:

[0078] Dynamically adjust the node score calculation based on user queries. For example:

[0079] Users pay more attention to chapters containing certain keywords, and the system automatically increases the weight of related nodes.

[0080] Provide more targeted search results.

[0081] 4. Stronger interpretability of results

[0082] General solution: It is impossible to explain the logic behind the result sorting, and only provides a relevance score.

[0083] System solution:

[0084] Node score calculation includes transparent weight assignment logic (such as structural weight, semantic score, contextual matching, etc.).

[0085] Users can trace the reasons for the results and enhance their sense of trust.

[0086] 5. Adaptability to complex scenarios

[0087] General solution: Limited ability to deal with multi-level problems (such as complex reasoning and multi-node cross-problems).

[0088] System solution:

[0089] Supports scoring of cross-node and cross-chapter related information. It is more suitable for retrieval and question-answering of complex documents such as technical documents and legal documents.

[0090] Step 2-1: Use the Rerank model to calculate all text pairs and assign Path_score

[0091] Step 2-1-1, Calculation of text pair relevance score:

[0092] The system uses the pre-trained Rerank model to calculate the relevance scores for all text pairs collected in step 1. The Rerank model evaluates the relevance between the Query and the Path_text path text and calculates the relevance score of each Path_text path text.

[0093] Step 2-1-2: Score assignment:

[0094] The system will calculate the score of the text pair (Query, Path_text) according to the Rerank model and assign it to the corresponding

[0095] Path_score,Here, Path_score represents the comprehensive relevance score of all nodes in the current path.

[0096] Step 2-2: Use the formula to calculate Node_score and assign a value, define:

[0097] Event A: Node is included in the Path;

[0098] Event B: The current Path is related to the user's question Query;

[0099] Prior probability P(B): Assume that the probability of a Node being included in a Path is 0.5, which means that we have no bias on whether the Node should be included in the Path.

[0100] The conditional probability P(A|B) is

[0101] P(A|B): Assume that if the current Path contains a Node, the probability that the user question Query is related to the Path is 0.7.

[0102] : Assume that if the current Path does not contain a Node, the probability that the user's question Query is related to the Path is 0.4. This means that the lack of a Node will result in a decrease in semantic relevance.

[0103] calculate:

[0104] Total probability formula:

[0105]

[0106] Bayesian formula:

[0107] P(B|A)=(P(A|B)*P(B)) / P(A)

[0108] Here, P(B|A) means the probability that the query is related to the path when the node is included, which is the node score required. Calculate Node_score according to the above formula,

[0109] Assumptions:

[0110] Path A contains 4 Node nodes, in order: Node1, Node2, Node3 and Node4, and the path score is

[0111] is 0.7, that is:

[0112] P(A|B)=0.7

[0113] Path B contains three Node nodes, Node1, Node2 and Node3 in order, and the path score is 0.4, that is:

[0114]

[0115] Prior probability P(B) = 0.5

[0116] From the total probability formula we can get:

[0117] P(A)=0.7*0.5+0.4*(1-0.5)=0.55

[0118] Using the Bayesian formula we get:

[0119] P(B|A)=(0.7*0.5) / 0.55≈0.64

[0120] Therefore, the node score of Node4 is about 0.64.

[0121] Based on the above calculation, the system can calculate the Node_score of the corresponding Node node according to the Path_score. This formula comprehensively considers factors such as the position of the Node in the current path, the importance of the content, and the degree of association with other nodes.

[0122] Get the relevance score of Node.

[0123] Step 2-3: Pruning operation and tree-structured document scoring and reconstruction

[0124] Step 2-3-1: Prune the Node nodes according to the threshold and obtain the pruned Path

[0125] The system will prune nodes with scores below the preset threshold.

[0126] After pruning, only nodes with scores higher than the threshold are retained to form the pruned Path.

[0127] Step 2-3-2: Construct the pruned Tree based on the pruned Path

[0128] The system constructs a minimal tree structure document (Tree) containing the user's question based on the pruned Path.

[0129] The pruned tree contains the nodes and paths that are most relevant to the user query.

[0130] Step 2-3-3: Select the Node_score of TopK in the Tree and assign the Tree_score

[0131] The system selects the Node_score of the topK nodes with the highest scores from the pruned Tree.

[0132] The TopK Node_score is combined and assigned to the Tree_score of the current Tree, indicating the overall relevance score of the tree-structured document.

[0133] Step 2-3-4: Sort the Trees according to Tree_score, and select the TopK Trees as reference documents for the large model.

[0134] The system sorts all Trees according to Tree_score.

[0135] Select the TopK trees with the highest scores as reference documents for large model reasoning.

[0136] Step 3: Restore the selected TopK Tree into text in the order of text and splice it into the reference document part in the prompt as the input of the large model

[0137] Step 3-1: Text restoration and splicing:

[0138] The system concatenates the Path_text in the selected TopK Tree document according to the hierarchical structure of the original text to generate a complete Reference_document, which contains the pictures and tables in the original text and retains the hierarchical structure consistent with the original text.

[0139] Step 3-2: Generate model input:

[0140] The concatenated Reference_document is embedded into the prompt of the large model as the final input to generate accurate answers.

[0141] Compared with the prior art, the present invention has the following advantages: by introducing a node scoring formula based on probability theory, a pruning optimization strategy and a reordering technique, the present invention achieves refined processing of tree-structured documents. Compared with the traditional RAG system, the present invention has significant beneficial effects in the following aspects:

[0142] 1) Accurate relevance assessment: By independently scoring and evaluating each node in the tree-structured document, the present invention can more accurately identify the information most relevant to the user query, thereby improving the accuracy of the retrieval results.

[0143] 2) Improve system efficiency: The introduction of pruning strategies effectively reduces unnecessary nodes and reduces the system's computational overhead. Compared with traditional methods, this invention significantly improves the reasoning speed of large-scale language models, especially in high-concurrency scenarios, and can better meet the needs of real-time response.

[0144] 3) Optimized document organization: By reordering the path and tree structure, the present invention ensures the logic and consistency of the document structure and the high quality of the output document. This not only improves the utilization value of the reference document, but also provides a better input for the generation task of the large model.

[0145] 4) Improve user experience: The final generated reference document retains the charts and text order in the original text, ensuring the integrity and coherence of the content. This refined document construction method improves the reasoning effect of the model, thereby providing users with more accurate and relevant answers and improving the overall user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0146] Figure 1 It is a schematic diagram of the overall process of the present invention,

[0147] Figure 2 This is an example diagram of a tree structure document.

[0148] Figure 3 User question: What are the advantages of Pytorch? Schematic diagram of the retrieved results.

[0149] Figure 4 To compare the retrieval results with the prior art for different problems under the same conditions. DETAILED DESCRIPTION

[0150] In order to deepen the understanding of the present invention, the present embodiment is described in detail below with reference to the accompanying drawings.

[0151] Example 1: See Figure 1 ,

[0152] See also Figure 1, a RAG reordering method based on pruning optimization for tree-structured documents, the method comprising the following steps:

[0153] Step 1: Get and parse the document.

[0154] After obtaining the initial document, the depth-first search algorithm (DFS) is used to parse the tree-structured document (Tree) and construct nodes (Node) and paths (Path), where Path is composed of Node and Tree is composed of Path. Specifically:

[0155] Step 1-1, obtain the initial document,

[0156] The system retrieves relevant tree-structured documents from the knowledge base based on the user's query.

[0157] These documents usually have a multi-level, multi-branch tree structure. Each document can be regarded as a tree, where each node represents an information unit in the document, including paragraphs, sentences, and tables. Steps 1-2, depth-first search (DFS) parsing,

[0158] Through the DFS algorithm, the tree structure document is traversed, starting from the root node (root), and visiting each node in turn until the leaf node (leaf).

[0159] During the traversal process, the system builds a path, which is a list of multiple nodes connected in sequence.

[0160] represents the path from the root node to the leaf node,

[0161] Each path records the complete information flow from the root node to a specific leaf node in the document. Steps 1-3: Construct Node and Path.

[0162] During the DFS traversal process, the system records each visited node and its content in turn, and combines these nodes into a path in order.

[0163] Each Path consists of multiple Nodes. The system will calculate and record the corresponding path text (Path_text) for each Path. Step 2: Build text pairs. After parsing the document and building the path, the system builds text pairs for each node in the path.

[0164] Step 2-1, construct Node_text and Path_text:

[0165] The text content of each node is standardized to generate Node_text.

[0166] For each path, concatenate the Node_text of all nodes in the path in order to generate Path_text.

[0167] Step 2-2: Text pair construction: the system constructs a text pair (Query,

[0168] Path_text).

[0169] Step 3: Use the Rerank model to calculate all text pairs and assign Path_score,

[0170] Step 3-1, text pair score calculation:

[0171] The system uses the pre-trained Rerank model to calculate the scores of all constructed text pairs.

[0172] The Rerank model evaluates the text relevance between Query and Path_text and calculates the relevance score for each text pair.

[0173] Step 3-2, record the score: the system records the text score of each Path (Path_score),

[0174] Step 3-3, assign Path_score: The system will assign the score of the text pair (Query, Path_text) calculated by the Rerank model to the corresponding Path_score.

[0175] Path_score represents the comprehensive relevance score of all nodes in the current path.

[0176] Step 4: Use the formula to calculate Node_score for assignment.

[0177] Step 4-1, calculate Node_score,

[0178] based on Figure 2 , Figure 3 The system calculates the Node_score of the corresponding Node based on the Path_score. This formula takes into account factors such as the position of the Node in the current path, the importance of the content, and the degree of association with other nodes.

[0179] Elements, get the Node's relevance score,

[0180] Step 4-2, assigning Node_score: The system assigns the calculated Node_score to the corresponding Node, reflecting the importance of the node in the specific query context.

[0181] Step 5: Prune the Node according to the threshold and obtain the pruned Path.

[0182] Step 5-1: Pruning operation:

[0183] The system selects the nodes with lower scores for pruning according to the preset threshold.

[0184] After pruning, only the nodes with scores higher than the threshold are retained to form the pruned Path.

[0185] Step 6: Construct the pruned Tree based on the pruned Path.

[0186] Step 6-1, construct the pruned Tree:

[0187] The system rebuilds the tree structure document (Tree) based on the pruned Path.

[0188] The pruned tree contains only the nodes and paths that are most relevant to the user query.

[0189] Step 7: Select the Node_score of the TopK in the Tree and assign the Tree_score

[0190] Step 7-1, calculate Tree_score:

[0191] The system selects the Node_score of the topK nodes with the highest scores from the pruned Tree.

[0192] Comprehensive TopK Node_score, assigned to the current Tree's Tree_score, represents the overall tree structure document

[0193] Relevance score,

[0194] Step 8: Sort the trees according to Tree_score and select the topK trees as reference documents for the large model.

[0195] Step 8-1, sorting and selection:

[0196] The system sorts all Trees according to Tree_score.

[0197] Select the TopK trees with the highest scores as reference documents for large model reasoning.

[0198] Step 9: Restore the selected TopK Tree into text in the order of text and splice it into the reference document part in the prompt as the input of the large model.

[0199] Step 9-1: Text restoration and splicing:

[0200] The system will splice the Path_text in the selected TopK Tree according to the order of the original text to generate a complete Reference_document.

[0201] This reference document contains the figures and tables in the original text and keeps the same order as the original text.

[0202] Step 9-2: Generate model input: The concatenated Reference_document is embedded into the prompt of the large model as the final input to generate accurate answers.

[0203] This tree-structured document processing method that combines pruning strategies and probabilistic node scoring systems is particularly suitable for application scenarios that require efficient document processing and rapid response, such as search engines, intelligent question-answering systems, and knowledge base management. Compared with traditional methods, the present invention significantly improves the system's response speed and reasoning efficiency, reduces storage and computing costs, and provides higher accuracy and relevance when dealing with complex queries.

[0204] In summary, the present invention provides an efficient and accurate solution for processing tree-structured documents by innovatively combining pruning strategies, RAG technology and probability theory. It can be widely used in various information processing systems to meet the needs of modern data-driven applications.

[0205] The solution is based on a node scoring formula derived from probability theory methods such as conditional probability, total probability formula, and Bayesian formula. The system uses this formula to quantify the relevance of a node in a specific query, thereby providing an accurate basic score for subsequent processing.

[0206] This solution is based on the text similarity model and solves the problem that some child nodes have a large amount of duplicate text in their parent nodes. By adjusting and optimizing the node scoring formula, it effectively improves the accuracy of node scores and avoids the impact of information redundancy on evaluation results.

[0207] The solution is based on the optimized node scoring formula. The system implements a pruning strategy to prune redundant or irrelevant nodes with low scores and retain the nodes most relevant to the user's query, thereby building a minimum inclusion tree that contains the answer. This process greatly reduces the redundant information in the document and significantly improves processing efficiency.

[0208] After completing pruning, the system reorders the entire tree-structured document according to the optimization scores of the retained nodes.

[0209] The system will comprehensively evaluate the scores of the selected TopK nodes, recalculate and sort the overall scores of the remaining documents, and thus generate a tree structure that better meets the user's query requirements.

[0210] Finally, the system selects the TopK tree-structured documents with the highest scores as reference documents for large-scale language model reasoning. This step ensures the accuracy and relevance of the model input, while significantly improving the reasoning speed and efficiency of the model. Through the above technical solutions, the present invention can significantly improve the processing efficiency and retrieval accuracy of tree-structured documents, especially showing excellent performance in the application scenarios of large-scale language models.

[0211] It should be noted that the above embodiments are not intended to limit the protection scope of the present invention, and equivalent changes or substitutions made on the basis of the above technical solutions all fall within the protection scope of the claims of the present invention.

Claims

1. A RAG reordering method based on pruning optimization for tree-structured documents, characterized in that: The method comprises the following steps: Step 1: Get and parse the document. After getting the initial document, use the depth-first search algorithm (DFS) to parse the tree-structured document (Tree) and build nodes (Node) and paths (Path). Path is composed of Node and Tree is composed of Path. Step 2: Build text pairs. After parsing the document and building the path, the system builds text pairs for each node in the path. Step 3: Use the Rerank model to calculate all text pairs and assign Path_score, Step 4: Use the formula to calculate Node_score for assignment. Step 5: Prune the Node according to the threshold and obtain the pruned Path. Step 6: Construct the pruned Tree based on the pruned Path. Step 7: Select the Node_score of the TopK in the Tree and assign the Tree_score Step 8: Sort the Tree according to Tree_score, and select the TopK Tree as the reference document of the large model. Step 9: Restore the selected TopK Tree into text according to the order of text and splice it into the reference document part in the prompt as the input of the large model.

2. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 1: Get and parse the document, as follows: Step 1-1: Get the initial document. The system retrieves relevant tree-structured documents from the knowledge base based on the user's query. These documents usually have a multi-level, multi-branch tree structure. Each document can be regarded as a tree, where each node represents an information unit in the document, including paragraphs, sentences, and tables. Step 1-2, Depth-first search (DFS) parsing, using the DFS algorithm to traverse the tree-structured document, starting from the root node (root), visiting each node in turn until the leaf node (leaf). During the traversal process, the system builds a path (Path), which is a list of multiple nodes (Node) connected in sequence, representing the path from the root node to the leaf node. Each path records the complete information flow from the root node to a specific leaf node in the document. Step 1-3, construct Node and Path. During the DFS traversal process, the system records each visited node (Node) and its content in turn, and combines these nodes into paths (Path) in order. Each Path consists of multiple Nodes. The system calculates and records the corresponding path text (Path_text) for each Path.

3. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 2: Build text pairs. After parsing the document and building the path, the system builds text pairs for each node in the path. Step 2-1, construct Node_text and Path_text: The text content of each node is standardized to generate Node_text. For each path, the Node_text of all nodes in the path are concatenated in order to generate Path_text. Step 2-2, text pair construction. The system constructs a text pair (Query, Path_text) with Query and each Path_text.

4. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 3: Use the Rerank model to calculate all text pairs and assign Path_score, Step 3-1, text pair score calculation: The system uses the pre-trained Rerank model to calculate the scores of all constructed text pairs. The Rerank model evaluates the text relevance between Query and Path_text and calculates the relevance score for each text pair. Step 3-2, record the score: the system records the text score of each Path (Path_score), Step 3-3, assign Path_score: The system will assign the score of the text pair (Query, Path_text) calculated by the Rerank model to the corresponding Path_score. Path_score represents the comprehensive relevance score of all nodes in the current path.

5. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 4: Use the formula to calculate Node_score for assignment. Step 4-1, calculate Node_score. The system calculates the Node_score of the corresponding Node based on the Path_score. This formula takes into account factors such as the position of the Node in the current path, the importance of the content, and the degree of association with other nodes to derive the relevance score of the Node. Step 4-2, assigning Node_score: The system assigns the calculated Node_score to the corresponding Node, reflecting the importance of the node in the specific query context.

6. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 5: Prune the Node according to the threshold and obtain the pruned Path. Step 5-1: Pruning operation: The system selects the nodes with lower scores for pruning according to the preset threshold. After pruning, only the nodes with scores higher than the threshold are retained to form the pruned Path. Step 6: Construct the pruned Tree based on the pruned Path. Step 6-1, construct the pruned Tree: The system rebuilds the tree structure document (Tree) based on the pruned Path. The pruned tree contains only the nodes and paths that are most relevant to the user query.

7. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 7: Select the Node_score of the TopK in the Tree and assign the Tree_score Step 7-1, calculate Tree_score: The system selects the Node_score of the topK nodes with the highest scores from the pruned Tree. The TopK Node_score is combined and assigned to the Tree_score of the current Tree, indicating the overall relevance score of the tree-structured document. Step 8: Sort the Trees according to Tree_score, and select the TopK Trees as reference documents for the large model. Step 8-1, sorting and selection: The system sorts all Trees according to Tree_score. Select the TopK trees with the highest scores as reference documents for large model reasoning.

8. The RAG reordering method based on pruning optimization for tree-structured documents according to claim 1, characterized in that: Step 9: Restore the selected TopK Tree into text in the order of text and splice it into the reference document part in the prompt as the input of the large model. Step 9-1, text restoration and splicing: The system splices the selected Path_text in the TopK Tree according to the order of the original text to generate a complete Reference_document. The reference document contains the charts in the original text and retains the order of the original text. Step 9-2: Generate model input: The concatenated Reference_document is embedded into the prompt of the large model as the final input to generate accurate answers.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the RAG reordering method based on pruning optimization for tree-structured documents as described in any one of claims 1 to 8 above is implemented.

10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, a pruning-optimization-based RAG reordering method for tree-structured documents as described in any one of claims 1 to 9 is implemented.

Citation Information

Cited By

  • Path positioning method and device based on dictionary tree structure and weight learning and medium

    CN120743791A

  • Method, device and medium for path positioning based on dictionary tree structure and weight learning

    CN120743791B