A knowledge graph-based global retrieval method, an electronic device, and a storage medium

By combining knowledge graph-based community segmentation with a large language model, the problem of inconsistent answers in traditional RAG systems for multi-topic or cross-domain questions is solved, achieving efficient, comprehensive, and reliable answer generation.

CN122240772APending Publication Date: 2026-06-19BEIJING YUCHEN SHIMEI SCI & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING YUCHEN SHIMEI SCI & TECH
Filing Date
2026-03-13
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional search-enhanced generation (RAG) systems, when dealing with macro-level questions involving multiple topics or cross-domain issues, lack holistic insight and logical coherence in generating answers. This results in fragmented information, incomplete topic coverage, and difficulty in supporting high-quality, interpretable global knowledge summarization and answer generation.

Method used

The knowledge graph-based global retrieval method divides the knowledge graph into several communities through a community detection algorithm, randomly rearranges and divides them into community combinations, uses a large language model to generate intermediate answers and performs relevance scoring, and finally splices them together to form a comprehensive context to generate the answer.

🎯Benefits of technology

It enables comprehensive and insightful answer generation for thematic information scattered in complex knowledge networks, improves the reliability and logical coherence of answer output, and overcomes the limitations of traditional methods in processing information in structurally dispersed and interconnected domains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240772A_ABST
    Figure CN122240772A_ABST
Patent Text Reader

Abstract

This invention relates to the field of intelligent retrieval technology, and in particular to a global retrieval method, electronic device, and storage medium based on a knowledge graph. The method includes: constructing a knowledge graph based on several original texts; dividing the knowledge graph into several communities; dividing the communities into several community combinations; obtaining the community combination description text corresponding to each community combination; inputting each community combination as a separate context into a preset large language model; generating intermediate answers and corresponding answer relevance scores for user queries based on each individual context; selecting several intermediate answers based on the answer relevance scores and concatenating them to form a comprehensive context; and inputting this comprehensive context into the preset large language model to generate the final answer for user queries. This invention is beneficial for achieving comprehensive and insightful answer generation for broad topic queries, while improving the reliability of answer output when processing domain information with dispersed structures and strong correlations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent retrieval technology, and in particular to a global retrieval method, electronic device and storage medium based on knowledge graph. Background Technology

[0002] With the rapid development of artificial intelligence technology, Retrieval-Augmented Generation (RAG) systems have been widely applied in the field of question answering. Traditional RAG techniques typically segment a document corpus into text blocks, then retrieve several semantically related text blocks based on vector similarity to form a context, which is then fed into a large language model to generate the answer. This method is highly effective in answering simple, explicit factual questions.

[0003] However, when dealing with macro or general questions involving multiple topics or even cross-domain issues, the search results often exhibit problems such as fragmented information, incomplete topic coverage, and lack of hierarchical structure. This results in generated answers that lack overall insight and logical coherence, making it difficult to support high-quality, interpretable global knowledge summarization and answer generation. Summary of the Invention

[0004] To address the aforementioned technical problems, this invention provides a global retrieval method, electronic device, and storage medium based on knowledge graphs. By decomposing, processing, and integrating the community structure of knowledge graphs, it can efficiently and comprehensively understand topic information scattered in complex knowledge networks. This facilitates the generation of comprehensive and insightful answers for broad topic queries, while also improving the reliability of answer output when processing domain information that is structurally dispersed and highly correlated.

[0005] According to a first aspect of the present invention, a global retrieval method based on a knowledge graph is provided, comprising the following steps: S1. A knowledge graph is constructed based on several original texts, and the knowledge graph is divided into several communities through a community detection algorithm; wherein, the nodes of the knowledge graph include entities and events extracted from several original texts, and the edges represent the relationships between entities and between entities and events.

[0006] S2, randomly rearrange the communities and divide them into several community combinations, and obtain the community combination description text corresponding to each community combination.

[0007] S3, based on the user query, inputs the description text of each community combination as a separate context into the preset large language model, so that the preset large language model can generate an intermediate answer for the user query based on each separate context, and generate an answer relevance score for each intermediate answer.

[0008] S4: Sort and filter all intermediate answers according to the answer relevance score corresponding to each intermediate answer. Combine the selected intermediate answers to form a comprehensive context. Input the comprehensive context into the preset large language model to generate the final answer for the user query.

[0009] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement the above-described knowledge graph-based global retrieval method.

[0010] According to a third aspect of the present invention, an electronic device is provided, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0011] The present invention has at least the following beneficial effects: This invention provides a global retrieval method based on knowledge graphs. First, a knowledge graph is constructed based on several original texts and divided into several communities. Through knowledge graph construction and community division, fragmented information from different entities and relationships can be integrated, improving the rapid understanding of structurally dispersed information. Then, the communities are randomly rearranged and divided into several community combinations, and the descriptive text corresponding to each community combination is obtained. This expands the micro-level entity relationship network to a meso-level topic semantic summary, enabling the system to efficiently and comprehensively understand topic information scattered in complex knowledge networks, facilitating the generation of comprehensive and insightful answers for broad topic queries. Finally, the descriptive texts of each community combination are further processed... As individual contexts, these are input into a pre-defined large language model, which generates intermediate answers and corresponding answer relevance scores for each individual context. Several intermediate answers are selected based on the answer relevance scores and concatenated to form a comprehensive context, which is then input into the pre-defined large language model to generate the final answer for the user query. By concatenating several intermediate answers, the large language model can integrate multi-perspective and fragmented intermediate answers to generate a coherent, comprehensive, and generalized answer that covers multiple topics involved in the query. This completes the transformation from distributed information retrieval to high-quality knowledge extraction, overcoming the limitations of traditional retrieval enhancement generation techniques in handling structurally dispersed and complexly related domain information. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 A flowchart of a knowledge graph-based global retrieval method provided in an embodiment of the present invention. Detailed Implementation

[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0015] This invention provides a global retrieval method based on knowledge graphs, such as... Figure 1 As shown, the method includes the following steps: S1. A knowledge graph is constructed based on several original texts, and the knowledge graph is divided into several communities through a community detection algorithm. The nodes of the knowledge graph include entities and events extracted from several original texts, and the edges represent the relationships between entities and between entities and events. It can be understood that the original texts refer to the real texts published in the target domain, such as news texts published by mainstream media and social media.

[0016] The preferred community detection algorithm is the Leiden community detection algorithm.

[0017] Specifically, the knowledge graph is constructed through the following steps: S10 extracts entities, events, and relationships from several original texts to construct an initial graph.

[0018] Specifically, a sequence labeling method based on a pre-trained language model is used to identify entities in the original text. Within the pre-trained language model, a fine-grained entity type system is defined to suit the characteristics of news data. For example, "organization" is further subdivided into "public welfare organizations," "enterprises," and "media," to support more accurate subsequent relationship and event analysis.

[0019] After entity extraction, ambiguity is resolved for different entities, and they are associated with unique, normalized entity IDs within their context, employing a two-stage process of recall and ranking. In the recall stage, an entity alias dictionary built using Elasticsearch is used for rapid initial screening, obtaining a set of candidate entities based on surface string matching of entity names. In the ranking stage, a self-trained Zero-shot dual-tower vector model is used for precise matching. This model consists of a query tower encoding textual references and their context, and an entity tower encoding entity descriptions from a knowledge base. By calculating the similarity between the two vectors, the most relevant entity is selected from the candidate entities. The advantage of this method is that it does not require training data for specific link samples; it can achieve high-precision linking solely based on the entity's descriptive text, making it ideal for scenarios where new entities emerge frequently.

[0020] When extracting events, a sequence-to-sequence generation framework based on pre-trained language models, such as UIE and T5, is used. This model can generate structured event records end-to-end, including event type, trigger words, and elements such as time, location, participants, and reasons. This approach avoids the error accumulation defects of traditional pipeline methods and significantly improves extraction accuracy.

[0021] When extracting relations, a relation classification method based on a pre-trained language model is adopted. Entity pairs in the sentence and their context are input into the model, which then determines whether a predefined relation exists between the two entities and gives the specific relation type. In order to capture implicit, cross-sentence relations in the text, a document-level relation extraction technique is also introduced. This technique can identify the relations between entities scattered in different locations in the document by constructing a document-level context representation and using a graph neural network model for reasoning.

[0022] S20: Calculate the semantic similarity between any two events. Aggregate events with semantic similarity greater than a second preset similarity threshold into the same cluster. Merge these clusters as event nodes in the initial knowledge graph to construct the knowledge graph. This can be understood as follows: for any event in a cluster, there exists at least one event with which its semantic similarity is greater than the second preset similarity threshold. When calculating semantic similarity, events are represented using dense vectors that include information such as their type, trigger words, and core arguments. Those skilled in the art can set the second preset similarity threshold according to actual needs; details are omitted here.

[0023] As described above, by automatically constructing a knowledge graph containing rich semantic relationships from unstructured text, a structured knowledge foundation is laid for global retrieval. Furthermore, the community detection algorithm can group a subset of nodes with tightly connected internal nodes and relatively sparse connections with external nodes into a community. Through community division, fragmented information from different entities and relationships at different levels can be integrated, improving the rapid understanding of structurally dispersed information and providing a foundation for subsequent parallel retrieval and generalized understanding.

[0024] S2, randomly rearrange the communities and divide them into several community combinations, and obtain the community combination description text corresponding to each community combination.

[0025] This step employs a random rearrangement and grouping strategy, effectively breaking the sequential dependency of community processing and avoiding potential biases caused by a fixed processing order. It generates comprehensive descriptive text for each community combination, expanding the micro-level entity relationship network into a meso-level topic semantic summary. This enables efficient and comprehensive understanding of topic information scattered in complex knowledge networks, facilitating the generation of comprehensive and insightful answers for broad topic queries.

[0026] In a preferred embodiment, the step of randomly rearranging the plurality of communities and dividing them into several community combinations includes the following steps: S201, calculate the weight of each community; wherein the weight of a community is determined based on at least one of the following methods: the total frequency of the entity in the community appearing in all text units, and the number of different text units covered by the entity in the community.

[0027] S202: Arrange several communities in descending order according to their weights and divide them into several windows on an equal basis. If the number of communities is insufficient to divide them equally, the number of communities in any two windows shall not differ by more than 1.

[0028] S203, perform local random swaps on communities within adjacent windows to obtain several community combinations; for example, perform local random swaps on communities within the first and second windows, and on communities within the third and fourth windows. After the swaps are completed, the set of communities within the same window is taken as a community combination.

[0029] The above approach first sorts the communities in descending order of weight, ensuring that high-weight communities tend to appear in earlier batches during grouping, thus potentially being processed earlier. This facilitates obtaining high-quality intermediate answers quickly, improving overall efficiency. Furthermore, the introduction of random swapping within adjacent windows largely maintains the overall trend of weights while breaking the strict linear order, providing a foundation for subsequent parallel processing.

[0030] Furthermore, the community combination description text corresponding to each community combination is obtained through the following steps: S210, for any community combination, if the concatenation of the original information context of each community in the community combination exceeds the context window limit threshold of the preset large language model, then the communities are traversed in descending order of the number of entities contained in each community in the community combination, and the original information context of the community itself is replaced by the pre-generated community-specific description text summary of the currently traversed community, so as to generate the compressed original information context corresponding to the community combination.

[0031] Specifically, the original information context of a community includes the original nodes and relationship information within the community.

[0032] S220: After each replacement, determine the current length of the current compressed original information context; if the current length does not exceed the context window limit threshold, stop traversing and proceed to step S240.

[0033] S230, if after traversing all communities within the community group, the length of the compressed original information context still exceeds the context window limit threshold, then the remaining original node information in the compressed original information context is sorted by importance according to the degree centrality of the nodes, and the nodes and their associated relationships are removed sequentially from back to front until the length of the compressed original information context does not exceed the context window limit threshold.

[0034] S240, take the current compressed original information context as the final context and input it into the preset large language model to generate the community combination description text corresponding to the community combination.

[0035] The above approach addresses the context window limitation problem in large language models when processing large-scale community combinations, which are complex and contain a lot of information. It effectively solves this problem by using a dynamic context compression mechanism. The approach combines summary-priority replacement with core structure order-preserving pruning, which significantly reduces the input length while maximizing the preservation of the core semantic information of the community, and can generate high-quality community combination description text.

[0036] S3, based on the user query, inputs the description text of each community combination as a separate context into the preset large language model, so that the preset large language model can generate an intermediate answer for the user query based on each separate context, and generate an answer relevance score for each intermediate answer.

[0037] As described above, by submitting different combinations of communities as independent contextual backgrounds to the large language model, the large language model is guided to generate preliminary insights related to user queries from the local perspective of different community combinations. This enables rapid and low-cost exploration of multiple thematic dimensions of the knowledge graph. Furthermore, by using relevance scoring, highly relevant answers to user queries can be selected to improve the accuracy and reliability of subsequent overall answers.

[0038] In another implementation, step S3 is replaced by the following steps: S31, based on the user query, traverse the community combinations in descending order of importance, and input the community combination description text corresponding to the community combination as a separate context into the preset large language model, so that the preset large language model generates an intermediate answer for the user query based on each individual context input, and generates an answer relevance score corresponding to each intermediate answer; wherein, the importance of the community combination is the sum of the weights of all communities in the community combination.

[0039] S32, after generating an intermediate answer corresponding to each community combination, calculate the question coverage and average relevance score of all currently generated intermediate answers.

[0040] Preferably, the question coverage is the semantic similarity between the query vector corresponding to the user query and the vectors corresponding to all intermediate answers.

[0041] S33: If both the problem coverage and the average relevance score reach the corresponding preset convergence thresholds, then stop the traversal and proceed directly to step S4; otherwise, continue traversing the next community combination. Those skilled in the art can set the preset convergence thresholds for problem coverage and average relevance score according to actual needs, which will not be elaborated here.

[0042] The above steps, by introducing an ordered traversal and dynamic evaluation mechanism based on the importance of community combinations, realize intelligent scheduling of computing resources and early convergence of the global retrieval process. It not only prioritizes high-weight core topic communities to ensure answer quality, but also actively terminates subsequent retrieval when the quality of the obtained answers is high. Thus, while ensuring retrieval results, it significantly improves the system's response efficiency when handling broad and macro queries.

[0043] S4: Sort and filter all intermediate answers according to the answer relevance score corresponding to each intermediate answer. Combine the selected intermediate answers to form a comprehensive context. Input the comprehensive context into the preset large language model to generate the final answer for the user query.

[0044] Specifically, when splicing together several selected intermediate answers, they are spliced ​​in descending order of their relevance scores.

[0045] As described above, by screening intermediate answers, noise and low-quality information are effectively filtered out. By splicing together several intermediate answers, information from multiple perspectives is gathered. By utilizing the comprehensive inductive ability of the large language model, multi-perspective and fragmented intermediate answers are integrated to generate a coherent, comprehensive, and generalized answer that can cover multiple topics involved in the query. This completes the transformation from distributed information retrieval to high-quality knowledge extraction, overcoming the limitations of traditional retrieval enhancement generation technology in processing domain information that is structurally dispersed and complexly related.

[0046] Furthermore, prior to step S1, the method further includes: S01, the user query is input into a pre-trained query intent classification model to identify the intent of the user query and output the query intent category; wherein, the query intent category is either a specific question or a broad question.

[0047] S02, when the query intent category is a broad question, execute steps S1 to S4 to generate the final answer for the user query.

[0048] Furthermore, the method also includes the following steps: S021, when the query intent category is a broad question, obtain the confidence level of the query intent category output by the pre-trained query intent classification model.

[0049] S022, when the confidence level is greater than the preset confidence threshold, the higher-level community is selected from the hierarchical community structure generated by the community discovery algorithm and then step S2 is executed; otherwise, the lower-level community is selected and step S2 is executed.

[0050] As described above, by combining the confidence level of query classification with the hierarchical structure of the knowledge graph, the adaptive allocation of global retrieval granularity is achieved. When the system is highly confident in its judgment of a broad question, it directly selects a high-level community for macro-level generalization, improving efficiency and the abstractness of the answer. When the judgment is doubtful, it selects a more specific low-level community, providing answers that are closer to specific facts while retaining the global retrieval framework. This enhances the robustness and practicality of the system in scenarios where the query intent is ambiguous.

[0051] In another embodiment, when the query intent category is a specific question, the following steps are performed: P1, based on user queries, retrieves at least one target entity from a pre-built knowledge graph; where each community in the knowledge graph corresponds to a community description text.

[0052] Specifically, the community description text includes all entities, relationships, and assertions extracted from the original text within the corresponding community.

[0053] As described above, by accurately anchoring the target entities related to the user query in the knowledge graph, an accurate semantic starting point is established for subsequent retrieval. Only a local retrieval method is needed, which improves retrieval efficiency and ensures that the retrieval process always revolves around key information directly related to the question. This overcomes the semantic drift problem that traditional full-text retrieval is prone to in complex queries, thereby improving the accuracy and reliability of subsequent answer output.

[0054] Further, in step P1, retrieving at least one target entity from the pre-constructed knowledge graph includes the following steps: On page 101, the text corresponding to the user's query is converted into a query vector. The semantic similarity between the query vector and the description vector corresponding to each entity in the knowledge graph is calculated. Several first candidate entities are recalled based on a first preset similarity threshold. Those skilled in the art can set the first preset similarity threshold according to actual needs, which will not be elaborated here.

[0055] P102, based on a knowledge graph, performs keyword matching on entity mentions in the user query, and expands the matched entities along the edges of the knowledge graph within a preset hop range to recall several second candidate entities. For example, the preset hop range can be one hop or two hops.

[0056] P103, deduplicatize all first candidate entities and all second candidate entities recalled, and encode the user query, each deduplicated candidate entity, and the local neighborhood information of the candidate entity in the knowledge graph. Input the encoded data into a pre-trained language model to calculate the context relevance score of each deduplicated candidate entity to the user query. The pre-trained language model can be a BERT model.

[0057] Specifically, the local neighborhood information includes the neighboring entities and relationships of the candidate entity within a preset number of hops.

[0058] P104: Candidate entities whose context-related scores exceed a preset score threshold are selected as the retrieved target entities.

[0059] As described above, by fusing breadth recall based on semantic vectors and keyword matching recall based on graph structures, the comprehensiveness of the target entity set is ensured. Furthermore, by utilizing local neighborhood information of entities for filtering, a set of core entities most relevant to the query intent can be dynamically identified, thus ensuring the accuracy of the retrieved target entities.

[0060] In a preferred embodiment, the step of calling a preset large language model to generate corresponding community description text for each community includes the following steps: P021, For any community, if the original information context contained in the community exceeds the context window limit threshold of the preset large language model, then based on the hierarchical community structure generated by the community discovery algorithm, each lower sub-community is traversed in descending order of the number of entities contained in the lower sub-community. The pre-generated descriptive text summary of the currently traversed lower sub-community replaces the original information context contained in the lower sub-community itself, so as to generate the compressed original information context corresponding to the community.

[0061] P022, after each replacement, determine the current length of the current compressed original information context; if the current length does not exceed the context window limit threshold, stop traversing and proceed to step P024.

[0062] P023, if after traversing all the lower-level sub-communities corresponding to the community, the length of the compressed original information context still exceeds the context window limit threshold, then the remaining original node information in the compressed original information context is sorted by importance according to the degree centrality of the nodes, and the nodes and their associated relationships are removed from back to front until the length of the compressed original information context does not exceed the context window limit threshold.

[0063] P024. The current compressed original information context is used as the final context and input into the preset large language model to generate the community description text corresponding to the community.

[0064] The above approach effectively addresses the context window limitation problem when large language models process large-scale knowledge graph communities by employing a dynamic context compression mechanism for large or complex communities containing a large number of entities and relationships. It adopts a strategy that combines hierarchical summary priority replacement with core structure order-preserving pruning, which significantly reduces the input length while maximizing the preservation of the community's core semantic information, ensuring generation efficiency, and generating high-quality community description text.

[0065] P2, based on each target entity, obtain a set of candidate information from the knowledge graph; the information units in the set of candidate information include candidate communities containing any target entity, candidate relationships connected to any target entity, and candidate original text blocks containing any target entity.

[0066] As described above, by expanding the search scope to include the community, relationships, and original evidence associated with entities, a multi-dimensional and structured set of candidate information is constructed. This achieves a search upgrade from point-entity to surface-local graph structure, while also covering the micro-facts of entities and relationships in text blocks as well as the macro-themes of communities. This gives the system a stronger sense of context and deep semantic understanding, ensuring the completeness and richness of the direct and indirect related information required for answer generation. It effectively overcomes the shortcomings of traditional search-enhanced generation in processing deep logic and related information.

[0067] P3, according to the preset sorting rules corresponding to each information unit, sorts and filters the candidate communities, candidate relationships and candidate original text blocks respectively, and obtains a number of sorted and filtered information units; it can be understood as: according to the sorting results, using the filtering threshold corresponding to each information unit, filtering out a number of candidate communities, candidate relationships and candidate original text blocks.

[0068] Specifically, the preset sorting rules corresponding to each information unit are as follows: P301, For candidate communities, sort them in descending order according to their corresponding weights; whereby the weights of candidate communities meet the following conditions: W c =α×log(F c +1)+β×(U c / N), where W c Let F be the weight of the c-th candidate community. c Let U be the total frequency of the target entity contained in the c-th candidate community across all text units. c α represents the number of unique text units covered by the target entity contained in the c-th candidate community, N represents the total number of text units, and α and β are preset weighting coefficients.

[0069] P302, for candidate relations, intra-network relations connecting two target entities take precedence over extra-network relations connecting one target entity and one non-target entity; wherein, intra-network relations are sorted in descending order according to the sum of the degrees of the two target entities corresponding to the intra-network relations, and extra-network relations are sorted in descending order according to the number of target entities connected to the non-target entity nodes corresponding to the extra-network relations.

[0070] P303, for candidate original text blocks, sort them in descending order based on the maximum context relevance score between the target entities associated with the candidate original text block and the user query; where, when the maximum context relevance scores of two candidate original text blocks are the same, sort them in descending order according to the total number of candidate relations associated with the candidate original text blocks.

[0071] The above-mentioned method, which adopts a multi-criteria ranking method based on graph topology and semantic relevance, performs hierarchical ranking and intelligent filtering of candidate information sets, effectively solving the context window limitation faced by large language models. Furthermore, it prioritizes the retention of content with high information density, strong relevance, and conclusive evidence during ranking, significantly improving the information quality of the input model and the reliability of the output.

[0072] In another implementation, the candidate original text blocks are further sorted by the following steps: P310, For each candidate original text block, calculate the corresponding sorting feature vector; the sorting feature vector includes at least the following dimensions.

[0073] Semantic similarity feature: cosine similarity between the candidate original text block and the query vector corresponding to the user query.

[0074] Community importance feature: the average degree centrality of the set of nodes in the community to which the candidate original text block belongs.

[0075] Evidence connectivity feature: the edge density of the minimum connected subgraph containing the target entities associated with the candidate original text block; it can be understood as: the minimum connected subgraph is the graph that contains all target entities associated with the candidate original text block and has the fewest number of edges.

[0076] Specifically, the edge density of the minimum connected subgraph satisfies the following condition: D = 2E / (V×(V-1)), where D is the edge density of the minimum connected subgraph, E is the number of edges in the minimum connected subgraph, and V is the number of nodes in the minimum connected subgraph.

[0077] Path saliency feature: the reciprocal of the average shortest path length of the target entity associated with the candidate original text block in the knowledge graph.

[0078] On page 320, the ranking feature vector corresponding to each candidate original text block is input into a pre-trained scoring model to obtain the final ranking score for each candidate original text block. The scoring model can be a weighted linear model, a weighted nonlinear model, or a neural network model; there are no restrictions on which one is used.

[0079] P330, All candidate original text blocks are sorted in descending order according to the final sorting score.

[0080] The above-mentioned method accurately quantifies the comprehensive value of candidate original text blocks as evidence for the answer from multiple dimensions by evaluating their global position in the graph structure, the closeness of the internal evidence, and the potential relevance of the entities involved. This allows for the selection of text evidence that is rich in information and strongly supported by logic for the subsequent generation of answers.

[0081] In another embodiment, steps P2 and P3 are replaced by the following steps: F1 determines the query semantic pattern category corresponding to the user query; the query semantic pattern category is at least one of fact confirmation type, causal analysis type, impact assessment type, and process description type.

[0082] F2, based on the query semantic pattern category, selects the corresponding target expansion strategy from a number of predefined graph expansion strategies; the number of predefined graph expansion strategies includes pathfinding strategies for locating direct relationships, causal traversal strategies for tracing causes or results, influence propagation strategies for assessing the scope of influence, and temporal association strategies for constructing event sequences.

[0083] Specifically, when a user query is a fact-confirming query, a pathfinding strategy is adopted: the core is to find and merge all the nodes and edges involved in the shortest path whose length does not exceed a preset length threshold among entity pairs in the target node set, forming an initial subgraph.

[0084] When a user query is causal analysis type, a causal traversal strategy is adopted: a directed, multi-hop graph traversal is performed along causal relationship edges of specific types such as "cause", "influence", and "originate from". During the traversal, a propagation weight is maintained for each path. This weight decays as the number of hops increases and is dynamically adjusted based on the credibility of the edge itself and its semantic relevance to the user query.

[0085] When a user query is for impact assessment, an impact propagation strategy is adopted: a random walk algorithm based on personalized PageRank is used to calculate the personalized PageRank score of all nodes in the graph relative to these target nodes, starting from each target entity, and selecting nodes whose scores are higher than a preset score threshold.

[0086] When a user query is a process description, a temporal association strategy is adopted: prioritize expanding temporal relationship edges such as "occurred before" and "followed by" to construct a sequence of events.

[0087] F3, using each target entity as an anchor point, calculates the score of each node to be evaluated within a preset hop range based on the selected target expansion strategy and a preset scoring function. The preset scoring function integrates the semantic similarity between the description text of the node to be evaluated and the user query, the structural importance of the node in the current subgraph, and the fit between the node and the query semantic pattern category. It can be understood as a weighted sum of semantic similarity, structural importance, and fit. For example, in causal analysis, nodes of type event with a large number of causal in-and-out edges will receive a higher fit.

[0088] Specifically, the preset scoring threshold is inversely proportional to the expansion depth. For example, the preset scoring threshold decreases exponentially as the expansion depth increases; the expansion depth refers to the number of node hops during the expansion.

[0089] Specifically, the structural importance of the node to be evaluated in the current subgraph meets the following conditions: G = λ × (d1 / d max ) + μ×K, where G represents the structural importance of any node to be evaluated in the current subgraph, d1 is the degree of the node to be evaluated in the current subgraph, and d max λ represents the maximum degree of a node in the current subgraph, K represents the betweenness centrality of the node to be evaluated in the current subgraph, and λ and μ are preset weight coefficients, respectively.

[0090] F4 expands the nodes to be evaluated with scores greater than the preset scoring threshold into the current subgraph to extend the evidence subgraph from the knowledge graph; the current subgraph refers to the real-time graph obtained when the nodes are expanded.

[0091] F5: Extract the description information corresponding to each node and edge in the evidence subgraph from the knowledge graph and integrate it to generate a prompt context to replace the prompt context in step P4.

[0092] As mentioned above, since the rules for constructing the candidate set are relatively static, such as including the target entity's community and relationships, they may be over-expanded, leading to the introduction of noise, or under-expanded, resulting in the loss of key indirect evidence. The new alternative scheme transforms the query semantic pattern into an executable graph traversal strategy and introduces a real-time evaluation mechanism that integrates semantics, structure, and intent fit. This enables the accurate and efficient extraction of evidence subgraphs closely related to the question logic from the knowledge graph, overcoming the shortcomings of information overload or insufficient association in traditional static retrieval. This significantly optimizes the contextual relevance and logical integrity of the prompts, thereby greatly improving the accuracy and interpretability of answers to complex reasoning questions.

[0093] P4 integrates the sorted and filtered information units to generate a prompt context, and inputs the prompt context into a preset large language model to generate the final answer for the user query.

[0094] Specifically, the prompt context includes at least the filtered community description text summary, entity relationship pairs, and original text information.

[0095] As described above, by synthesizing structured, high-quality information fragments into a coherent prompting context, the pre-set large language model is guided to play the role of an accurate reasoning engine, ensuring that the final generated answer is not only accurate and well-founded, but also logically coherent and can directly meet the user's information needs. This overcomes the limitations of traditional retrieval enhancement generation technology in processing structurally dispersed and complexly related information.

[0096] In summary, by integrating local information retrieval and global retrieval methods, a complete knowledge-enhanced retrieval and generation system has been constructed, significantly improving the overall capability when processing structurally dispersed and highly interconnected domain information. The local information retrieval method, through a local deep association retrieval mechanism, demonstrates a unique advantage in accurately tracing the source of information when handling specific and complex factual and logical reasoning queries. The global retrieval method, through a global topic fusion retrieval mechanism, demonstrates the core value of comprehensive summarization when handling broad and macro-level topic summarization and trend analysis queries. These two methods complement each other, enabling the system to output highly reliable answers that combine accuracy, logic, and insight for information needs of different granularities and types. Both methods improve the reliability of answer output when processing structurally dispersed and highly interconnected domain information, and each has different advantages in handling specific information and macro-level topics.

[0097] Embodiments of the present invention also provide a non-transitory computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a method in the method embodiments, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement the knowledge graph-based global retrieval method provided in the above embodiments.

[0098] Embodiments of the present invention also provide an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0099] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. It should also be understood that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

Claims

1. A global retrieval method based on knowledge graphs, characterized in that, The method includes the following steps: S1. A knowledge graph is constructed based on several original texts, and the knowledge graph is divided into several communities through a community detection algorithm; wherein, the nodes of the knowledge graph include entities and events extracted from several original texts, and the edges represent the relationships between entities and between entities and events; S2, randomly rearrange the communities and divide them into several community combinations, and obtain the community combination description text corresponding to each community combination; S3, based on the user query, the description text of each community combination is used as a separate context input to the preset large language model, so that the preset large language model generates an intermediate answer for the user query based on each separate context, and generates an answer relevance score for each intermediate answer. S4: Sort and filter all intermediate answers according to the answer relevance score corresponding to each intermediate answer. Combine the selected intermediate answers to form a comprehensive context. Input the comprehensive context into the preset large language model to generate the final answer for the user query.

2. The global retrieval method based on knowledge graphs according to claim 1, characterized in that, The knowledge graph is constructed using the following steps: S10: Extract entities, events, and relationships from several original texts to construct an initial graph; S20, calculate the semantic similarity between every two events, aggregate events with semantic similarity greater than the second preset similarity threshold into the same cluster, merge the clusters as an event node in the initial graph, and construct a knowledge graph.

3. The global retrieval method based on knowledge graphs according to claim 1, characterized in that, In step S2, the random rearrangement and division of the several communities into several community combinations includes the following steps: S201, calculate the weight of each community; wherein the weight of a community is determined based on at least one of the following methods: the total frequency of the entity appearing in all text units within the community, and the number of different text units covered by the entity within the community; S202, based on the weight of the community, sort several communities in descending order and divide them into several windows on an average basis; S203, perform local random swaps of communities within adjacent windows to obtain several community combinations.

4. The global retrieval method based on knowledge graphs according to claim 1, characterized in that, The community combination description text corresponding to each community combination is obtained through the following steps: S210, for any community combination, if the concatenation of the original information context of each community in the community combination exceeds the context window limit threshold of the preset large language model, then the communities are traversed in descending order of the number of entities contained in each community in the community combination, and the original information context of the community itself is replaced by the pre-generated community-specific description text summary of the currently traversed community, so as to generate the compressed original information context corresponding to the community combination. S220, after each replacement, determine the current length of the current compressed original information context; If the current length does not exceed the context window limit threshold, then stop traversing and proceed to step S240; S230, if after traversing all communities within the community group, the length of the compressed original information context still exceeds the context window limit threshold, then the remaining original node information in the compressed original information context is sorted by importance according to the degree centrality of the nodes, and the nodes and their associated relationships are removed from back to front until the length of the compressed original information context does not exceed the context window limit threshold. S240, take the current compressed original information context as the final context and input it into the preset large language model to generate the community combination description text corresponding to the community combination.

5. The global retrieval method based on knowledge graphs according to claim 3, characterized in that, Replace step S3 with the following steps: S31, based on the user query, the community combinations are traversed in descending order of importance. The description text of the community combination corresponding to the community combination is input as a separate context into the preset large language model, so that the preset large language model generates an intermediate answer for the user query based on each individual context input, and generates an answer relevance score corresponding to each intermediate answer; where the importance of the community combination is the sum of the weights of all communities in the community combination. S32, after generating an intermediate answer corresponding to each community combination, calculate the question coverage and average relevance score of all currently generated intermediate answers; S33. If the problem coverage and average relevance score both reach the corresponding preset convergence threshold, stop traversing and proceed directly to step S4; otherwise, continue traversing the next community combination.

6. The global retrieval method based on knowledge graphs according to claim 1, characterized in that, In step S4, when splicing together the selected intermediate answers, they are spliced ​​in descending order of the relevance scores of the corresponding intermediate answers.

7. The global retrieval method based on knowledge graphs according to claim 1, characterized in that, Prior to step S1, the method further includes: S01, the user query is input into a pre-trained query intent classification model to identify the intent of the user query and output the query intent category; wherein, the query intent category is either a specific question or a broad question; S02, when the query intent category is a broad question, execute steps S1 to S4 to generate the final answer for the user query.

8. The global retrieval method based on knowledge graphs according to claim 7, characterized in that, The method further includes the following steps: S021, When the query intent category is a broad question, obtain the confidence level of the query intent category output by the pre-trained query intent classification model; S022, when the confidence level is greater than the preset confidence threshold, the higher-level community is selected from the hierarchical community structure generated by the community discovery algorithm and then step S2 is executed; otherwise, the lower-level community is selected and step S2 is executed.

9. A non-transitory computer-readable storage medium, wherein the storage medium stores at least one instruction or at least one program segment, characterized in that, The at least one instruction or the at least one program segment is loaded and executed by the processor to implement the knowledge graph-based global retrieval method as described in any one of claims 1-8.

10. An electronic device, characterized in that, Includes a processor and the non-transitory computer-readable storage medium as described in claim 9.