Search enhancement method, apparatus, electronic device, storage medium, and program product

By using multi-scale matching and bipartite graph techniques in the retrieval enhancement generation system, the problems of document chunking and retrieval result organization are solved, thereby improving the quality and relevance of the generated answers.

CN121597796BActive Publication Date: 2026-05-01BEIJING YUXINGYIZHOU INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING YUXINGYIZHOU INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2025-11-20
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing retrieval enhancement generation systems suffer from problems such as information dispersion, redundancy, and insufficient utilization of structured information in document chunking and retrieval result organization, resulting in poor answer generation quality.

Method used

By mapping user queries to document structure nodes through multi-scale matching, determining the structural hierarchy path based on the bipartite graph, filtering and reorganizing target semantic blocks, and generating context packages for use by large language models.

Benefits of technology

It improves the relevance and completeness of search results, ensures that the output context package is more in line with the query requirements, and supports the generation of high-quality answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597796B_ABST
    Figure CN121597796B_ABST
Patent Text Reader

Abstract

The application discloses a retrieval enhancement method and device, electronic equipment, a storage medium and a program product, and relates to the technical field of information retrieval and natural language processing. The method comprises the following steps: a user query multi-scale matching is mapped to a corresponding document structure node, the node is associated with a hierarchical position and a content abstract of a document structure element; and target semantic blocks are screened based on a structure hierarchical path, so that dynamic adjustment of query-guided blocks is realized, and information dispersion or redundancy caused by static blocks is avoided. The structure hierarchical path of the way associated node is determined by taking the document structure node as a starting point and by using a two-part graph. Meanwhile, the target semantic blocks are screened and reorganized based on the path, so that the output context package is more suitable for the query requirement. Thus, the natural advantage of a structured document in information organization is fully activated, the relevance and integrity of the retrieval result are improved, and a foundation is laid for high-quality answer generation.
Need to check novelty before this filing date? Find Prior Art

Description

Search enhancement methods, apparatus, electronic devices, storage media, and program products Technical Field

[0001] This application relates to the fields of information retrieval and natural language processing technology, and in particular to a retrieval enhancement method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] In the field of artificial intelligence technology, Retrieval-Augmented Generation (RAG) systems have been widely used in scenarios such as intelligent question answering and content creation because they can combine with external knowledge bases to improve the accuracy and reliability of generated content. However, current RAG systems still have significant technical deficiencies in document processing and retrieval, resulting in the quality of their generated answers failing to meet the needs of practical applications. Specific problems are as follows:

[0003] First, in the document segmentation stage, existing technologies mostly adopt offline static segmentation methods based on the inherent structure of the document (such as chapter and paragraph divisions) or fixed token lengths. This method often results in the information fragments obtained during the retrieval process being scattered and fragmented, with some fragments also having information redundancy or missing key information, directly affecting the coherence and accuracy of subsequent answer generation.

[0004] Secondly, at the level of retrieval methods, although existing technologies have established multi-level index structures to improve retrieval efficiency, when a user enters a query request, the system cannot reorganize the preliminary retrieved results according to the query intent, resulting in inconsistent quality of the final returned context information. Some low-quality context may even interfere with the judgment of the answer generation model.

[0005] Finally, the retrieval logic of existing retrieval enhancement generation systems relies excessively on semantic matching of text content, and makes insufficient use of the structured information contained in structured documents. This prevents structured documents from fully leveraging their natural advantages in information organization, and further limits the relevance and completeness of retrieval results. Summary of the Invention

[0006] In view of the above problems, this application provides a search enhancement method, apparatus, electronic device, storage medium, and program product that overcomes or at least partially solves the above problems. The technical solution is as follows:

[0007] This application provides a retrieval enhancement method, which includes: acquiring a user query and mapping the user query to a corresponding document structure node through multi-scale matching, wherein the document structure node includes the hierarchical position of document structure elements in a formatted document and a content summary; determining a structural hierarchy path based on the document structure node and a pre-constructed bipartite graph, wherein the structural hierarchy path is a reference path that starts from the document structure node and passes through associated nodes; determining target semantic blocks related to the document structure node from the bipartite graph based on the structural hierarchy path; reorganizing the target semantic blocks; and generating a context package of the user query based on the reorganized target semantic blocks, wherein the context package is used to provide a large language model to generate an answer to the user query.

[0008] As an optional implementation method provided in this application, mapping user queries to corresponding document structure nodes through multi-scale matching includes: determining the complexity of the user query; if the user query contains multiple sub-intents or requires multiple steps of reasoning, decomposing the user query into multiple sub-problems; otherwise, keeping the user query unchanged; extracting keywords from the user query or each sub-problem, and calculating the lexical matching score between the keywords and each document structure node; vectorizing the user query or each sub-problem and each document structure node, and calculating the semantic similarity between the encoded vectors to obtain a semantic matching score; obtaining a pre-generated set of atomic problems for each document structure node, calculating the similarity between the user query or each sub-problem and each atomic problem in the set, and selecting the highest similarity as the intent matching score; for each document structure node, fusing its lexical matching score, semantic matching score, and intent matching score according to a set weight to obtain a comprehensive score; sorting the document structure nodes according to the comprehensive score, and selecting one or more document structure nodes with the highest scores as the document structure nodes corresponding to the user query or sub-problem.

[0009] As an optional implementation method provided in this application, the structural hierarchy path is determined based on the document structure nodes and the pre-constructed bipartite graph, including: in the bipartite graph, performing a breadth-first search or depth-first search starting from the document structure nodes to obtain the path to be expanded; under the constraint of the total token budget, determining the associated nodes of the terminal nodes in the path to be expanded, and generating the expanded path based on the associated nodes; calculating the score of the expanded path, and filtering the expanded paths with scores less than a preset score; and selecting the top K structural hierarchy paths with scores from the filtered expanded paths.

[0010] As an optional implementation method provided in this application, the target semantic block is reorganized, including: decomposing the target semantic block into sentence units; calculating the sentence-level relevance between the sentence unit and the user query, and retaining the target sentence units whose sentence-level relevance is greater than a first relevance threshold; calculating the semantic relevance between the target sentence units, and merging at least two target sentence units whose semantic relevance is greater than a second relevance threshold and whose positions are adjacent.

[0011] The merged results are sorted in logical order to obtain the recombined target semantic blocks.

[0012] As an optional implementation method provided in this application, the bipartite graph construction process includes: performing structured parsing on the formatted document to obtain document structure elements; performing lexical decomposition on the content of the formatted document to obtain semantic blocks; generating an atomic problem set based on the document structure elements and semantic blocks; using the document structure elements and semantic blocks as nodes of the bipartite graph; and determining the edges of the nodes based on at least one of the structural correlation, semantic similarity, positional adjacency, and reference relationship between nodes to construct the bipartite graph of the formatted document.

[0013] As an optional implementation provided in this application, determining the edges of nodes based on at least one of structural correlation, semantic similarity, positional adjacency, and reference relationship between nodes includes: calculating the weight of the association relationship between nodes based on at least one of structural correlation, semantic similarity, positional adjacency, and reference relationship between nodes; and drawing the edges of nodes based on the weight of the association relationship between nodes.

[0014] This application provides a search enhancement device, the device comprising:

[0015] The query projection module is used to obtain user queries and map user queries to corresponding document structure nodes through multi-scale matching. The document structure nodes include the hierarchical position of document structure elements in the formatted document and content summary.

[0016] The path determination module is used to determine the structural hierarchy path based on the document structure nodes and the pre-built bipartite graph. The structural hierarchy path is the reference path that starts from the document structure node and passes through the associated nodes.

[0017] The semantic chunking determination module is used to determine the target semantic chunks related to document structure nodes from the bipartite graph based on the structural hierarchy path;

[0018] The reorganization module is used to reorganize the target semantic blocks;

[0019] The context package generation module is used to generate a context package for the user query based on the reorganized target semantic blocks. The context package is used to provide the large language model to generate the answer to the user query.

[0020] This application provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the retrieval enhancement method described in any of the preceding claims.

[0021] This application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described search enhancement methods.

[0022] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0023] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0024] Figure 1 is a system architecture diagram on which the execution of a retrieval enhancement method provided in an embodiment of this application depends;

[0025] Figure 2 is a schematic flowchart of a retrieval enhancement method provided in an embodiment of this application;

[0026] Figure 3 is a schematic structural diagram of a retrieval device provided in an embodiment of this application;

[0027] Figure 4 is a schematic structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0028] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.

[0029] To more clearly illustrate the embodiments of this application, the technical terms used in the embodiments will be briefly introduced below:

[0030] A bipartite graph is an undirected graph in which the set of vertices can be divided into two disjoint subsets, and the two endpoints of each edge belong to these two different subsets respectively.

[0031] A token is the smallest semantic unit into which text data is divided.

[0032] To overcome, or at least partially solve, the problems of static document segmentation, lack of dynamic organization of search results, and insufficient utilization of structured information in the aforementioned background technologies, this application provides a search enhancement method. First, the corresponding document structure node is determined through user query. This node directly relates to the hierarchical position and content summary of the document structure elements, essentially anchoring the starting point for dynamic segmentation based on the query requirements. Then, target semantic segments are filtered based on the structural hierarchy path, achieving dynamic adjustment of query-guided segments and avoiding information dispersion or redundancy caused by static segmentation. Starting with the document structure node, the structural hierarchy path of the associated nodes is determined through a bipartite graph; this process is essentially a dynamic pruning of the search scope. Simultaneously, filtering and reorganizing target semantic segments based on this path is equivalent to merging and rearranging the search results, fundamentally solving the problems of disorganized and unevenly qualityed search results, ensuring that the output context package better matches the query requirements. From initially locating document structure nodes at the hierarchical level, to filtering and segmenting based on the hierarchical path, and finally reorganizing to generate context packages, the process deeply utilizes structured information such as the document's hierarchical structure and element relationships, rather than relying solely on text semantic matching. This improves the relevance and completeness of the search results, laying the foundation for generating high-quality answers.

[0033] As shown in Figure 1, Figure 1 is a system architecture diagram on which the execution of a retrieval enhancement method provided in an embodiment of this application depends, including an offline indexing layer and an online retrieval layer.

[0034] The offline indexing layer is responsible for structured parsing and relational modeling of documents at the preprocessing node, thus providing a data foundation for online retrieval. First, a document parser analyzes input documents in formats such as PDF and Word, extracting text content and formatting information. Then, structural elements, including chapter titles, paragraph markers, table references, and chart descriptions, are extracted from the parsing results, recording their hierarchical position and content summary within the document. A hybrid chunking method based on token awareness is used to semantically chunk the document content, including text content, semantic embedding vectors, and original document position coordinates. Next, a bipartite graph is constructed. Based on the structural elements and semantic chunking, document structural nodes and semantic nodes, as well as the relationships between them, are established, forming a bipartite graph structure. Furthermore, weights are calculated for each edge of the bipartite graph based on dimensions such as structural relevance, semantic similarity, positional adjacency, and citation relationships, quantifying the strength of the association between nodes.

[0035] The online retrieval layer is responsible for the dynamic processing phase during query execution. Based on the offline-constructed bipartite graph, it dynamically processes user queries to output structured answer content. First, the query projection module receives user queries and maps them to the most relevant document structure nodes using multi-scale methods such as lexical-level matching, semantic-level matching, and intent-level matching. Then, starting from the mapped document structure nodes, it performs a breadth-first or depth-first search on the bipartite graph based on edge weights, expanding the search for relevant structural hierarchical paths under the constraint of lexical budget, and mining the set of nodes associated with the user query. Next, the relevant semantic blocks obtained from the search are reorganized, including operations such as pruning irrelevant content, merging relevant blocks, and rearranging logical order. Finally, the processed semantic blocks are organized into structured context packages containing reorganized text content, structural hierarchical paths, and other information, providing structured input to the large language model to generate the final cited answer.

[0036] As shown in Figure 2, Figure 2 is a schematic flowchart of a retrieval enhancement method provided in an embodiment of this application. The method includes:

[0037] S201. Obtain the user query and map the user query to the corresponding document structure node through multi-scale matching.

[0038] After obtaining the user query, the user query can be projected onto a document structure graph containing multiple document structure nodes through multi-scale methods such as word-level matching, semantic-level matching, and intent-level matching to determine the document structure nodes related to the user query.

[0039] In some embodiments, acquiring user queries and mapping them to corresponding document structure nodes through multi-scale matching includes: first, determining the complexity and decomposing the user query; when the user query contains multiple sub-intents, requires multi-step reasoning, or spans multiple knowledge points, it is decomposed into multiple independent sub-problems using a large language model, with each sub-problem focusing on a single information requirement; then, simultaneously performing lexical-level matching, semantic-level matching, and intent-level matching on the user query or each sub-problem; in lexical-level matching, keywords are extracted from the user query or sub-problems, and the lexical matching score between the keywords and each document structure node is calculated; in semantic ... In semantic-level matching, the user query or sub-question and each document structure node are vectorized and encoded, and the semantic similarity score between the encoded vectors is calculated. In intent-level matching, the similarity between the user query or sub-question and the pre-generated atomic question set of each document structure node is calculated, and the highest similarity is selected as the intent matching score. For each document structure node, its lexical matching score, semantic matching score, and intent matching score are fused according to a set weight to obtain a comprehensive score. The document structure nodes are sorted according to the comprehensive score, and one or more document structure nodes with the highest scores are selected as the document structure nodes corresponding to the user query or sub-question. In the specific implementation of the above embodiment, the task is first decomposed, and then three levels of parallel retrieval are performed for each user query or sub-question.

[0040] Step zero, at the task decomposition level, utilizes a large language model to analyze the complexity of user queries. Through prompt word engineering, the model is guided to determine whether the user query contains multiple independent information needs, requires multi-step reasoning, or involves complex logic such as causal relationships or comparative analysis. If determined to be a complex query, it is decomposed into several sub-questions, each expressing a single, clear information need. For example, the complex query "What are the main reasons for the decline in the company's Q3 profits, and what measures did management take to address them?" can be decomposed into sub-question 1 "What are the main reasons for the decline in the company's Q3 profits?" and sub-question 2 "What measures did management take to address the decline in Q3 profits?". Each decomposed sub-question undergoes independent multi-scale matching, and the results retrieved from each sub-question are ultimately integrated. For simple queries, the subsequent matching process proceeds directly without decomposition.

[0041] The first step, at the lexical level, involves preprocessing the query or sub-question text. A word segmentation tool breaks the text down into individual words, and a phrase recognition algorithm extracts key phrases, forming a query term set containing core vocabulary and phrases. For each document structure node, text segmentation and cleaning are also performed, removing stop words and retaining the core content of the node text. The lexical level matching score uses the Best Matching 25 (BM25) algorithm to calculate the relevance score between the query term set and the node text, normalized to the [0, 1] interval. The BM25 algorithm effectively avoids the problems of long document bias and excessive weighting of high-frequency words by introducing document length normalization and word frequency saturation mechanisms.

[0042] The second step, at the semantic-level matching level, involves selecting pre-trained language models such as Bidirectional Encoder Representations from Transformers (BERT) and Robustly Optimized BERT Pretraining Approach (RoBERTa), and fine-tuning them based on domain-specific corpora to enhance the model's understanding of technical terms and context. The pre-trained language models are used to vectorize the user query or sub-question text and the content of each document structure node, converting the text into a fixed-dimensional vector representation (e.g., 768-dimensional). The semantic-level matching score uses a cosine similarity algorithm to calculate the similarity between the query vector and the node vector, with the score mapped to the [0, 1] interval, where 1 indicates high semantic relevance and 0 indicates semantic irrelevance.

[0043] The third step, at the intent-level matching level, utilizes the atomic question set pre-generated for each document structure node during the document indexing phase. The atomic question set contains 3 to 5 typical questions that the node can answer, covering the node's main knowledge points. The cosine similarity is calculated between the user query or sub-question vector and each of the node's atomic question vectors, and the highest similarity value is selected as the intent-level matching score, ranging from [0, 1]. This "question-to-question" matching method is more direct and accurate because the atomic questions themselves are standard question statements that the node can answer; the similarity between the user query and the atomic questions directly reflects the node's ability to answer user questions.

[0044] Finally, the scores of each document structure node across the three dimensions are weighted and fused. A lexical weight α, a semantic weight β, and an intent weight γ are set, where α + β + γ = 1. These weights can be flexibly adjusted according to the application scenario. The overall score is calculated as: α × lexical score + β × semantic score + γ × intent score. All document structure nodes are then sorted based on their overall scores, and one or more of the top-ranked nodes (e.g., the Top-K nodes) are selected as the document structure nodes corresponding to the user query or sub-question.

[0045] The above embodiments fully leverage the advantages of query understanding and precise retrieval by combining task decomposition and multi-scale matching. Task decomposition breaks down complex queries into multiple well-defined sub-questions, each of which can be independently and precisely retrieved, avoiding the problem of unfocused search results caused by the mixed information requirements of complex queries. Lexical-level matching uses the BM25 algorithm to quickly capture literal and precise matches, ensuring high accuracy; semantic-level matching understands deep semantic relationships through vector similarity, compensating for omissions caused by differences in expression and improving recall; intent-level matching adopts a direct "question-to-question" matching method, accurately identifying the specific questions that nodes can answer through a pre-generated set of atomic questions. The three dimensions are computed in parallel and then weighted and fused. The importance of each dimension can be flexibly adjusted according to different application scenarios through weight parameters, ensuring that the final selected document structure nodes are highly relevant to the user query or sub-questions at the literal, semantic, and intent levels, thus providing an accurate starting point for subsequent path search and content reorganization.

[0046] S202. Determine the structural hierarchy path based on the document structure nodes and the pre-built bipartite graph.

[0047] Among them, the structural hierarchy path is a reference path that starts from the document structure node and passes through the associated nodes; the associated node is a bipartite graph node that is sequentially associated with the document structure node as the seed node.

[0048] In some embodiments, determining the structural hierarchy path based on document structure nodes and a pre-built bipartite graph includes: performing a breadth-first search or depth-first search starting from the document structure nodes in the pre-built bipartite graph to obtain the path to be expanded; then, under the constraint of the total token budget, determining the associated nodes of the terminal nodes in the path to be expanded, and generating the expanded path based on these associated nodes; then calculating the score of the expanded path and filtering out the expanded paths with scores less than a preset score; and further selecting the top K structural hierarchy paths with scores from the filtered expanded paths.

[0049] Breadth-First Search (BFS) is a traversal algorithm that starts from the starting node and prioritizes visiting all adjacent nodes (i.e., nodes at the same level) of the current node. After visiting all nodes at the current level, it then visits the adjacent nodes at the next level in sequence. Depth-First Search (DFS) is an algorithm that starts from the starting node and prioritizes visiting as many nodes as possible along a path. When it cannot continue to visit any more nodes (no unvisited adjacent nodes), it backtracks to the previous node and chooses another unvisited path to continue visiting the next node until all nodes have been visited.

[0050] In the specific implementation of the above embodiments: First, the node types and edge association rules of the bipartite graph are defined. The seed nodes (i.e., document structure nodes) obtained from the query projection are used as the initial search starting point. An initial path containing only that seed node is created for each seed node, and the score of the initial path is calculated. The score can be set based on the matching degree between the seed node and the user query. A priority queue is initialized, and all initial paths are sorted from high to low score. At the same time, the total token budget and pruning threshold are set, such as 1000 according to the search accuracy requirements. Each path expansion operation consumes 1 token; paths with scores lower than 30% of the highest scores in the queue are pruned.

[0051] Next, retrieve the highest-scoring path to be expanded from the head of the priority queue and check the remaining token budget: if the budget is exhausted, immediately terminate the expansion process; if the budget is sufficient, consume 1 token and determine the type of the end node of the path. Iterate through all associated nodes of the end node, generating a new path for each associated node. The new path is the original path with the associated node added, and the score of the new path is calculated. The score calculation needs to consider the contribution of the original path score and the new node, such as the concept-level matching degree between the new node and the query; the higher the matching degree, the greater the score bonus for the new path. All newly generated paths are temporarily stored in a temporary set. After the current batch of expansions is completed, they are all added to the priority queue and reordered to ensure that the queue always maintains the order of "highest to lowest score".

[0052] Then, after each priority queue reordering, the score distribution of all expanded paths in the queue is calculated to determine the pruning threshold. If a dynamic threshold is used, when the queue length exceeds 50, the threshold is set to 60% of the average score of the top 10 paths. All expanded paths in the priority queue are traversed, and expanded paths with scores below the pruning threshold are removed. The number of pruned paths can also be recorded to avoid losing high-quality paths due to over-pruning; for example, the number of paths pruned in a single instance should not exceed 20% of the total queue length. If the number of remaining paths in the queue is too small, such as less than the preset minimum number of paths (20), the pruning threshold is appropriately lowered (e.g., reduced by 10%) and a re-examination is performed to ensure that a sufficient number of candidate paths are always retained during the search process.

[0053] Furthermore, path expansion is stopped when any of the following conditions are met: token budget is exhausted, there are no paths to be expanded in the queue, or the number of expansion rounds reaches a preset limit (e.g., 10 rounds of expansion). All expansion paths in the priority queue are sorted from highest to lowest score. If the total number of paths in the queue exceeds K, the first K expansion paths are selected as the structural hierarchy paths; if the total number of paths is less than K, all paths are retained and marked "less than K paths, all available paths have been returned".

[0054] Optionally, the final selected Top-K paths can be post-processed, including: deduplication, such as removing duplicate paths with identical node sequences; and path structure verification to ensure that the paths conform to the rules of alternating node association in a bipartite graph, avoiding invalid paths with consecutive nodes of the same type. The final output is the complete node sequence of the Top-K optimal paths.

[0055] Following the previous example, assuming a user query is "What are the main reasons for the decline in the company's Q3 profits?", the hierarchical path determined by the two-part diagram is "Financial Data Table → Year-on-Year Analysis Section → Cost Analysis → Management Explanation → Industry Comparison". Assuming a user query is "How to configure an SSL certificate?", the hierarchical path determined by the two-part diagram is "Overview Section → Prerequisites → Detailed Steps → Troubleshooting → Related Command Reference". Assuming a user query is "Compliance Requirements for Cross-Border Transfer of Personal Data", the hierarchical path determined by the two-part diagram is "Legal Definition → Scope of Application → Specific Requirements → Exceptions → Penalties → Implementation Rules".

[0056] The above embodiments begin the search on a bipartite graph, starting with document structure nodes. By leveraging multi-dimensional edge weights between nodes in the bipartite graph, highly relevant structural hierarchical paths are determined. This ensures the relevance of path expansion while adapting to scenarios requiring comprehensive coverage or in-depth mining through different breadth / depth-first strategies. The constraint of the total lexical budget limits the lexical consumption of path expansion, preventing excessive expansion of the search space due to unrestricted expansion and reducing ineffective consumption of computational resources. Score filtering of the expanded paths eliminates low-quality paths, ensuring that the remaining paths all have high relevance. Selecting the top K paths by score from the filtered expanded paths ensures the richness of the results and clarifies the priority of paths through score ranking, enabling the output of the most valuable structural hierarchical paths with limited resources.

[0057] It should be noted that the construction process of the bipartite graph in this application includes: performing structured parsing on the formatted document to obtain document structure elements, which include chapter titles, paragraph markers, table references, image descriptions, etc.; performing lexical decomposition on the content of the formatted document to obtain semantic blocks; and using a lexical-aware hybrid block-segmentation method to segment the content of the formatted document into blocks, obtaining several semantic blocks, and recording the position information of each semantic block in the formatted document. Then, based on the document structure and semantic blocks, a bipartite graph of the formatted document is constructed. The bipartite graph uses document structure elements and semantic blocks as nodes, and the edges of the nodes are determined based on the structural relevance, semantic similarity, positional adjacency, and referencing relationships between nodes.

[0058] The specific process of constructing a bipartite diagram includes: First, starting the document parser and employing differentiated parsing strategies for different document formats such as PDF and Word: For PDF documents, tools such as Poppler and PDFMiner can be used to extract text content and formatting information, identifying chapter heading levels by detecting features such as bold / larger fonts and changes in paragraph spacing; for Word documents, the built-in paragraph styles and object identifiers are read, while retaining positional information such as page numbers and paragraph numbers. Then, structural elements are filtered and extracted from the parsing results: chapter headings, paragraph identifiers, table references, and chart descriptions are categorized as document structure nodes. A unique identifier is created for each document structure node, and its positional information and content summary are recorded, forming a set of document structure nodes.

[0059] Secondly, a hybrid chunking method based on token awareness is employed to chunk the document content. First, hierarchical chunking is performed based on the document's structural hierarchy, creating initial chunks for each structural element. Then, token awareness is adjusted using a tokenizer, setting a token limit (e.g., 512 tokens to fit the input length of mainstream pre-trained models). When an initial chunk exceeds the token limit, a semantic boundary detection model splits it at sentence boundaries to avoid sentence truncation. When adjacent chunks are all below the token limit (e.g., 128 tokens) and have the same hierarchical context (e.g., the same title, the same description), they are merged to improve chunk integrity. Semantic nodes are constructed for each semantic chunk: each is assigned a unique identifier, recording text content, semantic embedding vector, and position coordinates, forming a set of semantic nodes. This hybrid chunking method combines the hierarchical advantages of document structure with precise control of token limitations, ensuring both semantic integrity and that chunk sizes adapt to subsequent processing needs.

[0060] Furthermore, an atomic question set is generated for each document structure node for subsequent intent-level matching. Based on the content summary and associated semantic chunks of the document structure node, a large language model is used to generate several typical questions that the node can answer, forming an atomic question set, and a vector representation is generated for each atomic question.

[0061] Next, the two types of node sets in the bipartite diagram are clearly defined: document structure nodes and semantic nodes, ensuring that the two types of nodes have no overlap and cover both the structural and semantic dimensions of the document. Then, initial associations are established. For chapter title structure nodes, they are associated with the semantic nodes corresponding to all semantic blocks within that chapter; for paragraph identifier structure nodes, they are associated with the semantic nodes corresponding to that paragraph; for table references and chart descriptions structure nodes, they are associated with the semantic nodes corresponding to the paragraph containing the table / chart and surrounding explanatory paragraphs.

[0062] The bipartite graph relationships are stored using an adjacency list, which records the list of semantic nodes associated with each document structure node and the list of document structure nodes associated with each semantic node, thus forming the initial bipartite graph topology.

[0063] Finally, the weights of the associations between nodes are calculated based on at least one of the following: structural relevance, semantic similarity, positional adjacency, and reference relationship; and the edges of the nodes are drawn based on the weights of the associations between them.

[0064] Calculate the weights of the relationships between nodes. This involves calculating the multi-dimensional weights of each edge in the bipartite graph, including at least one of the following: Structure Score, Semantic Score, Position Penalty, and Citation Bonus.

[0065] Among them, structural relevance ensures the weight advantage of strong structural associations such as "parent-child structural nodes" and "adjacent paragraph nodes"; semantic similarity captures the content association of "different words with similar meanings" through vector matching; positional adjacency strengthens the physical association of "same page, adjacent paragraphs"; and citation relationship highlights the logical association of "table-explanatory paragraph" and "chapter-cross-reference".

[0066] When calculating structural relevance weights, first, the document hierarchy is analyzed, constructing a hierarchical tree of structural nodes. For example, chapter titles are parent nodes, paragraph identifiers are child nodes, and table / chart references are paragraph child nodes. Structural distances are defined, such as a distance of 1 between a parent and child node, a distance of 2 between a parent and grandchild node, and a distance of 1 between adjacent sibling nodes. Then, scoring rules are set: a distance of 1 earns 1.0 points, a distance of 2 earns 0.8 points, and for every additional 1 in distance, the score decreases by 0.2 points, with a minimum of 0.2 points. This ensures that parent-child and adjacent relationships have high weights, meeting the defined requirements. Alternatively, when calculating structural relevance weights, weight rules are set based on the document hierarchy. If a semantic node belongs to a document unit directly corresponding to a structural node, the weight is set to 1.0; if a semantic node belongs to a sub-level unit of a structural node, the weight decays according to the hierarchical distance. Finally, the weights are normalized and mapped to the [0, 1] interval.

[0067] When calculating semantic similarity weights, a pre-trained language model is used to vectorize the content summary of structural nodes and the text content of semantic nodes, generating high-dimensional vectors. The similarity between the two vectors is calculated using the cosine similarity formula, and the result is mapped to the [0, 1] interval as the score. If the structural node is associated with a query (such as querying related chapter titles), the score is increased by an additional 10% (e.g., similarity 0.8 is increased to 0.88), strengthening the semantic association weight with the query. Alternatively, when calculating semantic similarity weights, cosine similarity is used to calculate the similarity between the semantic vector of the content summary of the document structural node and the embedded vector of the semantic node, and then combined with the keyword overlap rate for weighted summation. For example, if the semantic similarity accounts for 70% and the keyword overlap rate accounts for 30%, the result is normalized to the [0, 1] interval as the weight of this dimension.

[0068] When calculating the adjacency weight, the page number of a node in the document is used as the core positional indicator, and penalty rules are defined. It can be assumed that nodes on the same page (structural and semantic nodes with the same page number) receive a penalty of 0 points, nodes across one page (page number difference of 1) receive a penalty of 0.2 points, nodes across two pages receive a penalty of 0.4 points, and the penalty score increases by 0.2 points for each additional page crossing, up to a maximum of 1.0 points. This achieves no penalty for content on the same page and penalties for content across pages based on distance, fulfilling the requirement that the weight of the same page is higher than that of cross-page content. Alternatively, when calculating the adjacency weight, the positional coordinates of the document's structural and semantic nodes in the document are used as the basis. If their positions completely overlap, the weight can be set to 1.0; if there is a positional deviation, it is decayed according to distance, such as a weight of 0.8 for a page number difference of 1 page and 0.6 for a paragraph difference of 2 paragraphs, also normalized to the [0, 1] interval.

[0069] When calculating the weight of reference relationships, a coreference resolution model and a reference recognition algorithm are used to detect the reference relationships between structural nodes and semantic nodes. If there is an explicit cross-reference, diagram reference, or coreference relationship, 1.0 point is awarded; if there is an indirect reference, such as a semantic node mentioning a related topic of a document structural node but not explicitly pointing to it, 0.5 points are awarded; if there is no reference relationship, 0 points are awarded. The reward mechanism highlights the importance of reference associations.

[0070] The total weight of the edges can also be calculated using a weighted summation method, with the weight ratio of each dimension set according to actual needs. For example, if the focus is on document structure relevance, α is initially set to 0.35; if the focus is on content semantic matching, β is initially set to 0.4; γ is initially set to 0.2 as a supplementary key association; and δ is initially set to 0.05 because positional differences have a relatively weak impact on association, and α+β+γ+δ=1 must be satisfied. In this example, the sum is 1, but the actual sum can be adjusted according to needs to ensure that the ratio of each parameter is reasonable. The weight is calculated edge by edge using the formula "W(edge)=α×Structure_Score+β×Semantic_Score+γ×Citation_Bonus-δ×Position_Penalty".

[0071] Taking parameters α=0.35, β=0.4, γ=0.2, and δ=0.05 as an example, if one side has Structure_Score=1.0, Semantic_Score=0.9, Citation_Bonus=1.0, and Position_Penalty=0, then W = 0.35×1.0+0.4×0.9+0.2×1.0-0.05×0=0.35+0.36+0.2=0.91; if the other side spanning two pages has Position_Penalty=0.4, and the other scores are the same, then W=0.35+0.36+0.2-0.05×0.4=0.91-0.02=0.89, reflecting the impact of page crossing penalty.

[0072] If the weight is negative, such as low structural score, low semantic score, high position penalty and no reference reward, the weight will be corrected to 0 to avoid invalid negative weights; if the weight exceeds 1, it will be corrected to 1 to ensure that the weight is always in the range of [0, 1] and that the total weight of each edge accurately reflects the comprehensive correlation strength between the document's structural nodes and semantic nodes.

[0073] In the above embodiments, the extraction of document structural elements such as chapter titles and paragraph markers during the construction of the bipartite graph fully preserves the logical hierarchy of the document, providing clear structural anchors for retrieval. Semantic blocks generated by the hybrid segmentation method based on word-based perception divide the document content into semantically complete units, capturing detailed textual information. The dual-node design avoids the semantic ambiguity of pure structural retrieval and solves the structural deficiencies of pure semantic retrieval. Multi-dimensional edge weights quantify the strength of associations between nodes, and the fusion of multi-dimensional edge weights allows the bipartite graph to comprehensively characterize node associations from structural, semantic, physical, and logical perspectives, which helps improve the accuracy of retrieval results.

[0074] After the bipartite graph is constructed, starting from the document structure nodes, the associated nodes with the highest weights are expanded first according to the edge weights of the bipartite graph. Each expansion consumes a corresponding lexical unit, and the sequence and cumulative weight of the path nodes are recorded. When the number of remaining lexical units is lower than the cost of a single expansion, the search for obtaining the structural hierarchy path stops. Paths with cumulative weights below the average weight threshold can be pruned to avoid invalid paths consuming lexical unit budget.

[0075] S203. Based on the structural hierarchy path, determine the target semantic blocks related to the document structure nodes from the bipartite diagram.

[0076] Based on the structural hierarchy path, the semantic nodes related to the document structure nodes are first determined from the bipartite diagram, and then the target semantic blocks located in the formatted document corresponding to the semantic nodes are obtained.

[0077] S204. Reorganize the target semantic blocks.

[0078] In some embodiments, reorganizing the target semantic block includes: decomposing the target semantic block into sentence units, calculating the sentence-level relevance between the sentence units and the user query, and retaining target sentence units whose sentence-level relevance is greater than a first relevance threshold. Then, the semantic relevance of the target sentence units is calculated, and at least two target sentence units whose semantic relevance is greater than a second relevance threshold and whose positions are adjacent are merged. The merged results are further sorted according to logical order to obtain the reorganized target semantic block.

[0079] In the specific implementation of the above embodiments: First, each relevant block is split into sentences. This can be done through punctuation and semantic boundary detection to break down the block into independent sentence units. The relevance score between the sentence unit and the user query is calculated. A bag-of-words model can be used to calculate the overlap rate between the sentence unit and the keywords in the user query. Combined with models such as Sentence-BERT, the cosine similarity between the sentence vector and the query vector is calculated, and the weighted sum of the two is used as the sentence-level relevance score. For example, the keyword overlap rate is 40%, and the vector similarity is 60%. A first relevance threshold is set. If the score is higher than 0.6, highly relevant sentence units above the first relevance threshold are retained, i.e., target sentence units. Simultaneously, semantic coherence checks can be performed on adjacent highly relevant sentences. If two sentences have a referential relationship or causal association, even if one sentence's score is slightly lower than the first relevance threshold (e.g., 0.55-0.6), it must be retained to avoid semantic breaks, ultimately forming a pruned set of sentences.

[0080] Secondly, the system checks whether the target sentence units are adjacent and calculates their semantic relevance through semantic association analysis. Core keywords are extracted for each target sentence unit. If the keyword overlap between two target sentence units exceeds 50%, or if logical connectors exist, they are considered semantically related. For target sentence units that are both adjacent and semantically related, a merging operation is performed: the latter target sentence unit is directly appended to the end of the former, while duplicate expressions between the target sentence units are removed, and transitional phrases are added to ensure the merged text flows smoothly and naturally. For target sentence units that do not meet the conditions, they remain independent to avoid confusion with irrelevant content.

[0081] Finally, the content is logically rearranged, organized in the order of data, analysis, and conclusions. All trimmed and merged text units (i.e., the merged results, including independent and merged blocks) are categorized. Keyword matching and semantic classification models can be used to categorize each text unit into data, analysis, or conclusions. First, all data-related text units are collected and sorted by data type or time sequence; then, analysis-related units are integrated and arranged by analysis depth to ensure a progressive analysis process; finally, conclusion-related units are summarized and sorted by the importance of the conclusions. Logical connection processing is applied to the sorted text units, adding transitional phrases between different types of units and supplementing related vocabulary between units of the same type, ultimately forming a clearly structured and logically coherent reorganized content.

[0082] The above embodiments decompose the target semantic blocks into sentence units. By calculating sentence-level relevance and retaining sentences with relevance above a first threshold, redundant content irrelevant to the query can be accurately filtered out, improving the matching accuracy between the recombined content and the user query. Sentence units with semantic relevance above a second threshold and adjacent positions are merged, enhancing the semantic coherence and information density of the content. The merged results are sorted according to logical order, ensuring that the final recombined content accurately matches the user query and possesses fluent semantic logic and a clear structural hierarchy.

[0083] S205. Generate the context package for the user query based on the reorganized target semantic blocks.

[0084] The context package is used to provide the large language model with the answer to the user query.

[0085] Optionally, the lexical consumption in the aforementioned steps can be recorded, the total consumption can be calculated and compared with the total lexical budget, and a lexical usage report can be generated.

[0086] The reorganized target semantic blocks are aggregated and logically assembled into a coherent collection of paragraphs. A natural language generation model is then used to optimize the semantic connections between paragraphs. For each target semantic block, its structural hierarchy path within the formatted document is annotated (e.g., "Chapter 3 → Section 3.2 → Paragraph 2") to facilitate tracing the content's origin. The processed target semantic blocks and structural hierarchy paths are then encapsulated into a context package, serving as structured input to the large language model. This structured retrieval enhancement yields a high-quality context package, improving the accuracy of answer generation.

[0087] In summary, the retrieval enhancement method provided in this application firstly maps user queries precisely to document structure nodes. Relying on the hierarchical positions and content summaries recorded by these structure nodes, it can quickly pinpoint the core structural anchor points of the document associated with the user query, improving the accuracy of the retrieval starting point and laying a high-quality foundation for subsequent path expansion. Secondly, by leveraging the multi-dimensional relationships between nodes in the bipartite graph, it can systematically mine structural hierarchical paths extending from the starting structural node. This ensures the relevance of path coverage and clearly records the content source through path referencing, providing a clear logical framework for subsequent block selection and avoiding randomness in block selection. Furthermore, by selecting target semantic blocks around the structural hierarchical paths, it ensures a deep connection between semantic blocks and user queries. This goes beyond surface-level word matching, relying on the structural and semantic relationships within the path to select target semantic blocks that truly carry core information. Simultaneously, combined with subsequent reorganization of target semantic blocks, fragmented blocks are transformed into semantically coherent and logically clear structured content. Finally, a context package containing reorganized chunks is generated, which not only integrates accurate core information but also ensures the credibility of the information by tracing the source through structural hierarchy. This provides high-quality, structured material support for the final answer generation, enabling the output answer to accurately match user needs while possessing a clear logical hierarchy and reliable source evidence, thus improving the practicality and user experience of the document retrieval and question-answering system.

[0088] As shown in Figure 3, an embodiment of this application also provides a retrieval enhancement device, which includes:

[0089] The query projection module 301 is used to obtain the user query and map the user query to the corresponding document structure node through multi-scale matching. The document structure node includes the hierarchical position of the document structure element in the formatted document and the content summary.

[0090] The path determination module 302 is used to determine the structural hierarchy path based on the document structure nodes and the pre-built bipartite graph. The structural hierarchy path is a reference path that starts from the document structure node and passes through the associated nodes.

[0091] The semantic block determination module 303 is used to determine the target semantic blocks related to the document structure nodes from the bipartite graph based on the structural hierarchy path;

[0092] Reassembly module 304 is used to reassemble the target semantic blocks;

[0093] The context package generation module 305 is used to generate a context package for the user query based on the reorganized target semantic blocks. The context package is used to provide the large language model to generate the answer to the user query.

[0094] In one specific embodiment, the query projection module 301 is specifically used to determine the complexity of the user query. When the user query contains multiple sub-intents or requires multiple steps of reasoning, the user query is decomposed into multiple sub-problems; otherwise, the user query remains unchanged. Keywords are extracted from the user query or each sub-problem, and the lexical matching score between the keywords and each document structure node is calculated. The user query or each sub-problem and each document structure node are vectorized and encoded, and the semantic similarity between the encoded vectors is calculated to obtain a semantic matching score. A pre-generated set of atomic questions for each document structure node is obtained, and the similarity between the user query or each sub-problem and each atomic question in the set is calculated. The highest similarity is selected as the intent matching score. For each document structure node, its lexical matching score, semantic matching score, and intent matching score are fused according to a set weight to obtain a comprehensive score. The document structure nodes are sorted according to the comprehensive score, and one or more document structure nodes with the highest scores are selected as the document structure nodes corresponding to the user query or sub-problem.

[0095] In one specific embodiment, the path determination module 302 is specifically used for: performing a breadth-first search or depth-first search starting from a document structure node in a bipartite graph to obtain the path to be expanded; determining the associated nodes of the terminal nodes in the path to be expanded under the constraint of the total token budget, and generating the expanded path based on the associated nodes; calculating the score of the expanded path and filtering the expanded paths with scores less than a preset score; and selecting the top K structural hierarchy paths with scores from the filtered expanded paths.

[0096] In one specific embodiment, the reorganization module 304 is specifically used to: decompose the target semantic block into sentence units; calculate the sentence-level relevance between the sentence units and the user query, and retain the target sentence units whose sentence-level relevance is greater than a first relevance threshold; calculate the semantic relevance between the target sentence units, and merge at least two target sentence units whose semantic relevance is greater than a second relevance threshold and whose positions are adjacent; sort the merged results according to the logical order to obtain the reorganized target semantic block.

[0097] In one specific embodiment, the device further includes a bipartite graph construction module, specifically used for: performing structured parsing on the formatted document to obtain document structure elements, and generating an atomic problem set based on the document structure elements; performing lexical decomposition on the content of the formatted document to obtain semantic blocks; using the document structure elements and semantic blocks as nodes of the bipartite graph; and determining the edges of the nodes based on at least one of structural correlation, semantic similarity, positional adjacency, and reference relationship between nodes, thereby constructing a bipartite graph of the formatted document.

[0098] In one specific embodiment, when determining the edges of nodes based on at least one of structural relevance, semantic similarity, positional adjacency, and reference relationships between nodes, the bipartite graph construction module is specifically used to: calculate the weight of the association relationship between nodes based on at least one of structural relevance, semantic similarity, positional adjacency, and reference relationships between nodes; and draw the edges of nodes based on the weight of the association relationship between nodes.

[0099] Regarding the apparatus in the above embodiments, the specific manner in which each unit performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0100] As shown in Figure 4, an embodiment of this application also provides an electronic device, including a memory 401 and a processor 402. The memory 401 stores a computer program, and the processor 402 is configured to run the computer program to perform the steps in any of the above-described retrieval enhancement method embodiments.

[0101] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described retrieval enhancement method embodiments at runtime.

[0102] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0103] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described retrieval enhancement method embodiments.

[0104] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above-described retrieval enhancement method embodiments.

[0105] The beneficial effects of the above embodiments can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0106] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0107] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0108] In the description of this application, it should be understood that if the terms "upper", "lower", "front", "rear", "left" and "right" are used to indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the position or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application.

[0109] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0110] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A retrieval enhancement method, characterized in that, include: The system acquires user queries and maps them to corresponding document structure nodes through multi-scale matching. Each document structure node includes the hierarchical position of document structure elements within a formatted document and a content summary. Based on the document structure nodes and a pre-constructed bipartite graph, a hierarchical structural path is determined. This hierarchical path is a reference path originating from the document structure node and passing through associated nodes. Based on the hierarchical structural path, target semantic blocks related to the document structure nodes are determined from the bipartite graph. The target semantic blocks are reorganized; a context package for the user query is generated based on the reorganized target semantic blocks, and the context package is used to provide the large language model to generate the answer to the user query; The step of determining the structural hierarchy path based on the document structure nodes and the pre-constructed bipartite graph includes: performing a breadth-first search or depth-first search starting from the document structure nodes in the bipartite graph to obtain the path to be expanded; determining the associated nodes of the terminal nodes in the path to be expanded under the constraint of the total word budget, and generating the expanded path based on the associated nodes; calculating the score of the expanded path and filtering the expanded paths with scores less than a preset score; selecting the top K structural hierarchy paths with scores from the filtered expanded paths; the step of reorganizing the target semantic block includes: decomposing the target semantic block into sentence units; calculating the sentence-level relevance between the sentence units and the user query, and retaining the target sentence units whose sentence-level relevance is greater than a first relevance threshold; calculating the semantic relevance between the target sentence units, and merging at least two target sentence units whose semantic relevance is greater than a second relevance threshold and whose positions are adjacent; sorting the merged results according to logical order to obtain the reorganized target semantic block.

2. The method according to claim 1, characterized in that, Mapping user queries to corresponding document structure nodes through multi-scale matching includes: determining the complexity of the user query; if the user query contains multiple sub-intents or requires multi-step reasoning, decomposing the user query into multiple sub-problems; otherwise, keeping the user query unchanged; extracting keywords from the user query or each sub-problem and calculating the lexical matching score between the keywords and each document structure node; vectorizing the user query or each sub-problem and each document structure node, and calculating the semantic similarity between the encoded vectors to obtain a semantic matching score; obtaining a pre-generated set of atomic problems for each document structure node, calculating the similarity between the user query or each sub-problem and each atomic problem in the set, and selecting the highest similarity as the intent matching score; for each document structure node, fusing its lexical matching score, semantic matching score, and intent matching score according to a set weight to obtain a comprehensive score; sorting the document structure nodes according to the comprehensive score, and selecting one or more document structure nodes with the highest scores as the document structure nodes corresponding to the user query or sub-problem.

3. The method according to claim 1, characterized in that, The process of constructing the bipartite graph includes: performing structured parsing on the formatted document to obtain document structure elements; performing lexical decomposition on the content of the formatted document to obtain semantic blocks; generating an atomic problem set based on the document structure elements and the semantic blocks; using the document structure elements and the semantic blocks as nodes of the bipartite graph; and determining the edges of the nodes based on at least one of structural relevance, semantic similarity, positional adjacency, and reference relationships between nodes to construct the bipartite graph of the formatted document.

4. The method according to claim 3, characterized in that, Determining the edges of nodes based on at least one of structural relevance, semantic similarity, positional adjacency, and reference relationships between nodes includes: calculating the weights of the association relationships between nodes based on at least one of structural relevance, semantic similarity, positional adjacency, and reference relationships between nodes; and drawing the edges of nodes based on the weights of the association relationships between nodes.

5. A retrieval enhancement device, characterized in that, include: The query projection module is used to obtain user queries and map the user queries to corresponding document structure nodes through multi-scale matching. The document structure nodes include the hierarchical position of document structure elements in the formatted document and content summary. The path determination module is used to determine the structural hierarchy path based on the document structure node and the pre-built bipartite graph. The structural hierarchy path is a reference path that starts from the document structure node and passes through associated nodes. The semantic block determination module is used to determine the target semantic blocks related to the document structure nodes from the bipartite graph based on the structural hierarchy path; The reorganization module is used to reorganize the target semantic blocks; The context package generation module is used to generate a context package for the user query based on the reorganized target semantic blocks. The context package is used to provide the large language model to generate the answer to the user query. The path determination module is used to perform a breadth-first search or depth-first search starting from the document structure node in the bipartite graph to obtain the path to be expanded; under the constraint of the total word budget, determine the associated nodes of the terminal nodes in the path to be expanded, and generate the expanded path based on the associated nodes; Calculate the score of the extended path and filter out extended paths with scores less than a preset value; Select the top K structural hierarchy paths from the filtered expanded paths; The reorganization module is used to decompose the target semantic block into sentence units; Calculate the sentence-level relevance between the sentence unit and the user query, and retain target sentence units whose sentence-level relevance is greater than a first relevance threshold; Calculate the semantic relevance between the target sentence units, and merge at least two target sentence units whose semantic relevance is greater than the second relevance threshold and whose positions are adjacent; sort the merging results according to logical order to obtain the recombined target semantic blocks.

6. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to implement the steps of the retrieval enhancement method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the retrieval enhancement method as described in any one of claims 1 to 4.

8. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the steps of the retrieval enhancement method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Multi-modal document retrieval enhancement generation method based on large model

    CN119988588A

  • Hierarchical semantic-driven retrieval enhancement generation method and system

    CN120632119A