Knowledge base retrieval method fusing natural language large model
By constructing a knowledge base hypergraph and dense vector index, and combining multi-view query representation and hypergraph semantic diffusion aggregation of natural language large models, the problem of insufficient structural association recognition in complex queries in existing knowledge base retrieval methods is solved, and high-quality answer generation and reasoning support are achieved.
Patent Information
- Application Number
- CN202511724688.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-11-24
AI Technical Summary
Existing knowledge base retrieval methods struggle to identify structural relationships between texts when handling complex queries, especially when reasoning and judgment are required. Dense vector retrieval cannot effectively capture path relationships between multiple texts, resulting in inaccurate and insufficient retrieval results.
We construct a knowledge base hypergraph, combine dense vector indexes and a large natural language model, perform hypergraph semantic diffusion aggregation through multi-view query representation, generate multi-view local semantic summaries, and perform fusion and ranking to obtain high-quality answers.
It significantly improves the accuracy, coverage, and interpretability of knowledge retrieval, and can stably provide structurally sound, semantically consistent, and reasoning-supported answers in complex query scenarios, thereby improving the performance of the knowledge base system in high-difficulty retrieval scenarios.
Smart Images

Figure CN121168677B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a knowledge base retrieval method that integrates a large natural language model. Background Technology
[0002] In the development of information retrieval and question-answering technologies, with the accumulation of large-scale corpora and the improvement of semantic modeling capabilities, more and more systems are beginning to adopt natural language processing (NLP) techniques to structure the text in knowledge bases to support semantic-level retrieval. In early implementations, knowledge bases were typically constructed as flat structures composed of documents and sentences. Users' natural language queries were compared with documents or sentences using keyword matching or word frequency-based calculations, selecting the segment containing the most keywords as candidate answers. While these methods are simple to implement, they lack the ability to describe the deep semantics of the text and the relationships between concepts. For questions with diverse expressions, complex structures, or those requiring reasoning and judgment, it is difficult to effectively retrieve truly relevant knowledge segments. This often results in false recalls of superficially similar but semantically unrelated text, or situations where the target content is not matched due to users not using standard terminology.
[0003] With the development of pre-trained semantic encoding models, dense vector retrieval has gradually become one of the mainstream technologies. By encoding knowledge base text into dense vectors, nearest neighbor retrieval can be performed in a continuous space, thus gaining stronger robustness when dealing with synonym substitution, expression differences, or cross-domain references. However, dense vector retrieval usually relies on the overall semantic similarity between vectors. Although this method can capture the proximity relationship at the semantic level of text, it is difficult to identify the structural associations between texts. For example, two knowledge fragments may share the same entity name or topic tag, but due to significant differences in expression, they are still far apart in the dense vector space, and therefore cannot be recalled in a purely vector-based retrieval architecture. In addition, dense vector retrieval has limited performance when dealing with problems that require reasoning, because reasoning often involves structural path relationships between multiple texts, and dense vector retrieval inherently lacks the ability to explicitly model graph structures or hyperedge structures. Summary of the Invention
[0004] The purpose of this invention is to provide a knowledge base retrieval method that integrates a large-scale natural language model. This method constructs a knowledge base hypergraph composed of knowledge fragments, entity identifiers, and topic tags, and combines this with a dense vector index that records dense vectors of knowledge fragments. Utilizing a multi-perspective query representation generated by the large-scale natural language model, a multi-perspective hypergraph semantic diffusion aggregation algorithm is executed on the hypergraph structure to obtain a set of candidate knowledge fragments that possess semantic, entity, and inference associations. Subsequently, a multi-perspective fusion and ranking process is used to determine the target knowledge fragment set, and based on this, retrieval answers for user queries are generated. Through joint modeling of semantic, entity, and inference perspectives, and the combination of the hypergraph structure and dense vector space, this invention significantly improves the accuracy, coverage, and interpretability of knowledge retrieval, and can stably obtain high-quality answers with tight structure, semantic consistency, and inference support even in complex query scenarios.
[0005] To address the aforementioned technical problems, this invention provides a knowledge base retrieval method integrating a large natural language model, comprising the following steps:
[0006] Step 1: Construct a knowledge representation structure, which includes a knowledge base hypergraph based on knowledge fragments, entity identifiers, and topic tags, as well as a dense vector index that records dense vectors of knowledge fragments;
[0007] Step 2: Parse the user's original natural language query, generate a multi-view query representation, and obtain the set of starting nodes by matching the original natural language query in the knowledge base hypergraph;
[0008] Step 3: On the knowledge base hypergraph, based on the set of starting nodes and the multi-view query representation, execute the multi-view hypergraph semantic diffusion aggregation algorithm to determine the set of candidate knowledge fragments and the corresponding multi-view local semantic summaries;
[0009] Step 4: Call the natural language processing model to perform multi-view fusion and sorting of the candidate knowledge fragment set to obtain the target knowledge fragment set, and generate the search answer based on the target knowledge fragment set.
[0010] Further, step 1 specifically includes: dividing each document in the knowledge base into multiple knowledge segments according to the rule that the continuous text length is between 200 and 500 characters, and generating a unique segment identifier for each knowledge segment; performing entity identifier extraction on each knowledge segment to obtain a set of entity identifiers containing proper nouns, term names, and abbreviations, and generating at least one topic tag for each knowledge segment based on the document's domain and chapter title; constructing a knowledge base hypergraph based on this, using knowledge segments, entity identifiers, and topic tags as hypergraph nodes, and using a set of nodes consisting of multiple knowledge segments under the same topic tag and at least one common entity identifier as a hyperedge; recording the list of nodes associated with each hyperedge and the list of hyperedges associated with each node in the form of an adjacency list; simultaneously, using a pre-trained semantic encoding model to generate a dense vector of length 768 for each knowledge segment, storing all dense vectors in a dense vector index; and recording the position index of the corresponding dense vector in the dense vector index for each knowledge segment node in the knowledge base hypergraph, thus obtaining a knowledge representation structure based on the knowledge base hypergraph and the dense vector index.
[0011] Further, step 2 specifically includes: receiving the original natural language query input by the user; inputting the original natural language query into the natural language large model; and having the natural language large model output three query texts for different purposes, namely, semantic view query text, entity view query text, and reasoning view query text; wherein the semantic view query text retains the original question statement, the entity view query text only retains entity names and key terms, and the reasoning view query text adds a description of the reasoning purpose; calling the entity recognition component to process the entity view query text to obtain a target entity identifier set, and simultaneously calling the topic extraction component to process the semantic view query text to obtain a target topic tag set; matching the target entity identifier set and the target topic tag set in the knowledge base hypergraph, and using the successfully matched entity identifier nodes, topic tag nodes, and knowledge fragment nodes directly connected to them through hyperedges as the starting node set; and using the pre-trained semantic encoding model consistent with the knowledge base hypergraph and dense vector index construction steps to encode the semantic view query text, entity view query text, and reasoning view query text respectively, to obtain semantic view dense vector representation, entity view dense vector representation, and reasoning view dense vector representation, as multi-view query representations.
[0012] Furthermore, step 3 includes initialization and diffusion sub-steps, specifically including: initializing the activation node set, adding all knowledge fragment nodes from the starting node set to the activation node set, setting the diffusion layer count to 1, fixing the maximum diffusion layer to 3, and initializing the candidate node set to empty; under the condition that the diffusion layer count is not greater than 3 and new nodes are found in the current diffusion layer, for each knowledge fragment node in the activation node set, reading the list of hyperedges associated with the knowledge fragment node in the knowledge base hypergraph; for each hyperedge, sequentially taking other knowledge fragment nodes from the node list of the hyperedge as new node candidates, skipping the nodes that have already been processed, counting the number of new node candidates obtained in the current diffusion layer, and stopping the introduction of new node candidates when the number reaches 50.
[0013] Furthermore, step 3 also includes a sub-step for calculating the multi-view similarity level, specifically including: for each new node candidate obtained in the initialization and diffusion sub-step, the multi-view similarity level is calculated according to the following process: First, the dense vector of the knowledge fragment corresponding to the new node candidate is located in the dense vector index through the record in the knowledge base hypergraph. The dense vector is then input into the cosine similarity calculation function provided in the vector retrieval library along with the dense vector representations of the semantic view, entity view, and reasoning view, respectively, to obtain three similarity values between 0 and 1. Second, the semantic view level, entity view level, and reasoning view level are generated according to the three similarity values, where the semantic view level is set to 3 when the semantic view similarity is not less than 0.8, the semantic view level is set to 2 when the semantic view similarity is above 0.6 and less than 0.8, and the semantic view level is set to 1 when the semantic view similarity is less than 0.6. The entity view and reasoning view adopt the same grading rules, mapping the corresponding similarity values to levels 1 to 3.
[0014] Furthermore, step 3 also includes a sub-step for calculating the structural association level, specifically including: generating a structural association level based on the connectivity between the new node candidate and the starting node set in the knowledge base hypergraph; wherein when the shortest path length between the new node candidate and any knowledge fragment node in the starting node set is 1 and the new node candidate and the knowledge fragment node share at least 2 hyperedges, the structural association level is set to 3; when the shortest path length is 1 and they share 1 hyperedge or the shortest path length is 2, the structural association level is set to 2; otherwise, the structural association level is set to 1.
[0015] Furthermore, step 3 also includes a sub-step for filtering and grouping new node candidates, specifically including: when the semantic perspective level is not less than 2, the entity perspective level is not less than 1, and the reasoning perspective level is not less than 1, the new node candidate is added to the candidate node set, and the semantic perspective level, entity perspective level, reasoning perspective level, and structural association level of the new node candidate are recorded; when the entity perspective level is not less than 2 and the structural association level is not less than 2, the new node candidate is added to both the candidate node set and the temporary set of activated nodes in the next layer; when the semantic perspective level is not less than 2 and the structural association level is not less than 2, the new node candidate is added to the temporary set of activated nodes in the next layer.
[0016] Furthermore, step 3 also includes diffusion iteration and sorting sub-steps, specifically including: replacing the activation node set with the temporary set of activation nodes for the next layer obtained at the end of the current diffusion layer, incrementing the diffusion layer count by 1, and stopping diffusion when the activation node set is empty or the diffusion layer count is greater than 3; after diffusion ends, sorting all knowledge fragment nodes recorded in the candidate node set according to the following rules: first, sorting by semantic perspective level from high to low; when semantic perspective levels are the same, sorting by reasoning perspective level from high to low; when reasoning perspective levels are still the same, sorting by entity perspective level from high to low; when all three levels are the same, sorting by structural association level from high to low; when all four levels are exactly the same, sorting by semantic perspective similarity value from high to low; and taking the top 100 knowledge fragment nodes in order according to the sorting results to form a candidate knowledge fragment set.
[0017] Furthermore, step 3 also includes a sub-step for generating a multi-perspective local semantic summary, specifically including: for each knowledge fragment node in the candidate knowledge fragment set, reading other knowledge fragment nodes directly connected to the knowledge fragment node through hyperedges from the knowledge base hypergraph; concatenating the knowledge fragment text corresponding to the knowledge fragment node with the knowledge fragment texts corresponding to up to 3 connected knowledge fragments to form a local context text; inputting the local context text along with the original natural language query into the natural language big model; instructing the natural language big model to generate 3 local semantic descriptions, where the first description describes the local content related to the semantic perspective, the second description describes the local content related to the entity perspective, and the third description describes the local content related to the reasoning perspective; and storing the 3 local semantic descriptions as a multi-perspective local semantic summary associated with the corresponding knowledge fragment node.
[0018] Further, step 4 specifically includes: organizing the knowledge fragment text, multi-view local semantic summary, and ranking position of each knowledge fragment node in the candidate knowledge fragment set into a structured input; inputting the structured input containing no more than 20 candidate knowledge fragment nodes into the natural language big data model along with the original natural language query; instructing the natural language big data model to provide semantic relevance scores, entity relevance scores, and inference relevance scores for each candidate knowledge fragment, with the scores limited to integers between 1 and 5; and fusing and ranking the candidate knowledge fragments according to the order of semantic relevance scores from high to low, inference relevance scores from high to low, entity relevance scores from high to low, and the original ranking in the candidate knowledge fragment set from front to back; selecting the top 5 knowledge fragments from the fusion ranking results as the target knowledge fragment set; inputting the knowledge fragment text corresponding to the target knowledge fragment set, the multi-view local semantic summary, and the knowledge fragment text directly connected to the target knowledge fragment set in the knowledge base hypergraph into the natural language big data model; and generating a retrieval answer corresponding to the original natural language query by the natural language big data model, taking into account the semantic, entity, and inference perspectives simultaneously.
[0019] The knowledge base retrieval method of this invention, which integrates a large-scale natural language model, has the following beneficial effects: By synergistically integrating a knowledge base hypergraph, dense vector indexing, and multi-perspective query representation of a large-scale natural language model, this invention enables knowledge retrieval to simultaneously possess stability, coverage, and interpretability across three dimensions: semantic association, structural association, and inference association. This significantly outperforms existing technologies that rely solely on keyword matching, dense vector retrieval, or ordinary graph structures. The knowledge base hypergraph constructed by this invention can simultaneously express the multi-dimensional relationships between knowledge fragments, entity identifiers, and topic tags. This allows the retrieval process to not only identify semantically similar content but also discover structurally closely related knowledge fragments along entity and topic links, avoiding omissions due to differences in representation. The multi-perspective hypergraph semantic diffusion aggregation algorithm proposed in this invention can explore relevant content layer by layer within a limited diffusion range, centered on a set of starting nodes. It uses multi-perspective similarity levels and structural association levels to jointly filter candidate nodes, ensuring that the retrieval scope is neither over-expanded nor misses deep-level related information. The multi-perspective local semantic summaries generated on this basis further enhance the interpretability of candidate knowledge fragments, enabling the large-scale natural language model to more accurately understand the role of each fragment during the fusion and ranking stage. This invention utilizes a large-scale natural language model in its final stage to simultaneously reference semantic, entity, and reasoning perspectives for fusion and sorting. This ensures that the set of target knowledge fragments centrally reflects the core intent of the user's query, avoiding information bias caused by single-perspective sorting. The resulting search answer is not only semantically accurate but also logically clear, providing high-quality content supported by multi-source associations and reasoning chains. This invention demonstrates significant stability and reliability in complex cross-domain queries, multi-entity aggregation queries, and highly reasoning-based questions, effectively improving the overall performance of knowledge base systems in challenging retrieval scenarios. Attached Figure Description
[0020] Figure 1 A schematic diagram illustrating the generation structure and encoding process of the multi-view query representation provided in an embodiment of the present invention;
[0021] Figure 2 This is a schematic diagram of the hypergraph diffusion polymerization process provided in an embodiment of the present invention;
[0022] Figure 3 This is a dense vector semantic space distribution diagram provided for embodiments of the present invention. Detailed Implementation
[0023] Example 1: A knowledge base retrieval method integrating a large natural language model, comprising the following steps:
[0024] Step 1: Construct a knowledge representation structure, which includes a knowledge base hypergraph based on knowledge fragments, entity identifiers, and topic tags, as well as a dense vector index that records dense vectors of knowledge fragments;
[0025] Step 2: Parse the user's original natural language query, generate a multi-view query representation, and obtain the set of starting nodes by matching the original natural language query in the knowledge base hypergraph;
[0026] Step 3: On the knowledge base hypergraph, based on the set of starting nodes and the multi-view query representation, execute the multi-view hypergraph semantic diffusion aggregation algorithm to determine the set of candidate knowledge fragments and the corresponding multi-view local semantic summaries;
[0027] Step 4: Call the natural language processing model to perform multi-view fusion and sorting of the candidate knowledge fragment set to obtain the target knowledge fragment set, and generate the search answer based on the target knowledge fragment set.
[0028] Example 2: In one implementation, when constructing the knowledge representation structure, the system first reads document content one by one from a pre-configured knowledge base. Each document can be a technical specification, standard text, patent text, or internal knowledge document. To facilitate fine-grained association of information in the knowledge base hypergraph and to achieve a relatively stable semantic representation in the dense vector index, each document is divided into multiple knowledge segments according to the rule that the length of continuous text is between 200 and 500 characters. Specifically, during the segmentation process, segmentation is preferentially performed at natural sentence breaks such as periods, semicolons, and paragraph separators. When the current cumulative character count approaches 300 characters, segmentation is attempted at the nearest punctuation mark. If the current paragraph is short, it is allowed to be extended to no more than 500 characters. When the total length of a document is 10,000 characters, approximately 20 to 40 knowledge segments can usually be obtained. For each knowledge segment generated, the system generates a unique segment identifier. The segment identifier can use an integer number that increments from 0 and is associated with the document identifier and the starting character position in the document for easy subsequent location and tracing.
[0029] After acquiring knowledge fragments, the system performs entity identifier extraction for each fragment. Entity identifier extraction can be based on a pre-trained entity recognition model combined with a manually maintained terminology dictionary. The entity recognition model detects personal names, organization names, professional terms, and abbreviations, while the terminology dictionary supplements specific industry terms not covered by the model. For a knowledge fragment of 300 characters, typically 2 to 10 entity identifiers can be extracted. Each entity identifier is uniformly registered globally. When a new entity name is discovered, it is standardized into a standard representation, such as unifying capitalization, eliminating extra spaces, and assigning a globally unique entity identifier. In this way, when the same entity name or its different spellings appear in different knowledge fragments, they can all point to the same entity identifier, forming a stable cross-document connection in the knowledge base hypergraph, facilitating the aggregation of knowledge fragments related to the same entity during retrieval.
[0030] To further characterize the thematic information of knowledge fragments, the system generates at least one topic tag for each knowledge fragment based on the document's domain, chapter title, section title, and high-frequency keywords appearing within the fragment. Specifically, the domain category, such as "computer networks," "image processing," and "financial risk control," is first extracted from the document's metadata. Then, the topic tag is determined by combining the chapter title and the knowledge fragment content with keyword statistics and topic candidates generated by a natural language processing model. When the topic suggested by the natural language processing model is close to the topic obtained from keyword statistics, that topic is used as the topic tag. When there is a significant difference, the topic that is closer to the document's domain and has a higher frequency of use in the knowledge base is prioritized as the topic tag. For knowledge fragments containing multiple different knowledge points, two to three topic tags can be configured to increase the chances of association and recall in the knowledge base hypergraph. By attaching topic tags to knowledge fragments, topic-level aggregation can be formed in the knowledge base hypergraph, facilitating rapid narrowing of the search scope during subsequent retrieval.
[0031] After obtaining knowledge fragments, entity identifiers, and topic tags, the system begins constructing a knowledge base hypergraph. In the knowledge base hypergraph, knowledge fragments, entity identifiers, and topic tags all serve as nodes. Each knowledge fragment node is associated and stored with its corresponding fragment identifier, its document identifier, and its starting position within the document; each entity identifier node is associated and stored with its standardized entity name and a list of possible synonyms; and each topic tag node is associated and stored with its textual description and its domain category. Subsequently, the system generates hyperedges according to a preset edge-building strategy. For each topic tag, all knowledge fragment nodes containing that topic tag are found, and among these knowledge fragment nodes, those containing at least one common entity identifier are further filtered. If the nodes share the same topic tag and at least one entity identifier, these knowledge fragment nodes, their corresponding entity identifier nodes, and the topic tag node are grouped into a node set, and a hyperedge is generated for this node set. In this way, a hyperedge can connect multiple knowledge fragment nodes, at least one entity identifier node, and one topic tag node simultaneously, thereby expressing the multi-dimensional relationship of "several knowledge fragments revolving around the same topic and involving the same entity" in the knowledge base hypergraph. Compared with the ordinary graph structure that only uses binary edges, it can more naturally represent many-to-many semantic associations, reduce the introduction of intermediate virtual nodes, and enable the subsequent multi-view hypergraph semantic diffusion aggregation algorithm to simultaneously perceive the common structure between multiple related knowledge fragments in one diffusion step.
[0032] To improve the efficiency of the knowledge base hypergraph in storage and traversal, the system uses an adjacency list to record the list of nodes associated with each hyperedge and the list of hyperedges associated with each node. Specifically, for each hyperedge, the system records a hyperedge identifier and a list of node identifiers. The node identifier list contains all knowledge fragment nodes, entity identifier nodes, and topic tag nodes connected by that hyperedge. For each node, the system records a node identifier and a list of hyperedge identifiers, which contains all hyperedges connected to that node. The advantage of the adjacency list is that when it is necessary to expand the knowledge base hypergraph from a certain knowledge fragment node, it is only necessary to look up the corresponding hyperedge identifier list based on the node identifier, and then retrieve other nodes from the node identifier list of each hyperedge to complete one expansion step, avoiding a full graph scan and reducing storage space and traversal time overhead. For a knowledge base containing 100,000 documents and millions of knowledge fragments, the knowledge base hypergraph stored using adjacency lists can complete regular query and expansion operations on a regular server.
[0033] After constructing the knowledge base hypergraph, the system uses a pre-trained semantic coding model to generate dense vectors for each knowledge fragment and stores these dense vectors in a dense vector index. The pre-trained semantic coding model can be a publicly available Chinese semantic coding model or a semantic coding model fine-tuned on domain-specific data. During encoding, the system first standardizes the knowledge fragment text, removing redundant spaces and unifying punctuation. For excessively long knowledge fragments, appropriate truncation can be performed without compromising semantic integrity. The standardized knowledge fragment text is then input into the pre-trained semantic coding model to obtain dense vectors of length 768. Each dense vector consists of 768 real values, which collectively describe the position of the knowledge fragment in the semantic space, ensuring that semantically similar knowledge fragments have similar dense vector representations. The system stores all dense vectors sequentially in a dense vector index, assigning a position index to each dense vector. Position indices can be integers starting from 0 and incrementing sequentially, with each position index corresponding one-to-one with the knowledge fragment identifier. In the knowledge base hypergraph, each knowledge fragment node records the position index of the dense vector corresponding to the knowledge fragment in the dense vector index. This allows the corresponding dense vector to be quickly located and read when the multi-view hypergraph semantic diffusion aggregation algorithm is executed in the future, given the knowledge fragment node.
[0034] By combining a pre-trained semantic encoding model with a dense vector index, knowledge fragments of different lengths and representations can be mapped to a unified dense vector space. Knowledge fragments with similar semantics but significant literal differences can still be grouped together in the dense vector space, enhancing the recall capability of subsequent retrieval. On the other hand, storing all dense vectors centrally in the dense vector index facilitates access to existing near-nearest neighbor retrieval databases. When it is necessary to quickly search for dense vectors that are semantically close to the query based on multi-view query representations, only the dense vector index needs to be manipulated, without the need for extensive traversal on the knowledge base hypergraph, thereby effectively reducing retrieval latency.
[0035] In another optional implementation, for knowledge bases where document lengths are generally short, each document can be segmented into knowledge fragments according to the rule that the length of continuous text is between 100 and 300 characters. This increases the granularity of the knowledge fragments, making the content carried by each knowledge fragment node in the knowledge base hypergraph more concentrated and more suitable for precise matching of specific questions. In this optional implementation, when generating dense vectors for each knowledge fragment, a dense vector of length 768 is still used, but a pre-trained semantic encoding model more suitable for short text scenarios can be selected, thereby improving the semantic distinguishability between short texts with the same vector length.
[0036] refer to Figure 2 In this embodiment, the system uses a pre-trained semantic coding model to map each knowledge fragment into a dense vector of length 768. These dense vectors together constitute a 768-dimensional semantic vector space. Figure 2 The image uses a dimension reduction projection method to map the original 768-dimensional high-dimensional space onto a two-dimensional plane for visualization. The horizontal axis represents the first principal dimension d1 of the semantic space, and the vertical axis represents the second principal dimension d2. It should be noted that the actual semantic space is a complete 768-dimensional space. Figure 2 This is a two-dimensional projection illustration for ease of understanding only. In this semantic space, knowledge fragments with similar semantic content will naturally cluster in close proximity, forming semantic clusters. Figure 2Three typical semantic clusters are presented: Topic A, Topic B, and Topic C. Each solid black dot represents the position of a dense vector corresponding to a knowledge fragment in the two-dimensional projection space. Specifically, Topic A contains 5 knowledge fragment vectors, whose positions in the two-dimensional projection coordinate system are approximately (0.35, 0.25), (0.38, 0.27), (0.33, 0.29), (0.37, 0.31), and (0.34, 0.23), respectively. Their proximity in space indicates that these knowledge fragments are highly related in semantic content and may revolve around the same technical topic. Topic B contains 6 knowledge fragment vectors, distributed in the area around coordinates (0.65, 0.35), also exhibiting a tight clustering characteristic. Topic C contains 4 knowledge fragment vectors, located around coordinates (0.82, 0.55), relatively far from Topic A and Topic B, indicating that the knowledge fragments in this cluster differ significantly in semantic content from the other two clusters. Figure 2 The point Q marked with a hollow circle represents the query vector, which is the position of the dense vector obtained after encoding the user's natural language query through the same pre-trained semantic coding model in the two-dimensional projection space, approximately (0.45, 0.32). The position of this query vector Q in space is close to topic cluster A, indicating that the user query and the knowledge fragments in topic cluster A are semantically similar. To quantify the semantic similarity between the query vector and the knowledge fragment vector, the system uses cosine similarity as a metric. Cosine similarity measures the directional similarity between two vectors by calculating the cosine of the angle between them, with the formula cos(θ) = v1·vQ / (|v1||vQ|), where v1 represents the knowledge fragment vector, vQ represents the query vector, · represents the vector dot product, and |·| represents the magnitude of the vector. The value of cosine similarity ranges from 0 to 1; the closer the value is to 1, the closer the directions of the two vectors are, i.e., the more semantically similar they are.
[0037] Figure 2Two concentric circles centered on the query vector Q are drawn, representing similarity thresholds of 0.8 and 0.6, respectively. The radius of the inner solid circle corresponds to the cosine similarity threshold of 0.8. Knowledge fragment vectors falling within this circle have a cosine similarity of at least 0.8 with the query vector Q, indicating highly relevant knowledge fragments. The radius of the outer dashed circle corresponds to the cosine similarity threshold of 0.6. Knowledge fragment vectors falling within this circle but not within the inner circle have a cosine similarity between 0.6 and 0.8 with the query vector Q, indicating moderately relevant knowledge fragments. It can be observed that some knowledge fragment vectors in topic A fall within the circle with a similarity of 0.8, indicating a high match between these knowledge fragments and the query. Other vectors in topic A and some vectors in topic B fall within the annular region of 0.6 to 0.8, indicating some relevance but a slightly lower degree of match. Knowledge fragment vectors in topic C lie outside the circle with a similarity of 0.6, indicating a weaker semantic association with the query.
[0038] Figure 2 The geometric meaning of the vector representation is further illustrated by two arrows drawn from the origin (0.1, 0.8). The dashed arrow v1 points to a knowledge fragment vector within topic cluster A, while the bold solid arrow vQ points to the query vector Q. The angle between these two vectors is the angle θ used to calculate cosine similarity. This geometric representation allows for an intuitive understanding of the principle behind cosine similarity calculation: the closer the directions of two vectors are, the smaller the angle θ, and the closer cos(θ) is to 1, resulting in higher similarity; conversely, when the directions of two vectors differ significantly, the larger the angle θ, the smaller cos(θ), and the lower the similarity. In practical applications, after receiving a user query and generating the query vector vQ, the system retrieves all knowledge fragment vectors in the dense vector index whose cosine similarity to vQ exceeds a preset threshold (e.g., 0.6 or 0.8), thereby quickly locating knowledge fragments semantically relevant to the query. Since the dense vectors of all knowledge fragments are stored in a unified dense vector index, the system can use existing approximate nearest neighbor retrieval algorithms to complete similarity calculation and sorting in sublinear time complexity, significantly improving retrieval efficiency.
[0039] By mapping knowledge fragments to a dense vector space, even if different knowledge fragments differ significantly in their literal expression, as long as they are semantically similar, their corresponding dense vectors will be close to each other in the space, thus enabling them to be effectively recalled by the query vector. This semantic representation method based on dense vectors overcomes the dependence of traditional keyword matching methods on literal similarity, enhances the retrieval system's ability to recall semantically similar but differently expressed knowledge fragments, and improves the accuracy and robustness of retrieval.
[0040] Example 3: In one implementation, regarding step 2, after receiving the user's input of the original natural language query, the system first performs basic preprocessing on the original natural language query. Preprocessing may include removing leading and trailing spaces, unifying full-width and half-width punctuation, merging multiple consecutive spaces into one space, and selecting an appropriate word segmentation strategy based on the language detection results. For example, when the original natural language query is detected as Chinese, a dictionary- and statistical model-based Chinese word segmentation method is used to divide the original natural language query into several word sequences; when it is detected as English or a mixture of Chinese and English, corresponding word segmentation strategies are applied to different language segments. Through this preprocessing process, irrelevant differences caused by inconsistent input formats can be reduced, making the semantic, entity, and inference-perspective query texts generated by the subsequent natural language large model more stable and controllable, maintaining a relatively consistent output structure under different user input styles.
[0041] After preprocessing, the system inputs the original natural language query as a whole into the natural language processing (NLP) model, explicitly instructing it to output three query texts for different purposes: semantic, entity, and inference perspectives. Specifically, a fixed delimiter can be used in the input to separate the three query texts; for example, the NLP model can be required to output the semantic, entity, and inference perspectives sequentially, separated by specific delimiter phrases. When generating the semantic perspective query text, the NLP model retains the original question expression while appropriately standardizing obviously colloquial expressions, making the semantic perspective query text semantically equivalent to the original natural language query and syntactically more suitable for subsequent encoding and topic extraction. When generating entity-view query text, the Natural Language Model (NLP) retains only the entity names and key terms from the original natural language query, such as product names, protocol names, algorithm names, and standard numbers. This can be achieved by specifying a comma-separated list of entities and terms in the NLP output, reducing irrelevant functional words. This keeps the entity-view query text typically between 10 and 50 characters in length, facilitating the entity recognition component's focused processing of these high-value terms. When generating inference-view query text, the NLP explicitly adds a description of the inference purpose to the original natural language query. This includes additions such as "comparing the advantages and disadvantages of different solutions," "analyzing the causes of the failure," and "inferring future trends," making the inference-view query text more focused on the intent of the problem and the expected direction of reasoning. This inference-view query text is typically between 50 and 150 characters in length.
[0042] By splitting the raw natural language query into semantic, entity, and inference perspectives, the system can perform subsequent processing on the overall semantics, key entities, and inference intent separately. The advantage of this approach is that different types of information are suited to different processing methods: overall semantics are suitable for topic extraction and dense vector encoding; key entities are suitable for precise matching in the knowledge base hypergraph; and inference intent information is better suited for guiding path selection and interpretative ranking of candidate knowledge fragments in subsequent multi-perspective hypergraph semantic diffusion aggregation algorithms. If only the raw natural language query is used without multi-perspective splitting, various information are mixed together, entity recognition is easily affected by word order and tone, and inference intent is not easily utilized by downstream steps. Multi-perspective query representation explicitly separates these components with different functions, reducing mutual interference between different processing flows.
[0043] After obtaining the entity-view query text, the system calls the entity recognition component to process the query text and obtain a target entity identifier set. The entity recognition component can operate by combining a fine-tuned entity recognition model based on a large natural language model with a manually maintained entity dictionary. First, the entity recognition model performs sequence labeling on the entity-view query text, identifying suspected entity fragments and term fragments. Then, these fragments are matched against standardized entity names in the entity dictionary. Matching can employ a combination of exact and fuzzy matching, allowing for minor character differences or abbreviations, and each successfully matched entity fragment is associated with a globally unique entity identifier. For new entities appearing in the entity-view query text but not yet registered in the entity dictionary, the system can temporarily record them as entities awaiting review and add them to the entity dictionary after manual confirmation. In normal scenarios, for an entity-view query text containing 2 to 5 key terms, the entity recognition component can identify 1 to 3 entity identifiers and group these identifiers into a target entity identifier set. In this way, the target entity identifier set centrally represents the key objects mentioned in the original natural language query, facilitating rapid location of relevant nodes in the knowledge base hypergraph.
[0044] In parallel with entity recognition, the system calls a topic extraction component to process the semantic query text, obtaining a set of target topic tags. The topic extraction component can determine target topic tags by combining keyword extraction, text classification, and natural language processing (NLP) model generation. First, the system performs keyword statistics on the semantic query text, selecting several candidate words with high frequency that do not overlap with the stop word list. Then, the semantic query text is input into a pre-trained topic classification model to obtain several topic category probability distributions, from which the topic category with the highest score is selected. Finally, the aforementioned candidate keywords and topic category descriptions are input into the NLP model, requesting the NLP model to output 1 to 3 concise topic tag texts based on this information. For example, a semantic query text about "performance comparison of distributed consensus protocols" might yield candidate words such as "distributed," "consistency," "protocol," and "performance" through keyword statistics, categories such as "distributed system" and "transaction processing" through the topic classification model, and topic tags such as "distributed consensus protocol" and "transaction consistency" through the NLP model. After obtaining the topic tag text, the system matches it against the list of registered topic tags in the knowledge base, using a combination of exact and fuzzy matching methods similar to entity matching, and obtains the target topic tag set. The target topic tag set typically contains 1 to 3 topic tags that can summarize the technical field and question category of the original natural language query.
[0045] After obtaining the target entity identifier set and the target topic tag set, the system matches the original natural language query and its multi-perspective query text in the knowledge base hypergraph to obtain the starting node set. Specifically, the system first locates the entity identifier nodes corresponding to the target entity identifier set and the topic tag nodes corresponding to the target topic tag set in the knowledge base hypergraph. For each entity identifier node, the system reads all relevant hyperedges from the list of hyperedges associated with that entity identifier node, and finds all knowledge fragment nodes in the list of nodes associated with these hyperedges, using these knowledge fragment nodes as candidates for knowledge fragment nodes directly related to that entity. Similarly, for each topic tag node, the system reads all relevant hyperedges from the list of hyperedges associated with that topic tag node, and extracts knowledge fragment nodes from the list of nodes associated with the relevant hyperedges, using them as candidates for knowledge fragment nodes directly related to that topic. Since each entity identifier node and topic tag node may be associated with a large number of knowledge fragment nodes, the system can limit the number of candidates when constructing the starting node set. For example, for each entity identifier node, only the top 20 most recently updated knowledge fragment nodes are selected, and for each topic tag node, only the top 50 knowledge fragment nodes that are frequently associated with that topic tag are selected. In this way, we can avoid the problem of an excessively large starting node set leading to a sharp increase in subsequent diffusion computation, while preserving core knowledge fragments that are highly relevant to the original natural language query.
[0046] After constructing the initial node set, the system uses a pre-trained semantic encoding model consistent with the knowledge representation structure construction step to encode semantic view query text, entity view query text, and reasoning view query text, respectively, obtaining semantic view dense vector representation, entity view dense vector representation, and reasoning view dense vector representation. To maintain comparability with the dense vectors of knowledge fragments, the same vector length as the knowledge fragments is used during encoding, for example, a dense vector of length 768. Since semantic view query text is typically between 50 and 200 characters long, entity view query text is typically between 10 and 50 characters long, and reasoning view query text is typically between 50 and 150 characters long, the pre-trained semantic encoding model maps inputs of different lengths to a semantic vector space of uniform length. This allows for direct comparison between these three dense vector representations and the dense vectors of knowledge fragments when calculating similarity or performing multi-view fusion. Semantic perspective dense vector representation focuses more on overall semantic matching, entity perspective dense vector representation emphasizes the semantic neighborhood corresponding to key entities, and reasoning perspective dense vector representation highlights semantic information related to question intent and reasoning direction. Together, these three constitute a multi-perspective query representation, which, along with the starting node set, provides a comprehensive description of the starting position and query semantics for subsequent multi-perspective hypergraph semantic diffusion aggregation algorithms.
[0047] In one alternative implementation, when the entity-view query text is short and the target entity identifier set output by the entity recognition component is empty, the system can directly use the semantic-view query text as supplementary input to call the entity recognition component again, to compensate for situations where standard terms are not explicitly used in the user input. In this case, the entity recognition component can identify some implicit entities from the semantic-view query text, such as abbreviations or specification names of common protocols, thereby generating a non-empty target entity identifier set, avoiding an overly broad diffusion direction caused by the starting node set relying solely on the target topic tag set.
[0048] Example 4: In one implementation, when performing a multi-view hypergraph semantic diffusion aggregation algorithm on a knowledge base hypergraph based on a set of starting nodes and a multi-view query representation, the system first initializes the diffusion-related data structures in memory. After completing step 2, the system has obtained the set of starting nodes and the multi-view query representation. At this point, the system puts all knowledge fragment nodes in the set of starting nodes into the set of active nodes, sets the diffusion layer count to 1, sets the maximum diffusion layer to 3, and initializes the candidate node set to an empty set. The reason for this setting is that knowledge base hypergraphs are usually large in scale. If the diffusion layer is not limited, the diffusion range will grow exponentially, resulting in very high computational overhead and introducing a large number of remote nodes that are weakly related to the original natural language query. Fixing the maximum diffusion layer to 3 can cover one to three rings of nodes that are structurally close to the set of starting nodes, which is generally sufficient to include knowledge fragments closely related to the original natural language query, while achieving a balance between diffusion range and computational cost.
[0049] In one implementation, Figure 1 This demonstrates the generation structure and encoding process of multi-view query representations. For example... Figure 1 As shown, when the system receives the user's raw natural language query "How to compare the performance of different distributed consensus protocols?", it first performs preprocessing operations on the raw natural language query. These preprocessing operations include removing leading and trailing spaces, standardizing punctuation, and selecting the appropriate word segmentation strategy based on the language type. After preprocessing, the system inputs the processed raw natural language query into the natural language processing model. The natural language processing model, based on a pre-configured instruction template, simultaneously generates three query texts for different purposes. Specifically, in... Figure 1 In the left branch, the natural language large model generates a semantic-perspective query text, "Compare the performance differences of distributed consensus protocols." This text is 85 characters long and its purpose is to preserve the overall semantic expression of the original question while standardizing the colloquial expression to make it more suitable for subsequent topic extraction and semantic encoding operations. Figure 1In the intermediate branch, the natural language large model generates the entity-perspective query text "distributed consistency, protocol, performance". This text is 28 characters long and only retains the key entity names and technical terms from the original natural language query, presented in comma-separated form, facilitating centralized processing of these high-value terms by the entity recognition component. Figure 1 In the right-hand branch, the natural language large model generates a query text from a reasoning perspective: "Compare the advantages, disadvantages, and performance metrics of different distributed protocols." This text is 112 characters long and explicitly adds a description of the reasoning purpose to the original query, highlighting reasoning-oriented information such as "comparing advantages and disadvantages" and "performance metrics." Subsequently, as... Figure 1 As shown in the second half, the system calls the pre-trained semantic encoding model, consistent with the steps in constructing the knowledge representation structure, to encode the three query texts mentioned above. For the semantic view query text, the encoded result is a 768-dimensional semantic view dense vector representation; for the entity view query text, the encoded result is a 768-dimensional entity view dense vector representation; and for the reasoning view query text, the encoded result is a 768-dimensional reasoning view dense vector representation. Although these three dense vectors have the same length, due to the different focuses of the input texts, the semantic view dense vector emphasizes overall semantic matching, the entity view dense vector emphasizes the semantic neighborhood corresponding to key entities, and the reasoning view dense vector highlights semantic information related to the question intent and reasoning direction.
[0050] During the diffusion process, under the condition that the number of diffusion layers is no greater than 3 and the current diffusion layer can discover new nodes, for each knowledge fragment node in the set of activated nodes, the system sequentially reads the list of hyperedges associated with that knowledge fragment node in the knowledge base hypergraph. For each hyperedge, the system sequentially retrieves other knowledge fragment nodes (excluding the current knowledge fragment node) from the node list of that hyperedge and treats these knowledge fragment nodes as new node candidates. The system maintains an access flag for each knowledge fragment node. If a knowledge fragment node has already been processed in a previous diffusion layer, the node is skipped to avoid duplicate calculations. At the same time, the system maintains a counter in the current diffusion layer to count the number of new node candidates. When the number of new node candidates obtained in the current diffusion layer reaches 50, the system stops introducing new node candidates in the current diffusion layer and directly proceeds to calculate the similarity and structural association of the new node candidates in this layer. By setting an upper limit of 50 new node candidates in each diffusion layer, the growth of the search space caused by diffusion can be controlled, enabling the multi-view hypergraph semantic diffusion aggregation algorithm to run stably in large-scale knowledge base hypergraphs. Each layer introduces a maximum of 50 new node candidates. With a maximum diffusion layer of 3, the total number of new node candidates participating in subsequent calculations is roughly controlled within the range of hundreds to thousands, which is more conducive to subsequent sorting and summary generation.
[0051] For each new node candidate obtained in the initialization and diffusion sub-steps, the system further calculates the multi-view similarity level. Specifically, firstly, by using the record of the new node candidate in the knowledge base hypergraph, the dense vector of the knowledge fragment corresponding to the new node candidate is located in the dense vector index. Since a dense vector of length 768 has already been generated for each knowledge fragment in step 1 and the corresponding index position has been recorded, the system can directly find the corresponding dense vector position based on the node identifier of the new node candidate, thereby quickly reading the dense vector. Subsequently, the system inputs the dense vector, along with the semantic view dense vector representation, the entity view dense vector representation, and the reasoning view dense vector representation, into the cosine similarity calculation function provided by the vector retrieval library, respectively, to obtain three similarity values between 0 and 1. The closer the cosine similarity value is to 1, the more similar the corresponding knowledge fragment is to the original natural language query from that perspective; the closer the similarity value is to 0, the higher the semantic deviation between the two.
[0052] To facilitate subsequent filtering and sorting in the multi-view hypergraph semantic diffusion aggregation algorithm, the system discretizes the three similarity values into corresponding similarity levels. Specifically, when the semantic view similarity is not less than 0.8, the semantic view level is set to 3; when the semantic view similarity is above 0.6 and less than 0.8, the semantic view level is set to 2; and when the semantic view similarity is less than 0.6, the semantic view level is set to 1. The entity view similarity and reasoning view similarity adopt the same grading rule, mapping the corresponding similarity values to one of the semantic view level, entity view level, or reasoning view level, respectively. Using a grading approach instead of directly using continuous similarity values helps reduce the instability caused by small numerical differences during multi-round diffusion and multi-node comparisons, making the filtering and sorting rules easier to implement by making logical judgments based on a small number of discrete levels. In practical use, using 0.8 as the high similarity threshold ensures that semantically highly similar knowledge fragments are classified into level 3, while using 0.6 as the medium similarity threshold can cover knowledge fragments that have slightly different expressions but are still significantly relevant to the query.
[0053] After obtaining the semantic, entity, and reasoning perspective levels, the system needs to generate a structural association level based on the connectivity between new node candidates and the starting node set in the knowledge base hypergraph. To this end, the system calculates the shortest path length for each new node candidate in the knowledge base hypergraph, finding the shortest path length between the new node candidate and any knowledge fragment node in the starting node set. Simultaneously, the system counts the number of shared hyperedges between the new node candidate and the selected knowledge fragment node. Based on the shortest path length and the number of shared hyperedges, the system divides the structural association level into three levels. When the shortest path length between a new node candidate and a knowledge fragment node in the starting node set is 1, and the new node candidate shares at least two hyperedges with that knowledge fragment node, the structural association level is set to 3. This indicates that the new node candidate is highly and tightly connected to the starting node set in the knowledge base hypergraph, often appearing on the same topic and surrounding multiple identical entity contexts, representing a very direct content association. When the shortest path length is 1 and shares one hyperedge, or when the shortest path length is 2, the structural association level is set to 2. These nodes are still structurally close to the starting node set, but the association level is slightly lower than level 3. When the above conditions are not met, the structural association level is set to 1, indicating that the new node candidate is only indirectly connected to the starting node set on a more distant path, or that the hyperedge overlap is very small, and the structural association with the original natural language query is weak. By combining the shortest path length and the number of shared hyperedges, the system can simultaneously consider connection distance and the number of common contexts, thus more accurately reflecting the tightness of knowledge fragments in the hypergraph structure.
[0054] After obtaining the semantic perspective level, entity perspective level, reasoning perspective level, and structural association level, the system filters and groups new node candidates. First, when a new node candidate has a semantic perspective level of 2 or higher, an entity perspective level of 1 or higher, and a reasoning perspective level of 1 or higher, the system adds the new node candidate to the candidate node set, while simultaneously recording its semantic perspective level, entity perspective level, reasoning perspective level, and structural association level. This condition ensures that the new node candidate has moderate or higher relevance in overall semantics, and also has some association in both entity and reasoning perspectives, which is beneficial for providing content support during subsequent answer generation. Second, when a new node candidate has an entity perspective level of 2 or higher and a structural association level of 2 or higher, the system adds the new node candidate to both the candidate node set and the temporary set of activation nodes for the next layer. These new node candidates are particularly strong in entity matching and are structurally similar to the starting node set, making them suitable as the starting point for the next layer of diffusion, exploring more adjacent knowledge fragments along entity-related paths. Furthermore, when a new node candidate has a semantic perspective level of no less than 2 and a structural association level of no less than 2, the system adds the new node candidate to the temporary set of activated nodes in the next layer. These new node candidates exhibit good performance in overall semantics and structural connectivity, and even if their entity perspective level is low, they can still serve as the starting point for subsequent diffusion, expanding the search scope centered on semantic neighbors. Through the above combination of conditions, the system distinguishes between the candidate node set and the temporary set of activated nodes in the next layer: the candidate node set is responsible for accumulating knowledge fragments suitable as the basis for answers, while the temporary set of activated nodes in the next layer focuses on key nodes that guide the diffusion direction, thus enabling the multi-perspective hypergraph semantic diffusion aggregation algorithm to balance retrieval depth and result quality.
[0055] After completing the filtering and grouping of the current diffusion layer, the system replaces the temporary set of active nodes for the next layer with a new set of active nodes and increments the diffusion layer count by 1. The diffusion process stops when the new set of active nodes is empty or when the diffusion layer count is greater than 3. This means that the multi-view hypergraph semantic diffusion aggregation algorithm has exhaustively searched for knowledge fragment nodes with strong structural associations to the starting node set within the specified structural radius. Subsequently, the system sorts the candidate node set accumulated during the diffusion process. Specifically, the system first sorts them from high to low semantic view level. When multiple knowledge fragment nodes have the same semantic view level, they are sorted from high to low inference view level. If the inference view level is still the same, they are sorted from high to low entity view level. When all three levels are the same, they are sorted from high to low structural association level. When all four levels are the same, they are finally sorted from high to low semantic view similarity values. Through this sorting rule, the system prioritizes knowledge fragments that highly match the overall semantics of the original natural language query and meet the inference requirements. Secondly, it considers the degree of entity matching and structural tightness. Finally, when the levels are completely identical, it uses continuous similarity values for fine-tuning. Based on the sorting results, the system sequentially extracts the top 100 knowledge fragment nodes and constructs a candidate knowledge fragment set with their corresponding knowledge fragments. Limiting the candidate knowledge fragment set to less than 100 ensures coverage of the main relevant content while avoiding excessively long inputs in the subsequent multi-view local semantic summarization generation stage.
[0056] In one implementation, Figure 3 This demonstrates the complete process of performing a multi-view hypergraph semantic diffusion aggregation algorithm on a knowledge base hypergraph based on a set of starting nodes and a multi-view query representation. For example... Figure 3 As shown, the algorithm employs a layer-by-layer diffusion approach, performing a maximum of three layers of diffusion. During each layer, newly discovered nodes undergo multi-view similarity calculation and ranking evaluation, and the algorithm determines whether to add them to the candidate node set or the next layer's active node set based on selection criteria. Specifically, in layer 0, the initial stage, the system has already obtained the initial node set through the matching operation in step 2. For example... Figure 3 As shown at the top, the starting node set contains one topic tag node T1, one entity identifier node E1, and three knowledge fragment nodes F1, F2, and F3, for a total of five nodes. These nodes are the initial anchor points directly related to the original natural language query. The topic tag node T1 and the entity identifier node E1 are obtained by matching the target topic tag set and the target entity identifier set. The knowledge fragment nodes F1, F2, and F3 are directly related knowledge fragments found from these topic tag nodes and entity identifier nodes through hyperedge associations. The system places the three knowledge fragment nodes F1, F2, and F3 from the starting node set into the activated node set as the starting point for the first layer of diffusion.
[0057] In the first layer diffusion stage, such as Figure 3 As shown in the "Layer 1: Activation Node Diffusion" section, the system starts from each knowledge fragment node in the activation node set, reads the list of hyperedges associated with it in the knowledge base hypergraph, and extracts other knowledge fragment nodes as new node candidates from the node lists of these hyperedges. In this example, Layer 1 diffusion discovered 6 new node candidates: F4, F5, F6, F7, F8, and F9. For each new node candidate, the system calculates its cosine similarity with the three dense vectors in the multi-view query representation, and discretizes the similarity value into semantic view level, entity view level, and reasoning view level. Simultaneously, it calculates the structural association level based on the shortest path length and the number of shared hyperedges between the new node candidate and the starting node set. For example, node F4 has four levels: (3, 2, 2, 3), representing a semantic view level of 3, an entity view level of 2, a reasoning view level of 2, and a structural association level of 3. The system groups these new node candidates according to preset filtering criteria: nodes that meet the criteria of "semantic level ≥ 2, entity level ≥ 1, and reasoning level ≥ 1" are added to the candidate node set; nodes that meet the criteria of "entity level ≥ 2 and structural level ≥ 2" or "semantic level ≥ 2 and structural level ≥ 2" are added to the next-level temporary set of activated nodes. Figure 3 The annotation "Add 50 new nodes" indicates that the first-layer diffusion introduces a maximum of 50 new node candidates within the quantity limit. In the second-layer diffusion stage, as... Figure 3 As shown in the "Layer 2: Continued Diffusion" section, the system uses the temporary set of activated nodes obtained after the first layer of diffusion as the new set of activated nodes, and continues to diffuse in the knowledge base hypergraph from these nodes. The second layer of diffusion discovered new node candidates, including F10, F11, and F12, etc. Figure 3 The ellipsis "..." indicates intermediate nodes, eventually reaching nodes F58, F59, etc. The system performs the same multi-view similarity calculation, ranking evaluation, and filtering / grouping operations on these new node candidates as in Layer 1. In this example, Layer 2 diffusion adds 47 new node candidates. These nodes are structurally 2 hops from the starting node set, indirectly associated with the starting node set through the intermediate nodes obtained in Layer 1 diffusion. In the Layer 3 diffusion stage, as... Figure 3As shown in the "Layer 3: Final Diffusion" section, the system continues to diffuse from the set of activated nodes obtained in Layer 2, discovering new node candidates including F60 and F61, and finally reaching nodes such as F92. Layer 3 diffusion adds 33 new node candidates. Since the system's preset maximum diffusion layer is 3, after completing Layer 3 diffusion, the system stops diffusing, and even if the next layer's set of activated nodes is not empty, a fourth layer of diffusion is not performed. This is because as the number of diffusion layers increases, the correlation between newly discovered nodes and the original natural language query gradually weakens, while the diffusion range grows exponentially. Continuing to diffuse brings limited benefits but a sharp increase in computational overhead. After completing 3 layers of diffusion, as... Figure 3 As shown at the bottom, the system aggregates all candidate nodes accumulated during the diffusion process into a candidate node set, which contains a total of 130 candidate nodes. These 130 nodes come from 50 nodes in layer 1, 47 nodes in layer 2, and 33 newly added nodes in layer 3. Subsequently, the system performs a sorting operation on the candidate node set, ranking them from highest to lowest priority according to semantic perspective level, reasoning perspective level, entity perspective level, and structural association level. The top 100 knowledge fragment nodes are selected from the sorting results, and their corresponding knowledge fragments constitute the final candidate knowledge fragment set for the next step of multi-perspective fusion sorting and answer generation. Figure 3 The right side indicates the number of newly added nodes at each layer, visually demonstrating the dynamic changes in node discovery during the diffusion process. Meanwhile, Figure 3 The statistical description at the bottom further clarifies the key parameters of the entire diffusion process: the starting node contains 5 nodes in total, including 3 knowledge fragment nodes, 1 topic tag node, and 1 entity identifier node; the maximum number of diffusion layers is set to 3; the maximum number of new nodes per layer is 50; and the final total number of candidate nodes is 130. Through this controlled, layer-by-layer diffusion mechanism, the system can effectively control computational complexity while ensuring retrieval coverage, achieving efficient knowledge fragment retrieval.
[0058] In one optional implementation, when calculating the multi-view similarity level, the system can adjust the medium similarity threshold from 0.6 to 0.7 while keeping the high similarity threshold of level 3 unchanged at 0.8. This allows for the classification of knowledge fragments with similarity greater than 0.7 into the medium-high level only in scenarios with higher accuracy requirements, while uniformly classifying knowledge fragments with similarity between 0.5 and 0.7 into level 1, thus enhancing the overall relevance of the candidate knowledge fragment set. In another optional implementation, when the size of the candidate node set is small, such as less than 30, the system can avoid forcibly truncating to 100 during sorting, and instead directly include all candidate nodes into the candidate knowledge fragment set to avoid omitting a few knowledge fragments with high structural correlation levels. These optional implementations are all adjustments based on the aforementioned multi-view hypergraph semantic diffusion aggregation algorithm, and those skilled in the art can implement them directly without changing the overall process according to specific business needs.
[0059] Example 5: In one implementation, after determining the candidate knowledge fragment set and the corresponding multi-view local semantic summary, the system first constructs structured input data for use by the large natural language model around the candidate knowledge fragment set. Specifically, for each knowledge fragment node in the candidate knowledge fragment set, the system reads the corresponding knowledge fragment text, the multi-view local semantic summary generated in the previous steps, and the sorting position of the knowledge fragment node in the candidate knowledge fragment set, and organizes these three into a record. Each record can explicitly indicate three fields: "candidate number," "knowledge fragment text," and "multi-view local semantic summary," where the candidate number directly uses the rank value obtained in step 3, for example, from 1 to 100. Subsequently, no more than 20 records are selected from the candidate knowledge fragment set according to the sorting result, usually the top 20 records, and these records are arranged in ascending order of candidate number and merged into structured input. Limiting the number of candidate knowledge fragments in a single structured input to no more than 20 can, on the one hand, control the input length of the natural language processing model and avoid excessively long inputs that lead to distraction and decreased inference quality. On the other hand, it can also ensure that the natural language processing model can perform a relatively thorough comparison and scoring of each candidate knowledge fragment in one processing cycle, which is conducive to obtaining stable multi-view relevance scores.
[0060] After constructing the structured input, the system inputs this structured input along with the original natural language query into the natural language processing model. During input, each record can be embedded in the structured input according to a fixed format, such as first providing the candidate number, then the corresponding knowledge fragment text, and finally attaching a multi-perspective local semantic summary, with clear delimiters separating each record. Simultaneously, explanatory text is added to the input, explicitly requiring the natural language processing model to output semantic relevance scores, entity relevance scores, and inference relevance scores for each record, with the scores limited to integers between 1 and 5. Limiting the scores to 1 to 5 is twofold: firstly, a 5-level scoring system is common in both human review and machine processing scenarios, making it easy to understand and compare; secondly, the 5 discrete levels provide sufficient differentiation without causing the natural language processing model to hesitate excessively when selecting specific scores due to too many levels, thus improving the stability and reproducibility of the scoring.
[0061] After receiving structured input and the original natural language query, the Natural Language Model (NLM) simultaneously reads the original natural language query, the text of each knowledge fragment, and its accompanying multi-perspective local semantic summary. Regarding semantic relevance scoring, the NLM focuses on comparing the degree to which the knowledge fragment text and its multi-perspective local semantic summary cover the overall semantics of the question. For example, does it directly answer the question in the original natural language query? Does it involve the same technical scenario or business background? When the knowledge fragment text basically covers the key points of the original natural language query, it tends to give a score of 4 or 5; when it only involves some background or related concepts, it may give a score of 2 or 3; when the relevance is weak, it gives a score of 1. Regarding entity relevance scoring, the NLM focuses on the description of entities in the multi-perspective local semantic summary, comparing whether the entities appearing in it are consistent with the target entity identifier set in the original natural language query, or whether there are synonymous entities or hierarchical entities. When candidate knowledge fragments revolve around the same product name, protocol name, or standard number, the entity relevance score will be higher. The reasoning perspective relevance score focuses more on the role of the knowledge fragment in the reasoning chain, such as whether it provides key steps, comparison conditions, causes of failure, or explanations of conclusions. When a knowledge fragment can directly support inferences such as "why is this so" or "how to choose a solution", the reasoning perspective relevance score tends to give a higher value.
[0062] To ensure that the scores output by the natural language processing model conform to the integer requirement of 1 to 5, the system can provide scoring examples in the input instructions, clearly indicating the range of integer values corresponding to different relevance levels. For example, "a score of 1 for completely irrelevant, a score of 2 or 3 for partially relevant, and a score of 4 or 5 for highly relevant." The system also requires the natural language processing model to return the three scores corresponding to each candidate number in list or tabular form. After receiving the output from the natural language processing model, the system parses the output content and establishes a correspondence between the semantic relevance score, entity relevance score, and inference relevance score of each record and the original candidate number. When a score value is detected to be outside the range of 1 to 5, or when a missing value exists, a simple correction process can be triggered. For example, values outside the range can be truncated to the boundary value, or missing values can be set to 1, to ensure that the subsequent fusion and ranking calculation process always runs within the defined score range.
[0063] After obtaining the complete multi-perspective relevance scores, the system performs multi-perspective fusion sorting on the candidate knowledge fragment set. Specifically, the system first sorts the candidate knowledge fragments from high to low according to their semantic relevance scores, placing the knowledge fragments with higher semantic relevance scores first to ensure that the final selected set of target knowledge fragments can preferentially cover the content that best matches the overall semantics of the original natural language query. When multiple candidate knowledge fragments have the same semantic relevance score, the system then sorts them from high to low according to their reasoning relevance scores, placing the knowledge fragments that are more helpful in supporting the inference process, providing reasons, or comparing different solutions in a higher position, thus improving the quality of the final retrieval answer in terms of logical chain and explanatoryness. If the reasoning relevance scores are still the same, the system sorts them from high to low according to their entity relevance scores, placing the knowledge fragments more closely related to the key entities first to ensure that the answer does not deviate from the object that the user is truly concerned about. When the above three relevance scores are completely the same, the system then sorts them from front to back according to the original sorting in the candidate knowledge fragment set, maintaining the priority already established in the multi-perspective hypergraph semantic diffusion aggregation algorithm in step 3. This hierarchical ranking rule can establish a clear priority order among different perspectives, ensuring that the overall semantic matching and reasoning value take precedence over other factors, while also taking into account the prior ranking generated by entity matching and structural diffusion.
[0064] After fusion and ranking, the system selects the top 5 knowledge fragments from the ranking results and forms a target knowledge fragment set from these 5 corresponding knowledge fragment nodes. Limiting the size of the target knowledge fragment set to 5 fragments ensures that the natural language processing model can fully utilize each fragment when generating search answers, preventing the answer content from becoming scattered and unclear in its priorities due to an excessive number of fragments. It also reduces the input length during answer generation, allowing the natural language processing model to focus more intently on content directly related to the answer. In practical applications, it has been verified that in most technical question-answering and knowledge retrieval scenarios, the top 5 highly relevant knowledge fragments are sufficient to cover the main arguments and key steps, and further expanding the number of target knowledge fragments offers limited benefits.
[0065] After obtaining the set of target knowledge fragments, the system reads the knowledge fragment text and multi-perspective local semantic summary corresponding to each target knowledge fragment node from the knowledge base hypergraph. Simultaneously, it reads the knowledge fragment nodes directly connected to each target knowledge fragment node from the knowledge base hypergraph, using the knowledge fragment text of these connected nodes as supplementary context. These directly connected knowledge fragments typically share common entity identifiers or topic tags with the target knowledge fragments, and can provide background information, supplementary conditions, or relevant definitions. The system organizes the above content into a new structured input in a certain order, where each target knowledge fragment can first be provided with its knowledge fragment text and multi-perspective local semantic summary, followed by the text of its connected knowledge fragments as "extended explanations." Subsequently, the system inputs this structured input along with the original natural language query into the natural language processing model, explicitly instructing the model to comprehensively consider semantic, entity, and reasoning perspectives, and generate a retrieval answer corresponding to the original natural language query based on the target knowledge fragment set and its connecting context.
[0066] When generating search results, the Natural Language Model (NLM) utilizes semantic perspective information to determine the scope of topics and question types that the answer should cover, such as whether it is an explanatory question, a step-by-step question, or a comparative question. It uses entity perspective information to ensure that the description in the answer closely relates to the product name, protocol name, or key terms that the user cares about, avoiding the introduction of irrelevant entities. It uses reasoning perspective information to organize the logical structure of the answer, for example, stating the preconditions first, then giving the conclusion, and finally supplementing the reasons or advantages and disadvantages. Because the target knowledge fragment set has already undergone multi-perspective fusion and sorting, its content is usually prioritized in terms of semantic matching, entity matching, and reasoning value. Based on this, the search results generated by the NLM can achieve a good balance between accuracy and interpretability.
[0067] The present invention has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the invention. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims
1. A knowledge base retrieval method integrating a large-scale natural language model, characterized in that: Includes the following steps: Step 1: Construct a knowledge representation structure, which includes a knowledge base hypergraph based on knowledge fragments, entity identifiers, and topic tags, as well as a dense vector index that records dense vectors of knowledge fragments; Step 2: Parse the user's original natural language query, generate a multi-perspective query representation, and obtain the starting node set by matching the original natural language query in the knowledge base hypergraph. The multi-perspective query representation includes a semantic perspective dense vector representation, an entity perspective dense vector representation, and a reasoning perspective dense vector representation. Step 3: On the knowledge base hypergraph, based on the set of starting nodes and the multi-view query representation, execute the multi-view hypergraph semantic diffusion aggregation algorithm to determine the set of candidate knowledge fragments and the corresponding multi-view local semantic summaries; The multi-view hypergraph semantic diffusion aggregation algorithm includes an initialization and diffusion sub-step; it also includes a sub-step for calculating the multi-view similarity level, specifically: for each new node candidate obtained in the initialization and diffusion sub-step, calculating the multi-view similarity level; it also includes a sub-step for calculating the structural association level, specifically: generating the structural association level based on the connection between the new node candidate and the starting node set in the knowledge base hypergraph; and it also includes a sub-step for filtering and grouping the new node candidates, specifically: when the semantic view level is not less than 2, the entity view level is not less than 1, and the reasoning view level is not less than 1, adding the new node candidate to the candidate node set, and simultaneously recording the new node. The process includes considering the semantic perspective level, entity perspective level, reasoning perspective level, and structural association level of candidates. When both the entity perspective level and structural association level are not less than 2, the new candidate node is simultaneously added to both the candidate node set and the temporary set of activated nodes for the next layer. The process also includes diffusion iteration and sorting sub-steps, specifically: replacing the activated node set with the temporary set of activated nodes obtained at the end of the current diffusion layer, incrementing the diffusion layer count by 1, and stopping diffusion when the activated node set is empty or the diffusion layer count is greater than 3. After diffusion, the candidate nodes are... All knowledge fragment nodes recorded in the point set are sorted according to the following rules: First, they are sorted from high to low semantic perspective level. When the semantic perspective levels are the same, they are sorted from high to low inference perspective level. When the inference perspective levels are still the same, they are sorted from high to low entity perspective level. When all three levels are the same, they are sorted from high to low structural association level. When all four levels are the same, they are sorted from high to low semantic perspective similarity value. The top 100 knowledge fragment nodes are selected according to the sorting results to form a candidate knowledge fragment set. The process also includes a sub-step of generating a multi-perspective local semantic summary, specifically including: for each knowledge fragment node in the candidate knowledge fragment set, from the knowledge... The system reads other knowledge fragment nodes that are directly connected to the knowledge fragment node through hyperedges in the hypergraph; it concatenates the knowledge fragment text corresponding to the knowledge fragment node with the knowledge fragment texts corresponding to up to 3 connected knowledge fragments to form local context text; it inputs the local context text along with the original natural language query into the natural language big model; it instructs the natural language big model to generate 3 local semantic descriptions, where the first description describes local content related to the semantic perspective, the second description describes local content related to the entity perspective, and the third description describes local content related to the reasoning perspective; and it stores the 3 local semantic descriptions as a multi-perspective local semantic summary associated with the corresponding knowledge fragment node. Step 4: Call the natural language processing model to perform multi-view fusion and sorting of the candidate knowledge fragment set to obtain the target knowledge fragment set, and generate the search answer based on the target knowledge fragment set.
2. The knowledge base retrieval method integrating a large natural language model as described in claim 1, characterized in that, Step 1 specifically includes: dividing each document in the knowledge base into multiple knowledge segments according to the rule that the continuous text length is between 200 and 500 characters, and generating a unique segment identifier for each knowledge segment; performing entity identifier extraction on each knowledge segment to obtain a set of entity identifiers containing proper nouns, term names, and abbreviations, and generating at least one topic tag for each knowledge segment based on the document's domain and chapter title; constructing a knowledge base hypergraph based on this, using knowledge segments, entity identifiers, and topic tags as hypergraph nodes, and using a set of nodes consisting of multiple knowledge segments under the same topic tag and at least one common entity identifier as a hyperedge; recording the list of nodes associated with each hyperedge and the list of hyperedges associated with each node in the form of an adjacency list; simultaneously, using a pre-trained semantic encoding model to generate a dense vector of length 768 for each knowledge segment, storing all dense vectors in a dense vector index; and recording the position index of the corresponding dense vector in the dense vector index for each knowledge segment node in the knowledge base hypergraph, thus obtaining a knowledge representation structure based on the knowledge base hypergraph and the dense vector index.
3. The knowledge base retrieval method integrating a large natural language model as described in claim 1, characterized in that, Step 2 specifically includes: receiving the user's original natural language query, inputting the original natural language query into the natural language processing model, and having the natural language processing model output three query texts for different purposes, namely, semantic view query text, entity view query text, and reasoning view query text; wherein the semantic view query text retains the original question statement, the entity view query text only retains entity names and key terms, and the reasoning view query text adds a description of the reasoning purpose; calling the entity recognition component to process the entity view query text to obtain a target entity identifier set, and simultaneously calling the topic extraction component to process the semantic view query text to obtain a target topic tag set; matching the target entity identifier set and the target topic tag set in the knowledge base hypergraph, and using the successfully matched entity identifier nodes, topic tag nodes, and knowledge fragment nodes directly connected to them through hyperedges as the starting node set; and using the pre-trained semantic encoding model consistent with the knowledge base hypergraph and dense vector index construction steps to encode the semantic view query text, entity view query text, and reasoning view query text respectively to obtain semantic view dense vector representation, entity view dense vector representation, and reasoning view dense vector representation, as multi-view query representations.
4. The knowledge base retrieval method integrating a large natural language model as described in claim 1, characterized in that, Step 3, the initialization and diffusion sub-step, specifically includes: initializing the activation node set by adding all knowledge fragment nodes from the starting node set to the activation node set, setting the diffusion layer count to 1, fixing the maximum diffusion layer to 3, and initializing the candidate node set to empty; under the condition that the diffusion layer count is no greater than 3 and new nodes are found in the current diffusion layer, for each knowledge fragment node in the activation node set, reading the list of hyperedges associated with the knowledge fragment node in the knowledge base hypergraph; for each hyperedge, sequentially taking other knowledge fragment nodes from the node list of the hyperedge as new node candidates, skipping the nodes that have already been processed, counting the number of new node candidates obtained in the current diffusion layer, and stopping the introduction of new node candidates when the number reaches 50.
5. The knowledge base retrieval method integrating a large natural language model as described in claim 4, characterized in that, In step 3, for each new node candidate obtained in the initialization and diffusion sub-steps, a multi-perspective similarity level is calculated, specifically as follows: First, the dense vector of the knowledge fragment corresponding to the new node candidate is located in the dense vector index using the records in the knowledge base hypergraph. The dense vector is then input into the cosine similarity calculation function provided in the vector retrieval library along with the dense vector representations of the semantic perspective, entity perspective, and reasoning perspective, respectively, to obtain three similarity values between 0 and 1. Second, semantic perspective level, entity perspective level, and reasoning perspective level are generated based on the three similarity values. The semantic perspective level is set to 3 when the semantic perspective similarity is not less than 0.8, set to 2 when the semantic perspective similarity is above 0.6 and less than 0.8, and set to 1 when the semantic perspective similarity is less than 0.
6. The entity perspective and reasoning perspective use the same grading rules, mapping the corresponding similarity values to levels 1 to 3.
6. The knowledge base retrieval method integrating a large natural language model as described in claim 5, characterized in that, Step 3: When the shortest path length between the new node candidate and any knowledge fragment node in the starting node set is 1 and the new node candidate and the knowledge fragment node share at least 2 superedges, set the structural association level to 3; when the shortest path length is 1 and they share 1 superedge or the shortest path length is 2, set the structural association level to 2; otherwise, set the structural association level to 1.
7. The knowledge base retrieval method integrating a large natural language model as described in claim 6, characterized in that, Step 4 specifically includes: organizing the knowledge fragment text, multi-view local semantic summary, and ranking position of each knowledge fragment node in the candidate knowledge fragment set into a structured input; inputting the structured input containing no more than 20 candidate knowledge fragment nodes into the natural language big data model along with the original natural language query; instructing the natural language big data model to provide semantic relevance scores, entity relevance scores, and inference relevance scores for each candidate knowledge fragment, with scores limited to integers between 1 and 5; fusing and ranking the candidate knowledge fragments according to the order of semantic relevance scores from high to low, inference relevance scores from high to low, entity relevance scores from high to low, and the original ranking in the candidate knowledge fragment set from front to back; selecting the top 5 knowledge fragments from the fusion ranking results as the target knowledge fragment set; inputting the knowledge fragment text corresponding to the target knowledge fragment set, the multi-view local semantic summary, and the knowledge fragment text directly connected to the target knowledge fragment set in the knowledge base hypergraph into the natural language big data model; and generating a retrieval answer corresponding to the original natural language query by the natural language big data model, taking into account the semantic, entity, and inference perspectives simultaneously.
Citation Information
Patent Citations
Construction method and device of knowledge base question-answering system, equipment and storage medium
CN119293164A
Natural Language Processing Utilizing Transaction Based Knowledge Representation
US20160098389A1