A query-aware based knowledge graph retrieval enhancement generation system and method
By adaptively adjusting the retrieval strategy using a query-aware approach, the problem of insufficient flexibility of RAG and KG-RAG methods in different query types is solved, and efficient and accurate knowledge graph retrieval enhancement generation is achieved.
Patent Information
- Application Number
- CN202610473371.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing RAG and KG-RAG methods lack flexibility in handling different types of queries, have fixed retrieval strategies, and result in simple queries introducing redundant information or complex queries missing critical paths, leading to low inference efficiency.
A query-aware approach is adopted. Through query complexity analysis, the breadth-first search or shortest path algorithm is adaptively selected to retrieve the knowledge graph, obtain the appropriate reasoning path, and fuse it with the query information to generate the result.
It improves the accuracy and efficiency of generated results, adapts to different query complexities, reduces redundant information, and ensures efficient reasoning for complex queries.
Smart Images

Figure CN122364427A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of artificial intelligence and natural language processing, specifically relating to a query-aware knowledge graph retrieval enhancement generation system and method. Background Technology
[0002] Large Language Models (LLMs) represent a significant breakthrough in artificial intelligence in recent years. Trained on large-scale corpora, they are capable of understanding and generating natural language. Through deep learning techniques, LLMs can handle various natural language tasks, such as question answering, text generation, and translation. While LLMs perform well in many fields, they face "knowledge gaps" and "illusions" when dealing with complex problems requiring external knowledge support. This lack of external knowledge leads to inaccurate or unrealistic results.
[0003] In this context, Retrieval-Augmented Generation (RAG) emerged. RAG introduces external knowledge sources, performing knowledge retrieval before generation to obtain relevant information from external resources, and then generating more accurate answers based on this information. By combining the retrieval and generation stages, RAG effectively improves the model's performance in handling knowledge-intensive tasks, especially in domains not covered by LLM (Low-Level Modeling).
[0004] Knowledge Graph Retrieval-Augmented Generation (KG-RAG) is one approach that introduces knowledge graphs as an external knowledge source into the RAG framework. KG-RAG improves the generation effect by retrieving reasoning paths from the knowledge graph, providing structured knowledge information to the LLM (Low-Level Machine). KG-RAG can significantly enhance the reasoning ability of LLMs, especially when handling complex queries, as the reasoning paths provided by the knowledge graph can effectively avoid the knowledge gap problem in LLMs.
[0005] However, existing RAG and KG-RAG methods also share some common shortcomings, mainly in the following two aspects: 1. Inflexible retrieval strategies: Both RAG and KG-RAG typically rely on fixed retrieval strategies and inference paths, making them inflexible when facing different types of queries. Simple queries may introduce redundant information, while complex queries may miss key inference paths, thus affecting the quality and accuracy of the generated results.
[0006] 2. Low inference efficiency: For complex queries, existing RAG and KG-RAG methods are usually unable to adjust appropriately according to the complexity of the query, resulting in inefficient inference process and waste of computational resources.
[0007] Therefore, there is an urgent need to provide a query-aware knowledge graph retrieval enhancement generation system and method. Summary of the Invention
[0008] The main objective of this invention is to provide a query-aware knowledge graph retrieval enhancement generation system and method to overcome the shortcomings of the prior art.
[0009] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: An embodiment of the present invention provides a query-aware knowledge graph retrieval enhancement generation system, comprising: The query perception module is used to receive query information input by the user, and to perform complexity analysis on the query information to obtain the query complexity. An adaptive retrieval module is used to obtain a corresponding retrieval strategy based on the complexity category of the query, and to obtain inference path information of the query information based on the retrieval strategy. The retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity. The inference path information and the query information are then fused to obtain a query vector. The inference generation module is used to input the query vector into the generation model to generate query results, wherein the generation model is a large language model.
[0010] In a preferred embodiment, receiving query information input by the user, and performing complexity analysis on the query information to obtain the query complexity, includes: Entity referents and relational predicates in the query information are extracted using a language analysis model to construct entity relation features; the entity relation features are used to characterize the query entity set and the logical reasoning relationships between entities; and the complexity classification corresponding to the entity relation features is obtained.
[0011] In a preferred embodiment, the query complexity is represented as a complexity category, which includes simple queries and complex queries; The retrieval strategy includes: When the query complexity category is a simple query, a breadth-first search strategy is used to search the knowledge graph and obtain a set of intermediate paths with no more than a preset number of hops. When the query complexity category is complex query, the shortest path algorithm is used to search in the knowledge graph to obtain multi-hop reasoning paths as intermediate path set, and the number of hops of the multi-hop reasoning paths is higher than the preset number of hops; Obtain the relevance score for each path in the intermediate path set, and select the K paths with the highest relevance scores from the intermediate path set as inference path information, where K is a positive integer greater than 1. In a preferred embodiment, the retrieval in the knowledge graph using a breadth-first search strategy includes: taking an entity in the query information as a starting node, performing a breadth-first search in the knowledge graph according to a preset number of hops, obtaining reasoning paths related to the query, and forming a set of intermediate paths; or, The method of using the shortest path algorithm to perform retrieval in the knowledge graph includes: using Dijkstra's algorithm to find the shortest reasoning path between multiple entities in the knowledge graph, which serves as a multi-hop reasoning path and forms a set of intermediate paths. An embodiment of the present invention provides a query-aware knowledge graph retrieval enhancement generation method, comprising: Receive query information input by the user, perform complexity analysis on the query information, and obtain the query complexity. The corresponding retrieval strategy is obtained based on the complexity category of the query. The inference path information of the query information is obtained based on the retrieval strategy. The retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity. The inference path information and the query information are fused to obtain a query vector. The query vector is input into a generative model to generate query results; the generative model is a large language model.
[0012] One embodiment of the present invention provides a computer-readable storage medium storing a computer program that, when executed by at least one processor, implements the steps of any of the methods described above.
[0013] An embodiment of the present invention provides a computer program product, the computer program product including a computer program, which, when executed by at least one processor, implements the steps of the method described above.
[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: it adaptively uses query complexity as the basis for retrieval adjustment, and takes into account the reasoning path of the knowledge graph and the complexity characteristics of the query, thereby solving the problem that the existing RAG and KG-RAG methods have fixed retrieval strategies and lack flexibility when dealing with simple and complex queries, and the processing results are more efficient and accurate. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a schematic diagram of the overall system framework in one embodiment of this application; Figure 2 This is a schematic diagram illustrating the relationship between query complexity classification and reasoning path in one embodiment of this application; Figure 3 This is a schematic diagram of the adaptive retrieval process in one embodiment of this application; Figure 4 This is a flowchart illustrating the knowledge graph retrieval enhancement generation method in one embodiment of this application. Detailed Implementation
[0017] The invention will be more fully understood through the following detailed description, which should be read in conjunction with the accompanying drawings. Detailed embodiments of the invention are disclosed herein; however, it should be understood that the disclosed embodiments are merely exemplary of the invention, which may be embodied in various forms. Therefore, the specific functional details disclosed herein should not be construed as limiting, but rather as the basis for the claims and as intended to teach those skilled in the art to employ the representative basis of the invention in different ways in any suitable detailed embodiment.
[0018] Example 1 See Figure 1 This embodiment provides a query-aware knowledge graph retrieval enhancement generation system, including: The query awareness module receives query information input by the user and classifies the query information by complexity using a large language model to obtain query complexity categories; the query complexity categories include simple queries and complex queries; The query complexity is represented by a complexity category, which may include simple queries and complex queries. In specific applications, it may not be limited to a binary search; it could be a triadic search or an infinitely variable search. For example, it could be divided into three categories (simple, normal, and complex) or more categories based on the complexity score.
[0019] The process of receiving query information input by the user, performing complexity analysis on the query information to obtain the query complexity, includes: Entity referents and relational predicates are extracted from the query information using a language analysis model to construct entity relation features. These entity relation features characterize the set of entities in the query and the logical reasoning relationships between them. The complexity classification corresponding to the entity relation features is then obtained. The language analysis model can be, for example, a large language model or a simplified small language analysis model. Complexity classification based on the number of entities and the number of steps in logical reasoning relationships can also be obtained through fixed rules. The reason for preferring a large language model is that it captures complex implicit logic through deep semantic understanding for classification.
[0020] As an example, the query-aware module is configured as follows: First, receive the query information input by the user. Then, query complexity is directly classified using a Large Language Model (LLM): in, This indicates the complexity category of the query information. LLM determines the complexity based on the content of the query information. If the output is "simple," the query is classified as a simple query; if the output is "complex," the query is classified as a complex query. In practical applications, the query classification system is not limited to the "simple / complex" division; it can also be a label system such as A / B levels. This application uses "simple" and "complex" as the complexity categories for illustration.
[0021] Query complexity categories This will affect the selection of subsequent retrieval strategies. If the query is determined to be a simple query, the system will select a retrieval strategy suitable for simple queries; if the query is determined to be a complex query, a retrieval strategy suitable for complex queries will be selected.
[0022] An adaptive retrieval module is used to obtain a corresponding retrieval strategy based on the complexity category of the query, and to obtain inference path information of the query information based on the retrieval strategy. The retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity. The inference path information and the query information are then fused to obtain a query vector. In practical applications, the query complexity is represented as a complexity category, which includes simple queries and complex queries; The retrieval strategy includes: When the query complexity category is a simple query, a breadth-first search strategy is used to search the knowledge graph and obtain a set of intermediate paths with no more than a preset number of hops. When the query complexity category is complex query, the shortest path algorithm is used to search in the knowledge graph to obtain multi-hop reasoning paths as intermediate path set, and the number of hops of the multi-hop reasoning paths is higher than the preset number of hops; Obtain the relevance score for each path in the intermediate path set, and select the K paths with the highest relevance scores from the intermediate path set as inference path information, where K is a positive integer greater than 1.
[0023] The method of using a breadth-first search strategy to retrieve information in a knowledge graph includes: starting with an entity in the query information as a starting node, performing a breadth-first search in the knowledge graph according to a preset number of hops to obtain reasoning paths related to the query and forming a set of intermediate paths; or, The method of using the shortest path algorithm to perform retrieval in the knowledge graph includes: using Dijkstra's algorithm to find the shortest reasoning path between multiple entities in the knowledge graph, which serves as a multi-hop reasoning path and forms a set of intermediate paths.
[0024] As an example, the adaptive retrieval module is configured as follows: Based on query complexity category Choose an appropriate search strategy. For simple queries... This example uses a breadth-first search (BFS) strategy for retrieval. It leverages a knowledge graph through a graph search algorithm. Nodes in and edge To find and query information Related reasoning path. Let nodes... For entities in a knowledge graph, edges If the relationship between entities is defined, the search process can be represented by the following formula: in, This indicates that a maximum of two inference paths will be considered during the BFS retrieval process.
[0025] For complex queries This example uses a shortest path algorithm (such as Dijkstra's algorithm) for retrieval, ensuring that the retrieval path is as short as possible and the information is highly relevant. Let the inference path be... For the node The shortest path can be expressed by the following formula: in, Representing an edge The weights can be calculated based on the semantic similarity of the relation. The semantic similarity of the relation refers to the similarity between the expected relation between the calculated edge (relation) and the entity pair mentioned in the query (the semantic similarity between the calculated edge and the query).
[0026] During the retrieval process, path filtering and fusion operations are performed for simple and complex queries, respectively. Let the set of intermediate paths retrieved be... Each path The corresponding relevance score is Path filtering is performed using the following formula: in, This indicates selecting the highest-scoring path from the retrieved paths. These paths form reasoning path information.
[0027] Next, the selected path (inference path information) will be compared with the query information. Combine and merge. Let the query vector be... This indicates that each selected path is... After fusion for: The inference generation module is used to input the query vector into the generation model to generate query results, wherein the generation model is a large language model.
[0028] As an example, the inference generation module is configured as follows: The final query vector after fusion The input is passed to the generative model to generate the final answer (query result). The generative model is a large model LLM, and its output is... This refers to the answer to the query. The generation process is as follows: The Generator is the generative model used to generate the final answer, in order to produce the optimal answer.
[0029] In summary, to address the shortcomings of related technologies, the technical solution provided in this embodiment includes a query complexity analysis stage and a retrieval enhancement generation stage.
[0030] In the query complexity analysis phase, the system first receives user-input queries. Using a large language model, the queries are categorized by complexity into simple and complex queries. Simple queries typically involve a small number of entities and relationships, while complex queries involve more entities and multi-step reasoning paths. The results of the query complexity analysis will serve as the basis for subsequent retrieval strategy selection.
[0031] During the retrieval enhancement generation stage, different retrieval strategies are automatically selected based on the complexity of the query. For simple queries, a breadth-first search (BFS) strategy is used to extract relevant entities and relations from the knowledge graph (subgraph extraction process) and obtain a concise inference path. For complex queries, a shortest path algorithm (such as Dijkstra's algorithm) is used to find multi-hop inference paths to reduce redundant information and ensure accuracy (in complex queries, the algorithm first obtains multiple multi-hop inference paths and then selects the shortest path). The inference path in the retrieval process is not only based on the structure of the knowledge graph but also considers the semantic relationships between entities. Through graph embedding technology, the semantic similarity of entities and relations is effectively quantified. Finally, the retrieved path is passed to the generative model along with the query input to obtain the final answer. The generative model generates the final answer by combining the original information with the retrieval path to ensure the accuracy and relevance of the generated result.
[0032] To better understand the technical implementation of the technical solution provided in this embodiment, the following two specific examples demonstrate how to use a query-aware knowledge graph retrieval enhancement generation system to solve practical problems.
[0033] In one example, the query task is a simple query task where the user asks, "Who is the director of a certain movie?". Figure 1 The overall system framework is presented, including a query perception module, an adaptive retrieval module, and an inference generation module. The query perception module determines the complexity of the query, the adaptive retrieval module selects an appropriate retrieval strategy, and the inference generation module is responsible for generating the final answer.
[0034] First, the system receives the user's query information. "Who is the director of a certain movie?" Then, the query complexity is directly classified using a Large Language Model (LLM): in, This indicates the query complexity category. LLM determines the query complexity based on a specific prompt. If the output is "simple," the query is classified as a simple query; if the output is "complex," the query is classified as a complex query.
[0035] In this example, since the query "Who is the director of a certain movie?" involves only one entity (movie) and one relation (director), the system determines this query as a "simple query" through LLM reasoning. (Appendix) Figure 2 This demonstrates the distribution of inference paths with different hop counts for simple and complex queries. Simple queries typically require only a few inference steps, while complex queries require longer inference paths.
[0036] Based on the query complexity classification (simple queries), the system selects to use the breadth-first search (BFS) strategy for knowledge graph retrieval. BFS is suitable for simple queries because it can efficiently find relevant entities and relationships along a shorter reasoning path.
[0037] knowledge graph Includes nodes and edge In this knowledge graph, nodes represent entities, and edges represent relationships between entities. In this query, the nodes include entities related to "a certain movie" and "the director," and the edges represent the relationship between "the movie and the director." The breadth-first search process is as follows: This formula indicates that the system starts from the "movie" node, performs a maximum of two hops of reasoning, and retrieves the director entity related to that movie. (Appendix) Figure 3 The adaptive retrieval process is demonstrated. The diagram illustrates how to retrieve reasoning paths from a knowledge graph, including different strategies such as subgraph extraction, BFS retrieval, and Dijkstra's retrieval. In the case of a simple query, the BFS method is used to retrieve the reasoning path between a movie and its director.
[0038] Preprocessing involves preparing the raw input, providing standardized input for subsequent type determination and retrieval operations. Postprocessing includes path selection (TopK selection) and relevance score calculation after BFS or Dijkstra's search. Return path outputs the processed path information to the downstream module (inference generation module).
[0039] During the retrieval process, path filtering and merging operations are performed for this simple query. Let the retrieved path set be... Each path The corresponding relevance score is Relevance scores are obtained through semantic similarity. Path filtering is performed using the following formula: in, This indicates selecting the highest-scoring path from the retrieved paths. A path (and as path information). Furthermore, the value of K ranges from 1 to 3; the more complex the problem, the larger the value of K should be. Next, the selected path will be compared with the query... The results are then fused to obtain the final enhanced query vector. : By integrating query information and retrieval paths, the system effectively combines query information with the retrieval path to obtain the final query vector. The merged query vector The input is passed to the generative model to generate the final answer. The generative model is a Large Language Model (LLM), and its output is... This refers to the answer to the query (the query result). The generation process is as follows: In this example, the final generated answer is: "the specific name of a certain director".
[0040] In another example, unlike the previous one, the query task is a complex reasoning task; the user enters the query "Which Oscar-winning actors have also directed films?". Figure 1 The system architecture was demonstrated, comprising a query-aware module, an adaptive retrieval module, and an inference generation module. In cases of complex queries, the inference generation module combines the retrieved shortest path with the query information to generate the final answer.
[0041] First, the system receives the query information entered by the user. "Which Oscar-winning actors have also directed films?" Then, the query complexity is directly categorized using a Large Language Model (LLM). in, This indicates the query complexity category. LLM determines the query complexity based on a specific prompt. If the output is "simple," the query is classified as a simple query; if the output is "complex," the query is classified as a complex query.
[0042] In this example, the query "Which Oscar-winning actors have also directed films?" involves multiple entities (Oscar winners, actors, directors) and multiple logical reasoning relationships. Therefore, the system uses LLM reasoning to determine that this query is a "complex query". (See attached image) Figure 2 This illustrates the difference between complex and simple queries. The diagram shows that complex queries typically require longer reasoning paths and involve multiple entities and relationships.
[0043] Based on the query complexity classification results (complex queries), the system selects to use Dijkstra's algorithm to retrieve the shortest inference path. Complex queries typically involve relationships between multiple entities, and Dijkstra's algorithm can efficiently find the inference chain with the shortest path length.
[0044] In this query, knowledge graph Includes nodes and edge Here, nodes represent entities such as actors and directors, and edges represent relationships between these entities (e.g., the "win an Oscar" relationship, the "director" relationship). Using Dijkstra's algorithm, the system selects the shortest path from the multi-hop inference paths to ensure accurate and efficient query results. The shortest path retrieval is calculated using the following formula: in, Representing an edge The weight represents the relevance of the relationship or the semantic similarity of the entities. (Appendix) Figure 3 The adaptive retrieval process is illustrated. The diagram shows how to retrieve reasoning paths from a knowledge graph, including different strategies such as subgraph extraction, BFS retrieval, and Dijkstra's algorithm. In complex query scenarios, Dijkstra's algorithm is used to find the optimal reasoning path.
[0045] During the retrieval process, the system retrieved the following set of reasoning paths: Each path The corresponding relevance score is The system sorts the paths according to their scores and selects the path with the highest score. Select a path and generate a set of selected paths: Next, the system will match the selected path with the query. The query vector is then fused to obtain an enhanced query vector. The specific steps are as follows: This fusion operation enables the system to comprehensively consider the reasoning paths retrieved from the query and the results, thereby generating the final enhanced query vector. .
[0046] Finally, the merged query vector The input is fed into the generative model to generate the answer. The generation process can be represented as: In this embodiment, the generated answer is: "Name of a certain director". The generation model accurately generated the answer based on the fused query information and reasoning path.
[0047] As an example, this application also provides the following comparative examples. Referring to Tables 1 and 2 below, Example 1 is an experimental example conducted using the technical solution provided in this application. Comparisons 1 through 3 are comparative examples conducted using existing RAG methods.
[0048] Table 1 Table 2 Table 1 shows the comparison results for a simple query task (“Who is the director of a movie?”). Example 1 took 306 seconds (306s) to complete the task. Comparison 1 took 38 hours (38h) to complete the same or similar task. Comparison 1 took significantly longer to complete the task compared to Example 1.
[0049] Table 2 presents a comparison of the Hit@1 metric (shown as a percentage) for different groups (instance group and multiple comparison groups) on two different datasets (WebQSP and CWQ). Through the step-by-step descriptions of the examples above, and the comparisons with the comparisons, it demonstrates how to automatically select a retrieval strategy based on query awareness, fuse retrieval results, and generate accurate answers. In simple query tasks, the system quickly finds relevant inference paths using a breadth-first search (BFS) strategy; while in complex inference tasks, it selects the shortest inference path using the Dijkstra algorithm, combining path filtering and fusion techniques to generate accurate answers. During implementation, [the following is a continuation of the previous paragraph]... Figure 1 The system architecture and interaction flow are illustrated, with appendices. Figure 2 The relationship between query complexity and inference path is explained, with appendix. Figure 3 The execution path of adaptive retrieval is described in detail. Combined with formulas and accompanying figures, the embodiment clearly demonstrates how query input is transformed into the final answer. This embodiment effectively improves the accuracy and inference efficiency of query processing and provides a good solution for more complex query tasks, ensuring the efficiency and accuracy of inference.
[0050] Compared with related technologies, the technical solution provided in this application adaptively uses query complexity as the basis for retrieval adjustment, taking into account the reasoning path of the knowledge graph and the complexity characteristics of the query. This solves the problem of fixed and inflexible retrieval strategies in existing RAG and KG-RAG methods when handling simple and complex queries, resulting in more efficient and accurate processing. Its advantage lies in achieving efficient synergy between retrieval quality and modular flexibility. By adaptively switching retrieval strategies based on query complexity, good performance can be achieved with minimal training cost (e.g., only five minutes compared to tens of hours required by traditional methods) without the need for fine-tuning large language models. This lightweight, highly versatile modular design allows it to flexibly adapt to knowledge graphs of different sizes and structures. Experimental results show that the framework significantly improves inference accuracy on multiple public benchmark datasets (WebQSP, CWQ), with its key metric Hits@1 improving by 10% to 30% compared to existing mainstream methods, demonstrating good practical value and application prospects while ensuring efficient computation.
[0051] Example 2 See Figure 4 This embodiment also provides a query-aware knowledge graph retrieval enhancement generation method. Its specific implementation and the achieved technical effects are consistent with the embodiments described in the above system embodiments, and some details will not be repeated. The method includes: S101, Receive query information input by the user, perform complexity analysis on the query information, and obtain the query complexity; S102, obtain the corresponding retrieval strategy according to the queried complexity category, obtain the inference path information of the query information according to the retrieval strategy, wherein the retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity; fuse the inference path information and the query information to obtain a query vector; S103, The query vector is input into the generative model to generate query results, wherein the generative model is a large language model.
[0052] In one embodiment, receiving user-input query information and performing complexity analysis on the query information to obtain the query complexity includes: The entity references and relational predicates in the query information are extracted using the large language model to construct entity relation features; the entity relation features are used to characterize the query entity set and the logical reasoning relationships between entities; and the complexity classification corresponding to the entity relation features is obtained.
[0053] In one embodiment, the query complexity is represented as a complexity category, which includes simple queries and complex queries; The retrieval strategy includes: When the query complexity category is a simple query, a breadth-first search strategy is used to search the knowledge graph and obtain a set of intermediate paths with no more than a preset number of hops. When the query complexity category is complex query, the shortest path algorithm is used to search in the knowledge graph to obtain multi-hop reasoning paths as intermediate path set, and the number of hops of the multi-hop reasoning paths is higher than the preset number of hops; Obtain the relevance score for each path in the intermediate path set, and select the K paths with the highest relevance scores from the intermediate path set as inference path information, where K is a positive integer greater than 1.
[0054] In one embodiment, the breadth-first search strategy for retrieval in the knowledge graph includes: using entities in the query information as starting nodes, performing a breadth-first search in the knowledge graph according to a preset number of hops to obtain reasoning paths related to the query and forming a set of intermediate paths; or, The method of using the shortest path algorithm to perform retrieval in the knowledge graph includes: using Dijkstra's algorithm to find the shortest reasoning path between multiple entities in the knowledge graph, which serves as a multi-hop reasoning path and forms a set of intermediate paths.
[0055] Example 3 This application also provides a computer-readable storage medium, the specific embodiments of which are consistent with the embodiments described above and the technical effects achieved, and some contents will not be repeated.
[0056] The computer-readable storage medium stores a computer program that, when executed by at least one processor, implements the steps of any of the above methods or the functions of any of the above electronic devices.
[0057] A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. In embodiments of this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0058] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable storage medium may also be any computer-readable medium capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, or any suitable combination thereof. Program code for performing operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on a user computing device, partially on a user device, as a standalone software package, partially on a user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to user computing devices via any type of network, including local area networks (LANs) or wide area networks (WANs), or they can be connected to external computing devices (e.g., via the Internet using an Internet service provider).
[0059] Example 4 This application also provides a program product embodiment, wherein the computer program product includes a computer program, and when the computer program is executed by at least one processor, it implements the steps of the method described in any one of the method embodiments. Its specific embodiments are consistent with the embodiments described above and the technical effects achieved are the same, and some details will not be repeated.
[0060] Although the invention has been described with reference to illustrative embodiments, those skilled in the art will understand that various other changes, omissions, and / or additions can be made without departing from the spirit and scope of the invention, and that elements of the described embodiments can be substituted with substantially equivalents. Furthermore, many modifications can be made without departing from the scope of the invention to adapt particular situations or materials to the teachings of the invention. Therefore, this document is not intended to limit the invention to the specific embodiments disclosed for carrying out the invention, but rather to include all embodiments falling within the scope of the appended claims.
Claims
1. A query-aware knowledge graph retrieval enhancement generation system, characterized in that, include: The query perception module is used to receive query information input by the user, and to perform complexity analysis on the query information to obtain the query complexity. An adaptive retrieval module is used to obtain a corresponding retrieval strategy based on the complexity category of the query, and to obtain inference path information of the query information based on the retrieval strategy. The retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity. The inference path information and the query information are then fused to obtain a query vector. The inference generation module is used to input the query vector into the generation model to generate query results, wherein the generation model is a large language model.
2. The knowledge graph retrieval enhancement generation system according to claim 1, characterized in that, The process of receiving query information input by the user, performing complexity analysis on the query information to obtain the query complexity, includes: Entity referents and relational predicates in the query information are extracted using a language analysis model to construct entity relation features; the entity relation features are used to characterize the query entity set and the logical reasoning relationships between entities; and the complexity classification corresponding to the entity relation features is obtained.
3. The knowledge graph retrieval enhancement generation system according to claim 1, characterized in that, The query complexity is represented by a complexity category, which includes simple queries and complex queries; The retrieval strategy includes: When the query complexity category is a simple query, a breadth-first search strategy is used to search the knowledge graph and obtain a set of intermediate paths with no more than a preset number of hops. When the query complexity category is complex query, the shortest path algorithm is used to search in the knowledge graph to obtain multi-hop reasoning paths as intermediate path set, and the number of hops of the multi-hop reasoning paths is higher than the preset number of hops; Obtain the relevance score for each path in the intermediate path set, and select the K paths with the highest relevance scores from the intermediate path set as inference path information, where K is a positive integer greater than 1.
4. The knowledge graph retrieval enhancement generation system according to claim 3, characterized in that, The method of using a breadth-first search strategy to retrieve information in a knowledge graph includes: starting with an entity in the query information as the starting node, performing a breadth-first search in the knowledge graph according to a preset number of hops to obtain reasoning paths related to the query and forming a set of intermediate paths; or, The method of using the shortest path algorithm to perform retrieval in the knowledge graph includes: using Dijkstra's algorithm to find the shortest reasoning path between multiple entities in the knowledge graph, which serves as a multi-hop reasoning path and forms a set of intermediate paths.
5. A query-aware knowledge graph retrieval enhancement generation method, characterized in that, include: Receive query information input by the user, perform complexity analysis on the query information, and obtain the query complexity. The corresponding retrieval strategy is obtained based on the complexity category of the query. The inference path information of the query information is obtained based on the retrieval strategy. The retrieval breadth of the inference path information is negatively correlated with the complexity, and the retrieval depth is positively correlated with the complexity. The inference path information and the query information are fused to obtain a query vector. The query vector is input into a generative model to generate query results; the generative model is a large language model.
6. The knowledge graph retrieval enhancement generation method according to claim 5, characterized in that, The process of receiving query information input by the user, performing complexity analysis on the query information to obtain the query complexity, includes: Entity referents and relational predicates in the query information are extracted using a language analysis model to construct entity relation features; the entity relation features are used to characterize the query entity set and the logical reasoning relationships between entities; and the complexity classification corresponding to the entity relation features is obtained.
7. The knowledge graph retrieval enhancement generation method according to claim 5, characterized in that, The query complexity is represented by a complexity category, which includes simple queries and complex queries; The retrieval strategy includes: When the query complexity category is a simple query, a breadth-first search strategy is used to search the knowledge graph and obtain a set of intermediate paths with no more than a preset number of hops. When the query complexity category is complex query, the shortest path algorithm is used to search in the knowledge graph to obtain multi-hop reasoning paths as intermediate path set, and the number of hops of the multi-hop reasoning paths is higher than the preset number of hops; Obtain the relevance score for each path in the intermediate path set, and select the K paths with the highest relevance scores from the intermediate path set as inference path information, where K is a positive integer greater than 1.
8. The knowledge graph retrieval enhancement generation method according to claim 7, characterized in that, The method of using a breadth-first search strategy to retrieve information in a knowledge graph includes: starting with an entity in the query information as the starting node, performing a breadth-first search in the knowledge graph according to a preset number of hops to obtain reasoning paths related to the query and forming a set of intermediate paths; or, The method of using the shortest path algorithm to perform retrieval in the knowledge graph includes: using Dijkstra's algorithm to find the shortest reasoning path between multiple entities in the knowledge graph, which serves as a multi-hop reasoning path and forms a set of intermediate paths.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by at least one processor, implements the steps of the method according to any one of claims 5-8.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by at least one processor, implements the steps of the method according to any one of claims 5-8.