Retrieval enhancement generation method, device, equipment and medium based on knowledge graph

By combining the knowledge graph pattern and large language model, query statements are generated and queryed in the knowledge graph database, the shortcomings of the vector RAG library in complex knowledge queries are solved, and more accurate search results are achieved.

CN120277206BActive Publication Date: 2025-08-26ZHONGDIAN DATA IND CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510766359.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-08-26
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

The existing vectorization-based RAG library cannot answer accurately when processing inter-entity calculations and internal logical relationship queries, and cannot meet the needs of complex knowledge query.

Method used

By obtaining the knowledge graph pattern and querying problem text, preprocessing and format conversion, the large language model is used to obtain pattern information from the knowledge graph pattern, generate query statements, and query in the knowledge graph database to obtain query results.

Benefits of technology

It improves the accuracy of the search results, can handle inter-entity calculations and internal logical relationship queries, makes up for the shortcomings of the vector RAG library, and provides more comprehensive and accurate answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277206B_ABST
    Figure CN120277206B_ABST
Patent Text Reader

Abstract

The disclosed embodiments relate to a method, apparatus, device and medium for retrieval enhancement generation based on a knowledge graph, and relate to the field of artificial intelligence technology, including: obtaining a knowledge graph pattern and a query question text; processing the knowledge graph pattern to obtain a target knowledge graph pattern, and preprocessing the query question text to obtain a target question text; inputting the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtaining pattern information that matches the target question text from the target knowledge graph pattern; generating a query statement based on the pattern information and the target question text, and querying the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result. By adopting the above technical solution, through the combination of the knowledge graph pattern and the large language model, it is possible to more deeply understand the semantics and background of the question, thereby generating more accurate query statements, supporting complex knowledge queries, and thus improving retrieval accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and medium for retrieval enhancement generation based on a knowledge graph. Background Art

[0002] Retrieval-Augmented Generation (RAG) is a technology that combines external knowledge retrieval with text generation to improve the quality and accuracy of text generation. Currently, RAG construction methods primarily rely on a text vectorization RAG library. This involves converting text data into vectors and storing them in a vector database. During retrieval, the similarity between the query vector and the vectors in the vector database is calculated to return the most relevant text fragments, which are then combined for text generation. For example, in a question-and-answer system, a user enters a question, the system vectorizes the question, and then searches the RAG library for relevant answer fragments to generate the complete answer.

[0003] Existing vectorized RAG libraries have limitations. They can only retrieve content at the literal and semantic levels and cannot further query or calculate results based on existing descriptions and data. For example, when it is necessary to query the computational relationship between entities (such as the merger time of two companies, the calculation of kinship between people, etc.), or when it comes to internal logical relationship queries (such as causal relationships, conditional relationships, etc.), relying solely on vector RAG library retrieval often cannot answer or accurately answer. Summary of the Invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a knowledge graph-based retrieval enhancement generation method, device, equipment and medium.

[0005] An embodiment of the present disclosure provides a retrieval enhancement generation method based on a knowledge graph, comprising: obtaining a knowledge graph pattern and a query question text; processing the knowledge graph pattern according to a preset format to obtain a target knowledge graph pattern, and preprocessing the query question text to obtain a target question text; inputting the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtaining pattern information matching the target question text from the target knowledge graph pattern; generating a query statement based on the pattern information and the target question text, and querying the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result.

[0006] Optionally, the knowledge graph pattern is processed according to a preset format to obtain a target knowledge graph pattern, including: obtaining predefined node identifiers and node relationship attribute identifiers; identifying the nodes in the knowledge graph pattern and the relationships between the nodes based on the node identifiers and the node relationship attribute identifiers to obtain the target knowledge graph pattern.

[0007] Optionally, the knowledge graph pattern is processed according to a preset format to obtain a target knowledge graph pattern, including: obtaining metadata based on the knowledge graph pattern for each node, the relationship type, constraints and hierarchical conditions between nodes to obtain the target knowledge graph pattern.

[0008] Optionally, the preprocessing of the query question text to obtain a target question text includes: deleting stop words in the query question text to obtain a question text to be processed; and performing part-of-speech tagging on the question text to be processed to obtain the target question text.

[0009] Optionally, the target question text and the target knowledge graph pattern are input into a preset large language model for processing, and pattern information matching the target question text is obtained from the target knowledge graph pattern, including: the large language model traverses the target knowledge graph pattern based on the target question text, calculates the similarity between the target question text and each node in the target knowledge graph pattern based on a preset semantic matching model, and takes nodes with similarity greater than or equal to a preset similarity threshold as target nodes; and takes all the target nodes and the relationships between the target nodes as the pattern information.

[0010] Optionally, the method further includes: obtaining a question category of the target question text; and adjusting model parameters of the semantic matching model and the similarity threshold based on the question category.

[0011] Optionally, generating a query statement based on the pattern information and the target question text includes: performing named entity recognition on the target question text to obtain at least one entity; mapping the at least one entity to the pattern information, and generating the query statement based on preset query logic.

[0012] Optionally, the query statement is based on the query in the knowledge graph database corresponding to the knowledge graph model to obtain the query result, including: sending the query statement to the knowledge graph database to query and obtain the query entity, query entity relationship and query entity attribute; integrating the query entity, the query entity relationship and the query entity attribute according to preset processing rules to obtain the query result.

[0013] An embodiment of the present disclosure also provides a retrieval enhancement generation device based on a knowledge graph, the device comprising: an acquisition module for acquiring a knowledge graph pattern and a query question text; a first processing module for processing the knowledge graph pattern according to a preset format to obtain a target knowledge graph pattern; a second processing module for preprocessing the query question text to obtain a target question text; an input module for inputting the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtaining pattern information matching the target question text from the target knowledge graph pattern; a generation module for generating a query statement based on the pattern information and the target question text; and a query module for querying a knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result.

[0014] An embodiment of the present disclosure also provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; the processor for reading the executable instructions from the memory and executing the instructions to implement the knowledge graph-based retrieval enhancement generation method provided in an embodiment of the present disclosure.

[0015] An embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program, and the computer program is used to execute the knowledge graph-based retrieval enhancement generation method provided in the embodiment of the present disclosure.

[0016] The embodiments of the present disclosure also provide a computer program product, including a computer program, wherein the computer program is executed by a processor as the knowledge graph-based retrieval enhancement generation method provided in the embodiments of the present application.

[0017] The technical solution provided by the embodiments of the present disclosure has the following advantages over the existing technology: the knowledge graph-based retrieval enhancement generation solution provided by the embodiments of the present disclosure obtains a knowledge graph pattern and a query question text; processes the knowledge graph pattern according to a preset format to obtain a target knowledge graph pattern, and pre-processes the query question text to obtain a target question text; inputs the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtains pattern information that matches the target question text from the target knowledge graph pattern; generates a query statement based on the pattern information and the target question text, and queries the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result. By combining the knowledge graph pattern with the large language model, it is possible to more deeply understand the semantics and context of the question, thereby generating more accurate query statements and improving the quality of the retrieval results; it is able to handle complex knowledge requirements such as inter-entity calculations and internal logical relationship queries, making up for the shortcomings of traditional vector RAG libraries; and fully utilizes the rich knowledge structure and relationship information in the knowledge graph to dig out deeper knowledge and provide more comprehensive and accurate answers. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.

[0019] Figure 1 A schematic diagram of a process flow of a knowledge graph-based retrieval enhancement generation method provided in an embodiment of the present disclosure;

[0020] Figure 2 A flowchart of another knowledge graph-based retrieval enhancement generation method provided in an embodiment of the present disclosure;

[0021] Figure 3 A schematic diagram of the structure of a knowledge graph-based retrieval enhancement generation device provided in an embodiment of the present disclosure;

[0022] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0024] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0025] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0026] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0027] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0028] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0029] Specifically, the existing technical solution based on the vectorized RAG library has limitations; it can only complete content retrieval at the literal and semantic levels, and cannot further query or calculate results based on existing description content and data; that is, relying solely on vector RAG library retrieval often cannot answer or answer accurately.

[0030] In response to the above problems, how to improve the accuracy of RAG retrieval, and how to implement problems that the vector RAG library cannot answer, such as inter-entity calculations and internal logical relationship queries, so as to broaden the application scope of RAG technology in complex knowledge processing scenarios; the knowledge graph-based retrieval enhancement generation method proposed in the embodiment of the present disclosure can improve the accuracy of RAG retrieval, and at the same time add functions such as inter-entity calculations and internal logical relationship queries that the vector RAG library cannot implement, and can handle more complex knowledge query requirements.

[0031] Figure 1This is a flow chart of a method for generating retrieval enhancement based on a knowledge graph provided by an embodiment of the present disclosure. This method can be executed by a device for generating retrieval enhancement based on a knowledge graph, wherein the device can be implemented using software and / or hardware and can generally be integrated into an electronic device. Figure 1 As shown, the method includes:

[0032] Step 101: Obtain the knowledge graph model and query question text.

[0033] In the disclosed embodiments, a knowledge graph schema refers to a knowledge graph that defines the structure, type, and relationships of knowledge and is used to describe how data is organized. Knowledge graph schemas are typically pre-defined based on the knowledge system of a specific domain. In the disclosed embodiments, a knowledge graph schema can be input based on actual query needs.

[0034] In the embodiment of the present disclosure, the query question text may be input manually or by voice according to actual query needs.

[0035] Step 102: Process the knowledge graph model according to a preset format to obtain a target knowledge graph model, and pre-process the query question text to obtain a target question text.

[0036] In an embodiment of the present disclosure, after obtaining the knowledge graph pattern, the knowledge graph pattern is processed according to a preset format to obtain a target knowledge graph pattern. There are many ways to do this. In one embodiment, predefined node identifiers and node relationship attribute identifiers are obtained; based on the node identifiers and node relationship attribute identifiers, the nodes in the knowledge graph pattern and the relationships between the nodes are identified to obtain the target knowledge graph pattern; in another embodiment, metadata is generated based on the knowledge graph pattern to obtain each node, the relationship type between nodes, constraints and hierarchical conditions to obtain the target knowledge graph pattern.

[0037] Furthermore, there are many ways to pre-process the query text to obtain the target question text. In some embodiments, the stop words in the query text are deleted to obtain the question text to be processed; the question text to be processed is tagged with parts of speech to obtain the target question text; in other embodiments, the query text is segmented to obtain multiple keywords, and after screening the multiple keywords, the target keywords are obtained, and then the target keywords are tagged with parts of speech, and the tagged target keywords are combined to form the target question text.

[0038] Step 103: Input the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtain pattern information matching the target question text from the target knowledge graph pattern.

[0039] In the embodiment of the present disclosure, the preset large language model refers to a large-scale language model based on deep learning, which can understand and generate natural language.

[0040] In an embodiment of the present disclosure, the target question text and the target knowledge graph pattern are input into a preset large language model for processing. Obtaining pattern information that matches the target question text from the target knowledge graph pattern can be understood as determining one or more target nodes from multiple nodes in the target knowledge graph pattern, as well as the relationship between the target nodes, for the target question text through the large language model to determine the pattern information that matches the target question text.

[0041] Step 104: Generate a query statement based on the pattern information and the target question text, and perform a query in the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result.

[0042] In an embodiment of the present disclosure, after obtaining pattern information that matches the target question text, a query statement can be generated based on the pattern information and the target question text. Specifically, named entity recognition can be performed on the target question text to obtain at least one entity, and the at least one entity can be mapped to the pattern information, and a query statement can be generated based on preset query logic.

[0043] Furthermore, based on the query statement, a query is performed in the knowledge graph database corresponding to the knowledge graph model to obtain query results. Specifically, based on the query statement, a query in the knowledge graph database can obtain query entities, query entity relationships, query entity attributes, etc. as query results.

[0044] The embodiment of the present disclosure provides a knowledge graph-based retrieval enhancement generation solution, which obtains a knowledge graph pattern and a query question text; processes the knowledge graph pattern according to a preset format to obtain a target knowledge graph pattern, and pre-processes the query question text to obtain a target question text; inputs the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtains pattern information that matches the target question text from the target knowledge graph pattern; generates a query statement based on the pattern information and the target question text, and queries the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result. By combining the knowledge graph pattern with the large language model, it is possible to have a deeper understanding of the semantics and context of the question, thereby generating more accurate query statements and improving the quality of the retrieval results; it is able to handle complex knowledge requirements such as inter-entity calculations and internal logical relationship queries, making up for the shortcomings of traditional vector RAG libraries; and by making full use of the rich knowledge structure and relationship information in the knowledge graph, it is possible to dig out deeper knowledge and provide more comprehensive and accurate answers.

[0045] Figure 2This is a flow chart of another method for enhancing retrieval based on knowledge graph provided by the embodiment of the present disclosure. This embodiment further optimizes the above-mentioned method for enhancing retrieval based on knowledge graph on the basis of the above-mentioned embodiment. Figure 2 As shown, the method further includes:

[0046] Step 201: Obtain the knowledge graph model and query question text.

[0047] Step 202: Obtain predefined node identifiers and node relationship attribute identifiers, identify the nodes in the knowledge graph model and the relationships between the nodes based on the node identifiers and node relationship attribute identifiers, and obtain the target knowledge graph model.

[0048] Step 203: Based on the knowledge graph model, metadata is generated by obtaining each node, the relationship type between nodes, constraints and hierarchical conditions to obtain the target knowledge graph model.

[0049] After step 201, step 202 or step 203 may be executed. Figure 2 This is for illustrative purposes only and the present disclosure is not limited thereto.

[0050] Specifically, after obtaining the knowledge graph model and query text, before inputting the knowledge graph model into the large language model, the knowledge graph model needs to be normalized to ensure that it conforms to the format accepted by the large language model. For example, the nodes and relationships in the knowledge graph model are annotated with a specific markup language so that the large language model can clearly recognize them.

[0051] As an example, a specific JSON-LD extended format is designed; this format retains the universality of JSON-LD and adds specific annotations for knowledge graph patterns; for example, through customized "@schemaNode" and "@schemaRelation" attributes, the nodes and relationships in the knowledge graph pattern are clearly identified; as another example, a metadata description mechanism is developed to describe the structure and semantics of the knowledge graph pattern; this metadata not only contains the type information of the nodes and relationships in the knowledge graph pattern, but also includes the hierarchical relationships and constraints between them, such as the constraints between nodes, for example, the same drug cannot be both an indication drug and a contraindication drug for the same disease; thus, the large language model can use these metadata to quickly understand the overall structure and meaning of the knowledge graph pattern, so as to perform subsequent processing more effectively.

[0052] Step 204: Delete the stop words in the query question text to obtain a question text to be processed, perform part-of-speech tagging on the question text to obtain a target question text.

[0053] Specifically, the query text input also requires preprocessing, including stop word removal and part-of-speech tagging, to improve the large language model's accuracy in understanding the question. The preprocessed target question text, along with the normalized target knowledge graph schema, is then passed to the large language model in a specific input format (e.g., the format of common prompt terms such as role, requirement, restriction, task, input, output, etc.).

[0054] Step 205: The large language model traverses the target knowledge graph pattern based on the target question text, calculates the similarity between the target question text and each node in the target knowledge graph pattern based on the preset semantic matching model, and takes the nodes with similarity greater than or equal to the preset similarity threshold as the target nodes, and takes all target nodes and the relationships between target nodes as pattern information.

[0055] Specifically, the large language model filters knowledge graph pattern information. After receiving the target question text and the target knowledge graph pattern as input, the large language model first performs semantic understanding and analysis of the target question text. It then uses its pre-trained language understanding capabilities to identify the key concepts and relationships involved in the question. Concepts are generalizations of instances, such as type 2 diabetes and coronary heart disease, which are all referred to as "diseases." By feeding the target knowledge graph pattern to the large language model, it understands the content from both the conceptual and instance levels.

[0056] Specifically, based on its understanding of the target question text, the large language model traverses the target knowledge graph schema and, through a series of semantic matching algorithms and attention mechanisms, identifies nodes and relationships within the target knowledge graph schema that are relevant to the target question text. For example, for a target question text regarding "XX Company's product release time," the large language model will filter out nodes related to the entity "XX Company" and relationships related to "product release time," such as the attribute relationship "release time" from the target knowledge graph schema. Semantic matching algorithms and attention mechanisms are designed specifically for different business and application scenarios.

[0057] Specifically, during the screening process, in order to improve the accuracy and efficiency of screening, some optimization strategies will be adopted; for example, a similarity threshold will be set. When the semantic similarity between a certain part of the target knowledge graph pattern (such as the word data component, which is the target question text "Is data component a part of one of the plans for national data infrastructure construction") and the question exceeds the similarity threshold, it will be included in the screening results.

[0058] In some embodiments, the question category of the target question text is obtained, and the model parameters and similarity threshold of the semantic matching model are adjusted based on the question category.

[0059] Specifically, the question category can be understood as the complexity of the question. By setting the model parameters and similarity thresholds of different semantic matching models for different question categories, the processing accuracy can be further guaranteed while improving the processing efficiency.

[0060] Specifically, the filtering parameters and rules are dynamically adjusted according to the type and complexity of the target question text; for simple questions, a fast shallow matching strategy is adopted; for complex questions, a deeper reasoning and matching mechanism is enabled to ensure that relevant pattern information can be accurately filtered out in different scenarios; that is, if simple questions only require filtering parameter rules at the instance level, complex questions need to be filtered at the concept level.

[0061] Among them, the semantic matching algorithm based on deep learning uses a neural network with a Transformer architecture to build a semantic matching model; this semantic matching model takes the target question text and the pattern fragments of the target knowledge graph pattern as input, and calculates the semantic similarity between the question and the pattern fragment through a multi-head attention mechanism, thereby screening out the most relevant pattern information.

[0062] Therefore, we introduce the ontological reasoning mechanism (knowledge graph schema) of the knowledge graph. During the screening process, we not only consider direct semantic matching but also utilize the ontological reasoning rules (knowledge graph schema) of the knowledge graph. For example, if the knowledge graph schema defines "XX Company" as a subcategory of "Technology Company," when the target question text involves "Technology Company," ontological reasoning can also include schema information related to "XX Company" in the screening scope, improving the comprehensiveness of the screening.

[0063] Step 206: Perform named entity recognition on the target question text to obtain at least one entity, map the at least one entity to pattern information, and generate a query statement based on preset query logic.

[0064] Specifically, based on the filtered pattern information and target question text, the large language model will generate corresponding query statements; the generation process follows the grammatical rules of the knowledge graph query language. Taking SPARQL as an example, it needs to accurately construct triple patterns.

[0065] More specifically, the entities and relationships in the target question text are mapped to pattern information, that is, the nodes and relationships of the filtered target knowledge graph; then, based on the structure of the target knowledge graph and query requirements, the query logic is determined, such as whether multi-hop query is required, whether conditional filtering is required, etc.

[0066] For example, for the question of "the time when XX Company released mobile phone A", a SPARQL query statement similar to "SELECT?time WHERE {<XX Company><released product><mobile phone A>.<mobile phone A><release time>?time}" will be generated.

[0067] Step 207: Send the query statement to the knowledge graph database to query and obtain query entities, query entity relationships, and query entity attributes, and integrate the query entities, query entity relationships, and query entity attributes according to preset processing rules to obtain a query result.

[0068] Specifically, send the generated query statement to the knowledge graph database for execution; after receiving the query request, the knowledge graph database performs data retrieval in the knowledge graph database according to the requirements of the query statement.

[0069] Thus, after the retrieval is completed, the knowledge graph database will return a query result. These query results may be a series of entities, relationships, or attribute values. The large language model will process and integrate the returned results and convert them into an answer in natural language form; among them, integration is to give the query results to the large language model, and the context long window of the large language model can accept the text length.

[0070] When generating an answer, the large language model will also consider the integrity, accuracy, and readability of the answer. For example, if the query result contains multiple relevant pieces of information, the large language model will reasonably organize and sort this information to generate a smooth and well-organized answer and feedback it to the user.

[0071] In summary, compared with the vector-based RAG library, the present disclosure has the following advantages: higher retrieval accuracy, by combining the knowledge graph schema with the large language model, it can more deeply understand the semantics and background of the question, thereby generating more accurate query statements and improving the quality of retrieval results; supporting complex knowledge queries, capable of handling complex knowledge requirements such as entity calculations and internal logical relationship queries, making up for the deficiencies of traditional vector RAG libraries and broadening the application fields of RAG technology; better knowledge utilization, making full use of the rich knowledge structure and relationship information in the knowledge graph, enabling the RAG system to dig out deeper knowledge and provide more comprehensive and accurate answers.

[0072] Figure 3 FIG. is a schematic structural diagram of a retrieval enhanced generation device based on a knowledge graph provided by an embodiment of the present disclosure. This device can be implemented by software and / or hardware and is generally integrated in an electronic device. As Figure 3 shown, this device includes:

[0073] The acquisition module 301 is used to obtain the knowledge graph model and the query question text.

[0074] The first processing module 302 is used to process the knowledge graph model according to a preset format to obtain a target knowledge graph model.

[0075] The second processing module 303 is used to pre-process the query text to obtain a target question text.

[0076] The input module 304 is used to input the target question text and the target knowledge graph pattern into a preset large language model for processing, and obtain pattern information matching the target question text from the target knowledge graph pattern.

[0077] The generating module 305 is configured to generate a query statement based on the pattern information and the target question text.

[0078] The query module 306 is used to query the knowledge graph database corresponding to the knowledge graph model based on the query statement to obtain query results.

[0079] Optionally, the first processing module 302 is specifically used to: obtain predefined node identifiers and node relationship attribute identifiers; identify the nodes in the knowledge graph pattern and the relationships between the nodes based on the node identifiers and the node relationship attribute identifiers to obtain the target knowledge graph pattern.

[0080] Optionally, the first processing module 302 is specifically used to: generate metadata based on the knowledge graph model by obtaining each node, the relationship type between nodes, constraints and hierarchical conditions, and obtaining the target knowledge graph model.

[0081] Optionally, the second processing module 303 is specifically configured to: delete stop words in the query question text to obtain a question text to be processed; and perform part-of-speech tagging on the question text to be processed to obtain the target question text.

[0082] Optionally, the input module 304 is specifically used to: the large language model traverses the target knowledge graph pattern based on the target question text, calculates the similarity between the target question text and each node in the target knowledge graph pattern based on a preset semantic matching model, and takes the nodes with similarity greater than or equal to a preset similarity threshold as target nodes; and takes all the target nodes and the relationships between the target nodes as the pattern information.

[0083] Optionally, the device further includes: an acquisition and adjustment module, configured to acquire the question category of the target question text, and adjust the model parameters of the semantic matching model and the similarity threshold based on the question category.

[0084] Optionally, the generation module 305 is specifically used to: perform named entity recognition on the target question text to obtain at least one entity; map the at least one entity to the pattern information, and generate the query statement based on preset query logic.

[0085] Optionally, the query module 306 is specifically used to: send the query statement to the knowledge graph database to query and obtain the query entity, query entity relationship and query entity attribute; integrate the query entity, the query entity relationship and the query entity attribute according to preset processing rules to obtain the query result.

[0086] The knowledge graph-based retrieval enhancement generation device provided in the embodiments of the present disclosure can execute the knowledge graph-based retrieval enhancement generation method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0087] An embodiment of the present disclosure also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the knowledge graph-based retrieval enhancement generation method provided by any embodiment of the present disclosure.

[0088] Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 , which shows a schematic structural diagram of an electronic device 400 suitable for implementing the embodiments of the present disclosure. The electronic device 400 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0089] like Figure 4 As shown, electronic device 400 may include a processing device 401 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in ROM 402 (ROM is read-only memory) or programs loaded from storage device 408 into RAM 403 (RAM is random access memory). RAM 403 also stores various programs and data required for the operation of electronic device 400. Processing device 401, ROM 402, and RAM 403 are interconnected via bus 404. I / O interface 405 (I / O is input / output) is also connected to bus 404.

[0090] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0091] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the knowledge graph-based retrieval enhancement generation method of the embodiment of the present disclosure are executed.

[0092] It should be noted that the computer-readable medium described above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable storage media may include, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may 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. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wire, optical cable, RF (radio frequency), or any suitable combination thereof.

[0093] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.

[0094] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0095] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0096] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0097] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.

[0098] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0099] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0100] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:

[0101] processor;

[0102] a memory for storing instructions executable by the processor;

[0103] The processor is used to read the executable instructions from the memory and execute the instructions to implement any knowledge graph-based retrieval enhancement generation method provided in the present disclosure.

[0104] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium, which stores a computer program, and the computer program is used to execute any of the knowledge graph-based retrieval enhancement generation methods provided by the present disclosure.

[0105] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the present disclosure is not limited to technical solutions formed by specific combinations of the aforementioned technical features. It also encompasses other technical solutions formed by any combination of the aforementioned technical features or their equivalents, without departing from the scope of the above disclosure. For example, a technical solution formed by replacing the aforementioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0106] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0107] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A retrieval enhancement generation method based on knowledge graph, characterized in that: include: Obtain knowledge graph patterns and query question text; The knowledge graph pattern is processed according to a preset format to obtain a target knowledge graph pattern, and the query question text is preprocessed to obtain a target question text; wherein, the nodes and relationships in the knowledge graph pattern are annotated with a preset markup language; the processing of the knowledge graph pattern according to the preset format to obtain a target knowledge graph pattern includes: obtaining predefined node identifiers and node relationship attribute identifiers; identifying the nodes in the knowledge graph pattern and the relationships between nodes based on the node identifiers and the node relationship attribute identifiers to obtain the target knowledge graph pattern; or, based on the knowledge graph pattern, obtaining metadata for each node, the relationship type between nodes, constraints and hierarchical conditions to obtain the target knowledge graph pattern; The target question text and the target knowledge graph pattern are input into a preset large language model for processing, and pattern information matching the target question text is obtained from the target knowledge graph pattern; wherein, the large language model traverses the target knowledge graph pattern based on the target question text, calculates the similarity between the target question text and each node in the target knowledge graph pattern based on a preset semantic matching model, and takes the node with a similarity greater than or equal to a preset similarity threshold as the target node; all the target nodes and the relationship between the target nodes are taken as the pattern information; wherein, based on a semantic matching algorithm of deep learning, a neural network of a transformer architecture is used to construct the semantic matching model; the semantic matching model takes the pattern fragments of the target question text and the target knowledge graph pattern as input, calculates the semantic similarity between the target question text and the pattern fragments through a multi-head attention mechanism, and filters out the pattern information; A query statement is generated based on the pattern information and the target question text, and a query is performed in the knowledge graph database corresponding to the knowledge graph pattern based on the query statement to obtain a query result.

2. The method according to claim 1, characterized in that The preprocessing of the query text to obtain a target question text includes: Deleting stop words in the query text to obtain a question text to be processed; Part-of-speech tagging is performed on the question text to be processed to obtain the target question text.

3. The method according to claim 1, characterized in that The method further comprises: Obtain the question category of the target question text; The model parameters of the semantic matching model and the similarity threshold are adjusted based on the question category.

4. The method according to claim 1, wherein Generating a query statement based on the pattern information and the target question text includes: Performing named entity recognition on the target question text to obtain at least one entity; The at least one entity is mapped to the schema information, and the query statement is generated based on a preset query logic.

5. The method according to claim 1, characterized in that The query is performed in the knowledge graph database corresponding to the knowledge graph mode based on the query statement to obtain the query result, including: Sending the query statement to the knowledge graph database to query and obtain the query entity, query entity relationship and query entity attribute; The query entity, the query entity relationship and the query entity attribute are integrated according to a preset processing rule to obtain the query result.

6. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the knowledge graph-based retrieval enhancement generation method described in any one of claims 1-5 above.

7. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which is used to execute the knowledge graph-based retrieval enhancement generation method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Cypher-stack type alignment generation method and device based on large language model

    CN120104110A