Retrieval optimization method based on hierarchical expert routing model and CoT reasoning

By hierarchical expert routing model and CoT inference, the original document is hierarchically segmented and semantic library construction, combining intelligent routing and CoT inference, the problem of insufficient retrieval efficiency and adaptability in the existing technology is solved, and efficient retrieval and generation in queries of different complexity is achieved.

CN119336900BActive Publication Date: 2025-03-11XIANGJIANG LAB
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411883290.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-03-11
Estimated Expiration
2044-12-19

AI Technical Summary

Technical Problem

In the prior art, the search efficiency and adaptability are poor, and it is difficult to adaptively adjust the search strategy according to the query complexity, resulting in excessive calculation burden when processing simple tasks and low efficiency when processing complex tasks.

Method used

A search optimization method based on hierarchical expert routing model and CoT inference is adopted. By hierarchically segmenting the original document, a hierarchical knowledge base and a hierarchical semantic library are created, and combined with intelligent routing mechanisms and CoT inference, the search path and hierarchical switching are dynamically adjusted to optimize the search process.

Benefits of technology

It realizes flexible response in queries of different complexities, reduces the computational overhead of simple queries, improves the processing ability of complex queries, and significantly improves the retrieval efficiency and generation quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336900B_ABST
    Figure CN119336900B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning, which belongs to the field of data processing technology, and specifically includes: creating a hierarchical knowledge base; extracting and clustering the abstracts of each fragment in each layer of the hierarchical knowledge base to create a hierarchical semantic base; using the central abstracts in the hierarchical semantic base to build a hierarchical index base and combining it with an intelligent routing mechanism to form a hierarchical expert routing model; using the hierarchical expert routing model to determine the target hierarchical index that matches the question in the hierarchical index base; calculating the similarity between the vectorized question and the target hierarchical index; returning the fragment of the original document under the hierarchical semantic base with the highest similarity; using CoT reasoning to drive hierarchical switching, and finally merging the fragments to return to the large model to generate the answer corresponding to the question. Through the scheme of the present invention, the response speed and accuracy of user queries are improved, the adaptive adjustment of the retrieval path is realized, and the retrieval efficiency and adaptability of complex queries are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning. Background Art

[0002] At present, although large language models have made significant progress in the past two years and have performed well on multiple tasks, they have certain limitations due to the lack of specific domain knowledge and real-time information updates. These deficiencies can easily lead to the phenomenon of "hallucination", that is, the model generates inaccurate or even fictitious information. Therefore, it has become an urgent need to supplement large language models with external knowledge bases to alleviate the hallucination problem. Retrieval-Augmented Generation (RAG) has emerged as an important solution, which effectively improves the accuracy of answers to tasks such as question answering, and has gradually become a key means to solve complex information retrieval problems. However, since user queries cannot always be clearly divided into simple or complex, how to adaptively adjust the retrieval strategy according to the query complexity, both to reduce the computational burden of simple tasks and to efficiently deal with complex tasks, is still a problem that needs to be solved by current RAG technology.

[0003] It can be seen that there is an urgent need for a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning with high retrieval efficiency and adaptability. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning, which at least partially solves the problems of poor retrieval efficiency and adaptability in the prior art.

[0005] The embodiment of the present invention provides a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning, including:

[0006] Step 1, segment the original document into layers and create a layered knowledge base;

[0007] Step 2, extract and cluster the fragment summaries of each layer in the hierarchical knowledge base to create a hierarchical semantic library;

[0008] Step 3: Use the central summaries in the hierarchical semantic library to build a hierarchical index library and combine it with the intelligent routing mechanism to form a hierarchical expert routing model;

[0009] Step 4, using the hierarchical expert routing model to determine the target hierarchical index matching the question in the hierarchical index library;

[0010] Step 5: Calculate the similarity between the vectorized question and the target level index;

[0011] Step 6, returning the fragment of the original document in the hierarchical semantic library with the highest similarity;

[0012] Step 7: Use CoT reasoning to drive hierarchical switching, and finally merge the fragments and return them to the large model to generate the answer to the question.

[0013] According to a specific implementation of the embodiment of the present invention, step 1 specifically includes:

[0014] Step 1.1, after preprocessing the original document, use NLTK's sent_tokenize method to tokenize the text at the sentence level, identify common sentence terminators and other punctuation marks, and obtain a set of segmented sentences;

[0015] Step 1.2, adopt a top-down layer-by-layer segmentation strategy to segment the sentence set into a top-level segment set, a middle-level segment set, and a bottom-level segment set.

[0016] According to a specific implementation of the embodiment of the present invention, step 1.2 specifically includes:

[0017] Step 1.2.1, segment the sentence set according to the number of tokens in the sentence set and the first threshold to obtain a top-level segment set;

[0018] Step 1.2.2, segmenting the top-level segment set according to the second threshold to obtain a middle-level segment set;

[0019] Step 1.2.3, segmenting the middle-layer segment set according to the third threshold to obtain a bottom-layer segment set;

[0020] Step 1.2.4, establish a parent-child mapping relationship between the top-level fragment set, the middle-level fragment set and the bottom-level fragment set according to the data structures of the top-level fragment set, the middle-level fragment set and the bottom-level fragment set.

[0021] According to a specific implementation of the embodiment of the present invention, the first threshold is greater than the second threshold, and the second threshold is greater than the third threshold;

[0022] The data structures of the top-level segment set, the middle-level segment set and the bottom-level segment set all include segment id, segment content, segment summary, segment vector, level identifier and upper-level segment.

[0023] According to a specific implementation of the embodiment of the present invention, step 2 specifically includes:

[0024] Step 2.1, using the large language model to generate summaries corresponding to each fragment in each layer of the hierarchical knowledge base;

[0025] Step 2.2, vectorize each summary to obtain its embedding vector;

[0026] In step 2.3, the vectorized summaries of each layer are clustered using the DBSCAN algorithm to build a hierarchical semantic library.

[0027] According to a specific implementation of the embodiment of the present invention, step 3 specifically includes:

[0028] The central summary of each cluster is matched with similar summaries using vector index, so that the clustered summaries constitute a hierarchical index library and are combined with an intelligent routing mechanism to form a hierarchical expert routing model, where each index includes the cluster center summary and associated document fragments.

[0029] According to a specific implementation of the embodiment of the present invention, step 4 specifically includes:

[0030] Step 4.1, obtain the question input by the user;

[0031] Step 4.2, perform part-of-speech tagging and extract keywords through the spaCy model;

[0032] Step 4.3, matching the keyword with the complexity keyword table and calculating the first Boolean value accordingly;

[0033] Step 4.4, extract other entities in the question and calculate the second Boolean value accordingly;

[0034] Step 4.5, calculating the complexity score of the problem according to the first Boolean value and the second Boolean value;

[0035] In step 4.6, based on the comparison of the complexity score with the complexity threshold corresponding to each hierarchical index in the hierarchical index library, the intelligent routing mechanism assigns the problem to the most suitable hierarchical index in the hierarchical index library as the target hierarchical index.

[0036] According to a specific implementation of the embodiment of the present invention, step 5 specifically includes:

[0037] Step 5.1: Use the pre-trained language model to transform the problem into a high-dimensional vector representation

[0038] ;

[0039] Among them, BERT represents the pre-trained model for question vectorization. Indicates a problem;

[0040] Step 5.2: Convert the central summary in the target level index into a high-dimensional vector representation

[0041] ;

[0042] in, represents the central summary of the i-th semantic library;

[0043] Step 5.3, calculate the similarity between the vectorized question and each vectorized central summary

[0044] .

[0045] According to a specific implementation of the embodiment of the present invention, step 6 specifically includes:

[0046] The semantic library corresponding to the highest similarity is selected and all relevant document fragments under the knowledge base are returned through the index.

[0047] According to a specific implementation of the embodiment of the present invention, step 7 specifically includes:

[0048] Step 7.1, analyze the relevance between document fragments through CoT reasoning and delete irrelevant document fragments;

[0049] Step 7.2, determine whether all current document fragments can output the answer corresponding to the question, if so, execute step 7.4, if not, execute step 7.3;

[0050] Step 7.3: If the information provided by all the current document fragments is missing, the upper-level document fragments are automatically retrieved according to the parent-child mapping relationship of these fragments, and step 7.2 is repeated until all the current document fragments can output the answer corresponding to the question;

[0051] Step 7.4, merge all document fragments and remove duplicate information to generate the answer corresponding to the question.

[0052] The retrieval optimization scheme based on the hierarchical expert routing model and CoT reasoning in the embodiment of the present invention includes: step 1, hierarchical segmentation of the original document to create a hierarchical knowledge base; step 2, extracting and clustering the abstracts of each fragment in each layer of the hierarchical knowledge base to create a hierarchical semantic library; step 3, using the central abstracts in the hierarchical semantic library to build a hierarchical index library and combining it with the intelligent routing mechanism to form a hierarchical expert routing model; step 4, using the hierarchical expert routing model to determine the target hierarchical index matching the question in the hierarchical index library; step 5, calculating the similarity between the vectorized question and the target hierarchical index; step 6, returning the fragment of the original document under the hierarchical semantic library with the highest similarity; step 7, using CoT reasoning to drive hierarchical switching, and finally merging the fragments to return to the large model to generate the answer corresponding to the question.

[0053] The beneficial effects of the embodiments of the present invention are as follows: through the solution of the present invention, the documents are hierarchically segmented, a hierarchical semantic library and a hierarchical expert index are constructed, and multi-level information integration from fine-grained to global background is realized, so that the system can flexibly respond to queries of different complexities. Specifically, an intelligent routing mechanism is designed to dynamically optimize the query retrieval path according to the complexity of the query. In addition, a new Chain-of-Thought (CoT) reasoning mechanism is introduced. By judging whether it is necessary to merge fragments or switch levels, the process of traditional CoT reasoning is simplified, ensuring that unnecessary computational overhead is reduced when processing simple queries, and improving the system's ability to handle complex multi-step problems, thereby achieving a significant improvement in retrieval efficiency and generation quality. RAG can not only effectively solve the problems of information loss and insufficient context understanding, but also realize the reasonable allocation and efficient use of resources in query tasks of different complexities. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1 A flowchart of a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning provided by an embodiment of the present invention;

[0056] Figure 2 A system framework diagram of a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning provided by an embodiment of the present invention;

[0057] Figure 3 A schematic diagram of a hierarchical library structure provided by an embodiment of the present invention;

[0058] Figure 4 A schematic diagram of a process for constructing a hierarchical semantic library provided by an embodiment of the present invention;

[0059] Figure 5 An overall framework diagram of a hierarchical expert routing model provided by an embodiment of the present invention;

[0060] Figure 6 A schematic diagram of a process flow of an intelligent routing mechanism provided by an embodiment of the present invention;

[0061] Figure 7 A schematic diagram of a process of CoT-based fragment merging and hierarchical retrieval provided in an embodiment of the present invention;

[0062] Figure 8 A schematic diagram of a CoT reasoning process provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0063] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0064] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.

[0065] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present invention, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.

[0066] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention. The drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0067] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0068] At present, RAG methods are mainly divided into two categories: single-step retrieval and multi-step retrieval. Single-step retrieval is relatively effective for simple tasks or when the user's information needs are clear. However, for complex tasks or tasks involving lengthy text generation, such as long-form question answering, multi-hop reasoning, and thought chain reasoning, relying solely on the user's initial input for retrieval may not fully cover all the external knowledge required by the model. Multi-step retrieval methods can better cope with complex tasks by alternating retrieval and reasoning, but the computational overhead is large and the efficiency is low when processing simple queries.

[0069] IRCoT (Interleaving Retrieval with Chain-of-Thought Reasoning) proposes a strategy to alternate between retrieval and reasoning, aiming to improve the ability to solve complex tasks by alternating between step-by-step reasoning and information retrieval. This method enables the system to better cope with problems that require multi-step reasoning by re-retrieving relevant information after each step of reasoning. Although IRCoT performs well in complex reasoning tasks, its frequent retrieval process brings high computational costs, especially when faced with simple queries, too many retrieval rounds appear to be inefficient.

[0070] RAPTOR (Recursive Abstractive Processing for Tree-Organized Retrieval) processes long texts and complex tasks by building a hierarchical tree structure. This method divides documents into multiple levels and gradually generates abstract summaries of each level to help the model process long texts. RAPTOR performs well in processing multi-step tasks that span multiple documents and levels, and can significantly improve the accuracy of multi-document question answering. However, RAPTOR's multi-level abstract generation process lacks flexibility in the face of changes in query complexity, which may lead to unnecessary multi-level processing, thereby increasing the computational burden of the system.

[0071] Adaptive-RAG proposes an adaptive framework that dynamically selects the optimal retrieval strategy based on query complexity. By training a complexity classifier, this method can flexibly switch between single-step retrieval, no retrieval, and multi-step retrieval according to the complexity of the query, thereby effectively balancing the processing efficiency of complex queries and simple queries. This adaptive strategy significantly reduces the computational overhead when processing simple queries and maintains efficient retrieval and generation capabilities in complex queries. However, Adaptive-RAG still has room for improvement in the accuracy of the classifier, especially when the complexity classification boundary is not obvious, which may lead to inaccurate strategy selection, thus affecting the overall performance of the model.

[0072] An embodiment of the present invention provides a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning, which can be applied to a large language model retrieval process in an Internet scenario.

[0073] See also Figure 1 , is a flowchart of a retrieval optimization method based on a hierarchical expert routing model and CoT reasoning provided by an embodiment of the present invention. Figure 1 As shown, the method mainly comprises the following steps:

[0074] Step 1, segment the original document into layers and create a layered knowledge base;

[0075] Furthermore, the step 1 specifically includes:

[0076] Step 1.1, after preprocessing the original document, use NLTK's sent_tokenize method to tokenize the text at the sentence level, identify common sentence terminators and other punctuation marks, and obtain a set of segmented sentences;

[0077] Step 1.2, adopt a top-down layer-by-layer segmentation strategy to segment the sentence set into a top-level segment set, a middle-level segment set, and a bottom-level segment set.

[0078] Furthermore, the step 1.2 specifically includes:

[0079] Step 1.2.1, segment the sentence set according to the number of tokens in the sentence set and the first threshold to obtain a top-level segment set;

[0080] Step 1.2.2, segmenting the top-level segment set according to the second threshold to obtain a middle-level segment set;

[0081] Step 1.2.3, segmenting the middle-layer segment set according to the third threshold to obtain a bottom-layer segment set;

[0082] Step 1.2.4, establish a parent-child mapping relationship between the top-level fragment set, the middle-level fragment set and the bottom-level fragment set according to the data structures of the top-level fragment set, the middle-level fragment set and the bottom-level fragment set.

[0083] Furthermore, the first threshold is greater than the second threshold, and the second threshold is greater than the third threshold;

[0084] The data structures of the top-level segment set, the middle-level segment set and the bottom-level segment set all include segment id, segment content, segment summary, segment vector, level identifier and upper-level segment.

[0085] In specific implementation, the overall architecture corresponding to the method of the present invention is mainly divided into three levels: data preparation and preprocessing layer, data retrieval layer and large language model generation layer. At the same time, a novel integration of hierarchical semantic library, hierarchical expert routing model and chain of thought (CoT) reasoning is introduced to improve the retrieval process in the RAG system, such as Figure 2 As shown. In the data preparation and preprocessing layer, document hierarchical segmentation is a key step. By dividing the documents into three levels: top, middle, and bottom, a hierarchical knowledge base is created so that key information can be accurately captured at different granularities in the subsequent retrieval process, thereby optimizing the efficiency of subsequent retrieval. In the data retrieval layer, the hierarchical expert routing model dynamically selects the optimal hierarchical expert index through an intelligent routing mechanism to ensure that query analysis can select the most appropriate retrieval path based on the complexity of the problem. Finally, in the large language model generation layer, the Chain-of-Thought (CoT) reasoning mechanism is used to recursively optimize the fragments returned by the data retrieval layer, and by gradually enriching the query context, answers with high accuracy and completeness are generated. This architecture provides a more efficient, flexible, and intelligent solution for document retrieval in a multi-level information environment, which helps to improve retrieval performance in complex scenarios. The specific steps are as follows:

[0086] Hierarchical semantic library is the basis for building hierarchical expert routing model. By dividing the document into top, middle and bottom layers, the core content of each fragment in each layer is condensed into summaries and clustered, so as to build a hierarchical library structure, such as Figure 3 shown.

[0087] Hierarchical knowledge base construction:

[0088] Hierarchical segmentation is a key step in building a hierarchical knowledge base. We proposed a top-down hierarchical text segmentation method, which ensures that the integrity of sentences and paragraphs is maintained during document segmentation, and segments the text into top-level, middle-level, and bottom-level fragments by setting multi-level token restrictions. Each fragment is cut according to the predefined token restrictions to ensure that the top level contains global information, the middle level refines the context, and the bottom level captures local detail information. This layer-by-layer refinement improves the level of detail of information, and the system can flexibly select the appropriate granularity level for retrieval based on the complexity and needs of the query, solving the problems of difficult determination of document fragment length, information loss, and poor retrieval flexibility in traditional RAG systems.

[0089] This method divides the document step by step from top to bottom, ensuring that the fragments at each level contain all the content of the lower level, thereby maintaining the integrity and traceability of the hierarchical structure. The specific process is:

[0090] (1) Sentence boundary recognition

[0091] When segmenting documents, maintaining the integrity of sentences is the key to ensuring information readability and contextual coherence. First, text preprocessing is performed to remove extra spaces, special characters, etc. to make the data neat and make subsequent analysis smoother. We use NLTK's sent_tokenize method to tokenize the text at the sentence level, identifying common sentence terminators (such as ".", question mark "?", exclamation mark "!") and other punctuation (such as quotation marks, brackets, etc.) to confirm the end of the sentence.

[0092] Generate a sentence set S for subsequent hierarchical processing.

[0093] ;

[0094] in, represents the set of segmented sentences, Represents each sentence.

[0095] (2) Top-down segmentation logic

[0096] In order to ensure that the segmentation logic of the top, middle and bottom layers is rigorous and that the layers maintain an inclusion relationship (i.e. the top layer includes the middle layer, and the middle layer includes the bottom layer), a top-down layer-by-layer segmentation strategy can be adopted, and the segmentation of each layer will be refined according to the structure of the previous layer.

[0097] First, initialize and set an empty list to store the current paragraph, and initialize the current token count to zero. Traverse each sentence in the text, check its token count, and then use the token count corresponding to the sentence with the largest token count as the first threshold. If the total token count exceeds the limit after the current sentence is added, move the current sentence to the next segment and start a new segment. Otherwise, add the current sentence to the current segment and update the token count.

[0098] By dynamically determining the total number of tokens in each sentence after adding the fragments, the division of the fragments is rationally planned to ensure that the information between the fragments flows naturally and the sentence structure is not destroyed, thus providing coherent context support for subsequent retrieval and analysis. The following is an introduction to each layer of segmentation:

[0099] ① Top-level segmentation

[0100] The main goal of the top-level segmentation is to obtain the most global information, each segment does not exceed the first threshold, and maintains a large context span. The top-level segmentation is the starting point of the entire hierarchical process, and the result is a segment that covers more global information.

[0101] ;

[0102] in, represents a collection of top-level fragments, Indicates the token threshold for each fragment.

[0103] ②Middle level segmentation

[0104] The goal of mid-level segmentation is to further refine the top-level information. The number of tokens in each mid-level segment does not exceed the second threshold. After completing the top-level segmentation, the mid-level segmentation will be further subdivided based on the content within the top-level segment to ensure that each mid-level segment contains more contextual medium-grained segments.

[0105] ;

[0106] in, represents a collection of middle-level fragments, Indicates the token threshold for each fragment.

[0107] ③ Bottom layer segmentation

[0108] The bottom-level segmentation is the most fine-grained level, focusing on local specific information. The bottom-level segment length does not exceed the third threshold to ensure that the most detailed content is captured. The bottom-level segmentation is based on the middle-level segment, and it is further subdivided into more specific segments.

[0109] ;

[0110] in, represents a collection of underlying fragments, Indicates the token threshold for each fragment.

[0111] The data structure of each fragment is as follows:

[0112] ① Fragment id: uniquely identifies each fragment, for example (top_1, middle_1, low_1).

[0113] ②Fragment content: original text content, storing the fragment information of the current level.

[0114] ③Summary: A brief summary of the fragment, used for quick reference when switching levels.

[0115] ④Fragment vector: A summary vector representation of the fragment, used for similarity calculation.

[0116] ⑤Level identification (level): Indicates the level to which the clip belongs (top, middle, low).

[0117] ⑥ Parent fragment (parent_id): indicates the parent fragment to which the fragment belongs.

[0118] This naming method ensures that each fragment has a unique identifier and can quickly locate the level and document it belongs to. Through the parent_id field of the fragment, it is connected to the fragment of the previous layer so that it can obtain high-level information. In other words, each bottom-level fragment will be pointed to the middle-level fragment, and the middle-level fragment will further point to the top-level fragment. Through this parent-child mapping relationship, the system can gradually trace back from fine-grained information to higher-level information.

[0119] Step 2, extract and cluster the fragment summaries of each layer in the hierarchical knowledge base to create a hierarchical semantic library;

[0120] Based on the above embodiment, step 2 specifically includes:

[0121] Step 2.1, using the large language model to generate summaries corresponding to each fragment in each layer of the hierarchical knowledge base;

[0122] Step 2.2, vectorize each summary to obtain its embedding vector;

[0123] In step 2.3, the vectorized summaries of each layer are clustered using the DBSCAN algorithm to build a hierarchical semantic library.

[0124] When implementing it, Figure 4 As shown in the figure, the construction of the hierarchical semantic library not only simplifies the query process, but also improves the concentration of the overall information by clustering the summaries of each layer. The system can gather information on similar topics at different levels to form a more structured knowledge system, allowing the system to quickly respond to user needs. This structure is designed to ensure that users can quickly obtain relevant information when searching and avoid the trouble of information overload. The specific steps are as follows:

[0125] 1. Summary Generation

[0126] Each layer of the hierarchical knowledge base uses gpt-3.5-turbo to generate fragment summaries for each fragment, allowing the model to convert large blocks of text into concise and coherent summaries of selected fragments, ensuring representative summary information at different levels and ensuring the concentration and accuracy of information.

[0127] 2. Summary Clustering

[0128] After generating summaries of each layer of fragments, clustering is performed next to form a higher-level semantic knowledge base to capture the core semantic information of the text. The purpose of clustering is to classify similar summaries into the same group, thereby improving the organization and retrieval efficiency of information. The steps of the clustering process are as follows:

[0129] (1) Abstract vectorization

[0130] Before clustering, each summary needs to be vectorized to obtain its embedded representation. This step uses the BERT pre-trained embedding model to convert each summary into a vector form. The BERT model learns deep semantic information from the context through a bidirectional Transformer architecture, which is suitable for capturing the complex meaning of text.

[0131] (2) Clustering algorithm selection

[0132] Select a suitable clustering algorithm, such as K-Means, hierarchical clustering, or DBSCAN, based on specific needs and data characteristics.

[0133] DBSCAN (Density-based Clustering with Noise) is a typical density-based spatial clustering algorithm. Compared with K-Means and BIRCH, which are generally only applicable to clustering of convex sample sets, DBSCAN can be applied to both convex sample sets and non-convex sample sets. The algorithm divides areas with sufficient density into clusters and finds clusters of arbitrary shapes in a noisy spatial database. It defines a cluster as the largest set of density-connected points.

[0134] We cluster the vectorized summaries of each layer using the DBSCAN algorithm to generate multiple semantic knowledge bases, such as bottom semantic base_1, bottom semantic base_2, top semantic base_1, and top semantic base_2. Each cluster represents a "topic" or "semantic scene", forming a hierarchical semantic base, and retaining the summary of the cluster center as the representative summary of each semantic base, which is convenient for quickly locating and matching relevant information during the retrieval process.

[0135] The core of the DBSCAN algorithm is to define density and neighborhood. The key parameters include:

[0136] Domain definition: Calculate the ε neighborhood of all points. For each point P in the data set, calculate how many neighbors it has in its ε neighborhood.

[0137] ;

[0138] in, is the number of points that meet the conditions, The distance between points P and Q (as Euclidean distance).

[0139] Core point: The threshold of the number of neighbors is usually defined by a parameter MinPts. If the number N(P) is greater than or equal to MinPts, then P is a core point and a new cluster begins to form, as shown below.

[0140] ;

[0141] After clustering is completed, each cluster has a centroid, which is the average of all summary vectors in the cluster. , centroid The calculation formula is:

[0142] ;

[0143] in, It is clustering The number of points in is each point in the cluster.

[0144] For each point In clustering , calculate and centroid Distance

[0145] ;

[0146] Among them, the Euclidean distance is usually used:

[0147] ;

[0148] Where n is the dimension of the feature, and They are and the value of the centroid on the mth feature.

[0149] Calculate the distance between each summary vector and the centroid in the cluster, and select the summary with the smallest distance as the central summary.

[0150] ;

[0151] in, is the index of the point closest to the centroid. The summary of the final selected centroid is:

[0152] ;

[0153] This means that from the clustering The summary closest to the centroid is selected Serves as the “central summary” of this cluster.

[0154] Step 3: Use the central summaries in the hierarchical semantic library to build a hierarchical index library and combine it with the intelligent routing mechanism to form a hierarchical expert routing model;

[0155] Based on the above embodiment, step 3 specifically includes:

[0156] The central summary of each cluster is matched with similar summaries using vector index, so that the clustered summaries constitute a hierarchical index library and are combined with an intelligent routing mechanism to form a hierarchical expert routing model, where each index includes the cluster center summary and associated document fragments.

[0157] In specific implementation, traditional information retrieval methods usually rely on a single-level indexing mechanism, and users' queries are not all clearly divided into simple or complex, which makes it difficult to adapt to the different semantic granularities in documents, especially in complex fields where the hierarchical characteristics of other document information are more obvious.

[0158] To this end, we propose a hierarchical expert routing model with the overall architecture as follows: Figure 5 The core idea is to dynamically select the most appropriate semantic hierarchical fragments for retrieval based on the complexity of the user's question by combining hierarchical expert indexing and intelligent routing mechanism. The advantage of this method is that it can quickly locate the level related to the semantics of the question with less computing resources, greatly improving the retrieval efficiency and accuracy.

[0159] Independently constructing hierarchical expert indexes in semantic libraries at different levels enables the system to obtain detailed content from refined information while quickly grasping the macro context.

[0160] The central abstract of each cluster is used to quickly match similar abstracts using vector indexes (such as FAISS, Annoy, etc.). The clustered abstracts form semantic library indexes at different levels, as shown below:

[0161] Top-level expert index: contains a high-level summary of the entire document for coarse-grained retrieval, suitable for queries that require the overall context of the document, summary, or answer broad questions.

[0162] Mid-level expert index: contains more detailed summaries and provides medium-granularity retrieval, suitable for answering questions that require context and multiple details, such as queries on technical processes, application scenarios, or multi-dimensional comparisons.

[0163] Underlying expert index: Contains the most fine-grained snippet summaries, providing accurate document content, suitable for refined, precise matching questions, such as specific technical parameters or simple factual queries.

[0164] Each index contains the following:

[0165] Cluster center summary: The most representative summary of each cluster.

[0166] Associated document fragments: point to the original text of all summary fragments in the semantic base.

[0167] Step 4, using the hierarchical expert routing model to determine the target hierarchical index matching the question in the hierarchical index library;

[0168] Based on the above embodiment, step 4 specifically includes:

[0169] Step 4.1, obtain the question input by the user;

[0170] Step 4.2, perform part-of-speech tagging and extract keywords through the spaCy model;

[0171] Step 4.3, matching the keyword with the complexity keyword table and calculating the first Boolean value accordingly;

[0172] Step 4.4, extract other entities in the question and calculate the second Boolean value accordingly;

[0173] Step 4.5, calculating the complexity score of the problem according to the first Boolean value and the second Boolean value;

[0174] In step 4.6, based on the comparison of the complexity score with the complexity threshold corresponding to each hierarchical index in the hierarchical index library, the intelligent routing mechanism assigns the problem to the most suitable hierarchical index in the hierarchical index library as the target hierarchical index.

[0175] When implementing it, Figure 6 As shown in the figure, in a large-scale knowledge base, computing and storage costs are often the key factors that restrict system performance. General retrieval methods usually traverse a wide range of knowledge bases, which often takes a lot of time and storage resources. The intelligent routing mechanism prioritizes relevant levels based on the characteristics and complexity of the problem, thereby reducing unnecessary computing and time overhead, reducing the overall resource requirements of the system, and making it more efficient and scalable when processing large-scale data. In this way, the system can respond to user queries faster and improve user experience.

[0176] 1. Complexity Judgment

[0177] The core of the intelligent routing mechanism is context requirement identification. It determines whether the question needs more context information by analyzing the complexity of the user's question. Complex questions are preferentially routed to hierarchical experts who provide more context information, while simple questions can be quickly answered at a lower level. To this end, we propose a comprehensive complexity assessment method that scores the complexity of input questions through keyword extraction, entity recognition, etc. Intelligent routing can prioritize the selection of appropriate hierarchical expert indexes based on similarity calculation, thereby completing information retrieval efficiently and accurately.

[0178] 1. Keyword extraction

[0179] In the intelligent routing mechanism, keyword extraction is the core link in judging the complexity of questions. By identifying the important words in the user's questions, the amount of contextual information and complexity required can be inferred. The accuracy of this step directly affects whether the system can select the most appropriate hierarchical expert index for retrieval and processing. Based on natural language processing (NLP) technology, keyword extraction can not only automatically identify the core words in the question, but also provide further complexity assessment by matching with the complexity keyword table.

[0180] In order to automatically determine the complexity of questions, this paper uses part-of-speech tagging technology in conjunction with a predefined common complexity keyword table. This method evaluates the complexity of questions by identifying the core words in the question and then matching these words with common patterns in the complexity keyword table.

[0181] (1) Part-of-speech tagging

[0182] Part-of-speech tagging is a technique that automatically marks the grammatical role (such as verbs, nouns, etc.) of each word in a sentence. In the process of keyword extraction, verbs and nouns can often reflect the complexity of the problem, especially for explanatory and reasoning problems. These problems usually contain verbs such as "how" (indicating that the problem requires a solution), "why" (indicating that the problem involves causal relationships), nouns such as "cause" (indicating that a deep explanation is needed), "solution" (indicating that a specific plan is needed), etc.

[0183] ① Load the spaCy model

[0184] First, use spaCy's pre-trained model for language processing. Commonly used models such as zh_core_web_sm, which contains the necessary tools for part-of-speech tagging.

[0185] ②Text processing and part-of-speech tagging

[0186] The question entered by the user is passed into the model for part-of-speech tagging. spaCy will automatically identify each word in the sentence and assign a part-of-speech tag to it (such as verb, noun, etc.).

[0187] ③Extract core vocabulary

[0188] In this step, we are not limited to extracting verbs and nouns, but also identify other core words related to the complexity of the problem, such as adverbs, pronouns and other information. These words can provide richer context clues, thereby helping the system to more fully understand the structure and complexity of the problem. Nouns usually refer to specific objects or concepts related to the problem, adverbs often point to the background or explanatory needs of the problem, and pronouns are often used to ask for specific details or background. By comprehensively extracting these core words, the system can obtain more dimensional information and further enhance its ability to understand the problem.

[0189] (2) Commonly used complexity keyword table matching

[0190] In order to further judge the complexity of the problem, we introduced a table of common complexity keywords. The table contains a set of common complexity keywords, such as "why", "how", "reason", "explanation", "analysis", etc. The keywords in the table usually indicate that the problem requires more contextual information or background explanation.

[0191] After the part-of-speech tagging is completed, the extracted core verbs, nouns, adverbs, and pronouns are matched with the keyword table. Successfully matched keywords will be assigned a higher complexity weight. For example, for the sentence "What is the cause of the system failure?", the system will identify "summarize" (verb) and "cause" (noun), and match them to "summarize" and "cause" in the keyword table, thus judging that the question has a high complexity.

[0192] Keyword table example:

[0193] Pronouns: which, who, where, where, etc.

[0194] Verbs: solve, occur, analyze, summarize, generalize, conclude, outline, introduce, etc.

[0195] Nouns: reason, plan, logic, problem, background, theory, time, etc.

[0196] Adverbs: when, why, how, how, wherefore, mainly, probably, etc.

[0197] In order to perform keyword matching and complexity calculation, the Boolean matching method is used, that is, to determine whether the extracted keywords appear in the keyword table. The corresponding formula is as follows:

[0198] ;

[0199] in, Is a Boolean value, indicating a keyword Whether it exists in the problem, the value is 1 if it exists, and 0 if it does not exist.

[0200] 2. Other entity extraction

[0201] In natural language processing (NLP) tasks, in addition to the basic keywords mentioned above, it is also crucial to extract other entities (such as names, organizations, specific times, places, etc.). Especially when the question contains names, organizations, specific times and places, these entities usually mean that the question has a clearer context and does not require additional background information to answer. The system prioritizes retrieval from the underlying low-grained fragments. Let the extracted other entities be E, and the corresponding entity set be , the matching formula is:

[0202] ;

[0203] in, An extracted entity.

[0204] 3. Complexity calculation

[0205] For the complexity calculation of each question, an effective complexity calculation formula is formulated by combining the keywords extracted by part-of-speech tagging with the matching of the keyword table and the extracted entities:

[0206] ;

[0207] Through this formula, the system can comprehensively consider different factors, so as to more accurately judge the complexity of the problem and choose the best processing strategy accordingly. Is with keywords The corresponding weight indicates the contribution of the keyword to the complexity, n is the total number of keywords extracted, is the weight of the entity, are other entities extracted, and m is the total number of entities.

[0208] 2. Routing Decision

[0209] In the intelligent routing mechanism, according to the complexity score of the question, the system will select the corresponding hierarchical expert index according to the different complexity of the question, thereby improving the efficiency and accuracy of retrieval. The following is the routing strategy based on complexity optimization:

[0210] 1. Bottom-level expert indexing is prioritized:

[0211] For low-complexity queries, especially those containing clear entities such as precise time, place, name or organization, the system will first search from the underlying expert index. These underlying expert indexes contain the most fine-grained semantic fragments and can handle queries with high-precision matching. This strategy is suitable for questions that do not require additional context or background explanation.

[0212] 2. Mid-level expert indexing is preferred:

[0213] When the query is more complex, contains complex keywords (such as "reason", "explanation", "analysis", etc.), or requires contextual support, the system will select the mid-level expert index. The mid-level expert index contains more semantic relationships and background information, and is suitable for processing questions that require a broader context or multi-angle explanation, providing answers of medium granularity.

[0214] 3. Top-level expert indexing is prioritized:

[0215] For highly complex queries, such as those involving keywords such as "why" and "how", and questions that require the system to provide more context or extensive information, the system will first access the top-level expert index. The top-level expert index provides a general overview and global information of the document, which can provide answers to broad or complex high-level queries and is suitable for handling questions involving macro-context, overall summary or multi-step reasoning.

[0216] Complexity score It is the core of determining the routing level of the problem. Based on this score, the system can intelligently select the most suitable hierarchical expert index. The specific rules are as follows:

[0217]

[0218] in, and The thresholds for the complexity of the mid-level expert index and the top-level expert index, They represent the corresponding level expert indexes respectively.

[0219] Step 5: Calculate the similarity between the vectorized question and the target level index;

[0220] Based on the above embodiment, step 5 specifically includes:

[0221] Step 5.1: Use the pre-trained language model to transform the problem into a high-dimensional vector representation

[0222] ;

[0223] Among them, BERT represents the pre-trained model for question vectorization. Indicates a problem;

[0224] Step 5.2: Convert the central summary in the target level index into a high-dimensional vector representation

[0225] ;

[0226] in, represents the central summary of the i-th semantic library;

[0227] ;

[0228] In specific implementation, once the user's question is evaluated for complexity by the intelligent routing in the hierarchical expert routing model and is routed to the corresponding hierarchical expert index, the system will enter the preliminary retrieval stage. The core goal of this process is to vectorize the user's question and calculate the similarity with the hierarchical expert index selected by the intelligent routing. The semantic knowledge base corresponding to the central summary vector with the highest similarity is the target semantic knowledge base. This step ensures that the system can accurately match the most relevant knowledge base, thereby returning all relevant original document fragments under the target semantic knowledge base.

[0229] 1. User Question Vectorization

[0230] In order to calculate the similarity with the hierarchical expert index, we first need to vectorize the user's question. We use the pre-trained language model BERT to convert natural language questions into high-dimensional vector representations. Let the user's question be q, then its vectorized representation is :

[0231] ;

[0232] BERT is a pre-trained model for question vectorization. BERT transforms the input token of question q into the output semantic vector. , capturing the core semantic information of the question.

[0233] 2. Central summary vector representation of semantic knowledge base

[0234] Each level of the semantic knowledge base is constructed by clustering abstracts. The central abstract of the cluster represents the core semantic content of the knowledge base. In the initial retrieval process, the vector of the user's question will be similar to the abstract vector of each cluster center. Let the central abstract of the i-th semantic knowledge base be , which is vectorized as :

[0235] ;

[0236] BERT is also used to summarize Convert to vector , this vector captures the semantic information of the central summary of the knowledge base.

[0237] 3. Similarity calculation

[0238] In order to calculate the similarity between user questions and the central summary of the semantic knowledge base, we use the cosine similarity metric. The calculation formula is:

[0239] ;

[0240] 4. Select the semantic knowledge base with the highest similarity

[0241] The system calculates the user question vector The central summary vector indexed by the level The cosine similarity of , select the semantic knowledge base with the highest similarity. Suppose there are N semantic knowledge bases in this level, then select the knowledge base with the highest similarity :

[0242] ;

[0243] The system will select the semantic knowledge base with the highest similarity as the target semantic knowledge base, and subsequent retrieval will be carried out around this knowledge base.

[0244] Step 6, returning the fragment of the original document in the hierarchical semantic library with the highest similarity;

[0245] Furthermore, the step 6 specifically includes:

[0246] The semantic library corresponding to the highest similarity is selected and all relevant document fragments under the knowledge base are returned through the index.

[0247] In specific implementation, once the most matching semantic knowledge base is determined , the system will return all relevant document fragments under the knowledge base through the index. These document fragments may come from different parent nodes at the same level, but because they are highly similar in semantics, they are classified into the same cluster. The system can aggregate scattered fragments in similar semantic spaces to ensure that the returned information is as complete as possible and relevant to the user's question.

[0248] This flexible retrieval mechanism ensures that the system dynamically balances local details and global information according to the complexity of the question. By introducing a multi-level index structure, the system not only improves its responsiveness to precise queries, but also can handle a wide range of questions that require more context.

[0249] Step 7: Use CoT reasoning to drive hierarchical switching, and finally merge the fragments and return them to the large model to generate the answer to the question.

[0250] Based on the above embodiment, step 7 specifically includes:

[0251] Step 7.1, analyze the relevance between document fragments through CoT reasoning and delete irrelevant document fragments;

[0252] Step 7.2, determine whether all current document fragments can output the answer corresponding to the question, if so, execute step 7.4, if not, execute step 7.3;

[0253] Step 7.3: If the information provided by all the current document fragments is missing, the upper-level document fragments are automatically retrieved according to the parent-child mapping relationship of these fragments, and step 7.2 is repeated until all the current document fragments can output the answer corresponding to the question;

[0254] Step 7.4, merge all document fragments and remove duplicate information to generate the answer corresponding to the question.

[0255] In the specific implementation, in the field of artificial intelligence, especially in natural language processing (NLP), the design and optimization of prompts is the key to improving model performance. In recent years, Chain of Thought (COT), as an emerging prompt design strategy, has gradually attracted widespread attention from researchers and developers.

[0256] Most of the thinking chain COT introduces a series of step-by-step reasoning steps in the prompt to guide the model to think in a logical chain, breaking down complex problems into multiple simple sub-problems or steps. Although it improves the accuracy and interpretability of the output to a certain extent, its complex reasoning process also brings some problems. For example, in the step-by-step reasoning process, the error of each step may accumulate in the subsequent steps; for logically simple problems, the traditional CoT method may cause unnecessary waste of calculations, generate too many intermediate steps, and affect the overall efficiency; on devices with limited computing resources, complex reasoning processes may require more computing resources, resulting in performance degradation.

[0257] To this end, we proposed a new type of CoT, which introduces the CoT mechanism to simplify the reasoning process based on all the original fragments under the hierarchical semantic library selected by the hierarchical expert routing model. Through multiple merging and hierarchical switching, the system's ability to answer complex questions is greatly enhanced. The large model evaluates the integrity, merging, and retrieval path of the fragments through CoT reasoning, allowing the system to generate complete answers that meet user needs more quickly, reducing the risk of error accumulation, achieving efficient and concise information processing, and reducing computing resource consumption.

[0258] 1. Prompt Design

[0259] The prompt design in our CoT reasoning process ensures that the system can gradually evaluate the completeness of the fragments and make decisions on merging or level switching. The following is the prompt used for this method:

[0260] You are an expert in search systems. Based on the user query, determine whether the current snippet fully answers the question "{user query}". Decide if another step is needed or if you are ready to give a final answer. Respond in JSON format, { "title": "","content": "","next_action": ""}, where the key value of "next_action" is either "continue" or "final_answer".

[0261] Here are the steps to complete:

[0262] 1. If there are multiple relevant snippets, analyze the relevance of these snippets to the user query and decide whether they need to be merged. If necessary, merge the relevant snippets and remove duplicate information.

[0263] 2. Determine whether the current fragment is complete enough. If it is incomplete or the information is scattered, mark the need to retrieve the upper-level information. Query the upper-level fragment {parent_id} and repeat this process until the top level is reached or a complete answer is obtained.

[0264] 3. Finally, explain your reasoning and indicate whether higher-level information is needed.

[0265] 2. Specific steps of CoT reasoning retrieval

[0266] like Figure 7 As shown in the figure, based on CoT's fragment merging and hierarchical retrieval, the system can effectively handle complex queries, automatically merge related fragments, progressively retrieve higher-level information, and finally generate coherent and accurate answers. This method not only improves retrieval efficiency, but also significantly improves the user's query experience. The specific steps are as follows:

[0267] 1. Fragment correlation analysis and merging

[0268] The system uses CoT reasoning to analyze the correlation between each fragment, focusing on evaluating whether they can provide relevant information for the user's question. If the content of multiple fragments has a strong semantic association and can jointly explain the user's query, the system will determine that these fragments can be merged and delete redundant fragments. The completeness of the information is improved by intelligently merging related fragments. This makes CoT not just a simple reasoning, but a construction of a more complete answer.

[0269] 2. Fragment integrity judgment

[0270] Because some fragment information is scattered or lacks context, it may not be able to directly answer the user's question. In this step, the system needs to evaluate whether the current fragment content can fully answer the user's query and determine whether the query needs more global background support. For example, if multiple underlying fragments are detailed information but lack corresponding background, CoT reasoning will believe that upper-level global information is needed to provide associations between these fragments.

[0271] 3. Progressive hierarchical search

[0272] If the system detects that some fragments only provide partial information (e.g., insufficient background information or unclear explanations), the system will automatically retrieve the upper-level document fragments based on the parent node information of these fragments and repeat step 2.

[0273] Through this recursive retrieval, more contextual information can be gradually added. The system will progressively search upward until it reaches the top level or finds a fragment that can fully answer the question. This progressive retrieval strategy ensures that upper-level information is fully utilized when needed, rather than simply relying on the underlying fine-grained fragments.

[0274] 4. Final answer generation

[0275] When the system obtains enough fragments through hierarchical switching, it will eventually merge all the fragment contents, eliminate duplicate information, and generate a complete answer.

[0276] 3. CoT Reasoning Example

[0277] Assume the user queries: "What is the cause of the system failure?"

[0278] 1. Step 1: Preliminary Search

[0279] The system found three related segments in the middle-level semantic library, but the content of the segments was relatively scattered. Through correlation analysis, it was confirmed that these segments were related to each other.

[0280] Title: "Fragment Correlation Analysis and Merging"

[0281] Content: "Fragments 1 and 2 are strongly related, and both contain information about system failures. The system attempts to merge the fragments."

[0282] Next_action: "continue"

[0283] 2. Step 2: Fragment integrity determination

[0284] Snippet 1 explains part of the system failure but lacks a solution, while Snippet 2 describes the solution in detail. Upon analysis, the snippets lack global context.

[0285] Title: "Fragment integrity judgment"

[0286] Content: "The combined fragments 1 and 2 provide some background and solution information, but lack an overall analysis of the cause of the failure."

[0287] Next_action: "continue"

[0288] 3. Step 3: Search the upper layer

[0289] Because the middle-level fragments cannot fully answer the question, the system searches the upper-level fragments, which contain a more comprehensive explanation of why the system failed, and after merging, the complete answer is obtained.

[0290] Title: "Searching Upwards"

[0291] Content: "By retrieving the top-level snippets, the system complements the comprehensive analysis of the failure cause. The combined snippets can fully answer the question."

[0292] Next_action: "final_answer"

[0293] 4. Final Result

[0294] The system determines that the merged fragments can fully answer the user's question and returns the final answer. The CoT reasoning example is shown in the figure below. Figure 8 shown.

[0295] The retrieval optimization method based on the hierarchical expert routing model and CoT reasoning provided in this embodiment realizes multi-level information integration from fine-grained to global background by segmenting documents in layers, constructing hierarchical semantic libraries and hierarchical expert indexes, so that the system can flexibly respond to queries of different complexities. Specifically, an intelligent routing mechanism is designed to dynamically optimize the query retrieval path according to the complexity of the query. In addition, a new Chain-of-Thought (CoT) reasoning mechanism is introduced. By judging whether it is necessary to merge fragments or switch levels, the process of traditional CoT reasoning is simplified, ensuring that unnecessary computational overhead is reduced when processing simple queries, and improving the system's ability to handle complex multi-step problems, thereby achieving a significant improvement in retrieval efficiency and generation quality. RAG can not only effectively solve the problems of information loss and insufficient context understanding, but also realize the reasonable allocation and efficient use of resources in query tasks of different complexities.

[0296] Specifically, this paper proposes a hierarchical semantic library construction method based on layered document processing, which divides the documents into three levels: top, middle and bottom according to granularity requirements, effectively organizes semantic information at different levels, and enables the system to intelligently select different granularity levels for retrieval according to query requirements, solving the problem that the traditional RAG segmentation length is difficult to flexibly adjust, and improving the response speed and accuracy of user queries.

[0297] This paper proposes a hierarchical expert routing model. Through natural language processing technology, the query type is analyzed. The system can intelligently select appropriate hierarchical experts as the initial retrieval based on the analysis results, avoiding the inefficient operation of indiscriminate traversal of all document fragments in traditional methods and optimizing the query path.

[0298] This paper proposes to introduce Connection of Thought (CoT) reasoning into the retrieval process, using the reasoning ability of CoT to dynamically adjust the retrieval depth and efficiently switch between different levels. It can not only merge the underlying refined information, but also trace back to higher levels to provide comprehensive contextual support, thus realizing the adaptive adjustment of the retrieval path and improving the processing capability of complex queries.

[0299] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof.

[0300] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A retrieval optimization method based on hierarchical expert routing model and CoT reasoning, characterized in that: include: Step 1, segment the original document into layers and create a layered knowledge base; Step 2, extract and cluster the fragment summaries of each layer in the hierarchical knowledge base to create a hierarchical semantic library; Step 3: Use the central summaries in the hierarchical semantic library to build a hierarchical index library and combine it with the intelligent routing mechanism to form a hierarchical expert routing model; The step 3 specifically includes: The central summary of each cluster is matched with similar summaries using vector index, so that the clustered summaries form a hierarchical index library and are combined with the intelligent routing mechanism to form a hierarchical expert routing model, where each index includes the central summary of the cluster and the associated document fragments; Step 4, using the hierarchical expert routing model to determine the target hierarchical index matching the question in the hierarchical index library; Step 5: Calculate the similarity between the vectorized question and the target level index; Step 6, returning the fragment of the original document in the hierarchical semantic library with the highest similarity; Step 7: Use CoT reasoning to drive layer switching, and finally merge the fragments back into the big model to generate the answer to the question. The step 7 specifically includes: Step 7.1, analyze the relevance between document fragments through CoT reasoning and delete irrelevant document fragments; Step 7.2, determine whether all current document fragments can output the answer corresponding to the question, if so, execute step 7.4, if not, execute step 7.3; Step 7.3: If the information provided by all the current document fragments is missing, the upper-level document fragments are automatically retrieved according to the parent-child mapping relationship of these fragments, and step 7.2 is repeated until all the current document fragments can output the answer corresponding to the question; Step 7.4, merge all document fragments and remove duplicate information to generate the answer corresponding to the question.

2. The method according to claim 1, characterized in that: The step 1 specifically includes: Step 1.1, after preprocessing the original document, use NLTK's sent_tokenize method to tokenize the text at the sentence level, identify common sentence terminators and other punctuation marks, and obtain a set of segmented sentences; Step 1.2, adopt a top-down layer-by-layer segmentation strategy to segment the sentence set into a top-level segment set, a middle-level segment set, and a bottom-level segment set.

3. The method according to claim 2, characterized in that The step 1.2 specifically includes: Step 1.2.1, segment the sentence set according to the number of tokens in the sentence set and the first threshold to obtain a top-level segment set; Step 1.2.2, segmenting the top-level segment set according to the second threshold to obtain a middle-level segment set; Step 1.2.3, segmenting the middle-layer segment set according to the third threshold to obtain a bottom-layer segment set; Step 1.2.4, establish a parent-child mapping relationship between the top-level fragment set, the middle-level fragment set and the bottom-level fragment set according to the data structures of the top-level fragment set, the middle-level fragment set and the bottom-level fragment set.

4. The method according to claim 3, characterized in that The first threshold is greater than the second threshold, and the second threshold is greater than the third threshold; The data structures of the top-level segment set, the middle-level segment set and the bottom-level segment set all include segment id, segment content, segment summary, segment vector, level identifier and upper-level segment.

5. The method according to claim 4, characterized in that The step 2 specifically includes: Step 2.1, using the large language model to generate summaries corresponding to each fragment in each layer of the hierarchical knowledge base; Step 2.2, vectorize each summary to obtain its embedding vector; In step 2.3, the vectorized summaries of each layer are clustered using the DBSCAN algorithm to build a hierarchical semantic library.

6. The method according to claim 5, characterized in that The step 4 specifically includes: Step 4.1, obtain the question input by the user; Step 4.2, perform part-of-speech tagging and extract keywords through the spaCy model; Step 4.3, matching the keyword with the complexity keyword table and calculating the first Boolean value accordingly; Step 4.4, extract other entities in the question and calculate the second Boolean value accordingly; Step 4.5, calculating the complexity score of the problem according to the first Boolean value and the second Boolean value; In step 4.6, based on the comparison of the complexity score with the complexity threshold corresponding to each hierarchical index in the hierarchical index library, the intelligent routing mechanism assigns the problem to the most suitable hierarchical index in the hierarchical index library as the target hierarchical index.

7. The method according to claim 6, characterized in that The step 5 specifically includes: Step 5.1: Use the pre-trained language model to transform the problem into a high-dimensional vector representation ; Among them, BERT represents the pre-trained model for question vectorization. Indicates a problem; Step 5.2: Convert the central summary in the target level index into a high-dimensional vector representation ; in, represents the central summary of the i-th semantic library; Step 5.3, calculate the similarity between the vectorized question and each vectorized central summary 8. The method according to claim 7, characterized in that The step 6 specifically includes: The semantic library corresponding to the highest similarity is selected and all relevant document fragments under the knowledge base are returned through the index.

Citation Information

Patent Citations

  • Document knowledge base-oriented multi-granularity structured retrieval enhancement generation method and device

    CN118585615A

  • Generating snippets for prominent users for information retrieval queries

    WO2014055764A2