Triplet search retrieval enhanced method and device for question answering of incomplete knowledge graph

By employing a triplet-based retrieval enhancement method, a multi-step reasoning process is generated using a large language model, and positive and negative sample pairs are used to fine-tune the sentence encoder. This addresses the problem of inaccurate answers caused by the incompleteness of knowledge graphs, and improves the accuracy of knowledge graph question answering and its ability to handle complex questions.

CN120994764BActive Publication Date: 2026-07-24ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG UNIV
Filing Date
2025-06-27
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing knowledge graph question answering methods are unable to provide sufficient knowledge for complex questions when faced with incomplete questions, resulting in inaccurate answers, especially in the fields of medicine, finance, science, education, or business, where existing technologies struggle to obtain effective answers by retrieving relevant sets of triples.

Method used

We employ a triplet-based retrieval enhancement method. This method generates a multi-step reasoning process through a large language model, utilizes a thinking-retrieval-generation framework, and combines prompt templates to decompose and encode questions. We construct positive and negative sample pairs to fine-tune the sentence encoder, thereby enhancing the knowledge graph question-answering capability of the large language model. We select relevant triplets by calculating the embedding similarity of triplets.

Benefits of technology

It significantly improves the reasoning ability and answer accuracy of large language models in incomplete knowledge graph question answering, enabling them to provide more reliable answers to complex questions and enhancing knowledge graph question answering support in medical, financial, scientific, educational, or business fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994764B_ABST
    Figure CN120994764B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on triple search enhancement's incomplete knowledge graph question and answer method and device, comprising: using thinking-retrieval-generation framework, based on incomplete knowledge graph and prompt template, input question is generated by large language model to answer question with multi-step reasoning process, each step reasoning includes in order: the thinking of question decomposition, the action type of execution and the observation result after executing action;When action type is retrieval, utilize sentence encoder to filter the triple of subgraph with high similarity with question as observation result, when action type is generation, these triples are used as context to guide the generation of observation result;Utilize the positive and negative sample pairs of (question, triple) for constructing from question to answer multi-hop path set to fine-tune sentence encoder and act on two action types of retrieval and generation.The application can effectively improve the knowledge graph question and answer performance in each field of medical, financial, scientific, educational or commercial field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing technology, specifically relating to a method and apparatus for question answering incomplete knowledge graphs based on triplet retrieval enhancement. Background Technology

[0002] Current large language models (LLMs) possess powerful language processing capabilities and demonstrate excellent performance in various natural language processing tasks, such as text generation, machine translation, and sentiment analysis. However, they often suffer from knowledge gaps and illusions. Knowledge graphs, as a structured knowledge representation method, contain rich and accurate factual knowledge. The synergy between the two has enabled the rapid development of knowledge graph question answering.

[0003] Currently, knowledge graph question answering methods mainly include those based on semantic parsing, information retrieval, and large language models. Semantic parsing-based methods convert user-posed questions into logical forms and then use query languages ​​like SPARQL to accurately find answers within the knowledge graph. For example, in the medical field, when a patient inquires about typical symptoms of a disease, this method can quickly retrieve relevant information from the medical knowledge graph, providing a reference for doctors' diagnoses. Information retrieval-based methods construct specific question subgraphs and locate answers through subgraph analysis. For example, in the business field, when a user searches for information about a product, this method can obtain product-related subgraphs based on the product mentioned in the user's question and retrieve detailed information such as product specifications, price, and user reviews from the product knowledge graph. Large language model-based methods are often used in conjunction with the first two types of methods. They can use large language models to convert complex questions into more manageable logical forms or directly generate answers. For example, in the education field, this combination can provide students with personalized learning Q&A services. When a student raises a question about a specific subject knowledge point, the large language model can assist the knowledge graph in quickly providing an accurate answer.

[0004] However, existing knowledge graph question answering methods rely on a key assumption: the triples used to answer a question must be contained within the knowledge graph. However, since knowledge graphs are often constructed automatically or semi-automatically, their completeness is difficult to guarantee. In scientific research, newly discovered knowledge may not yet be updated in the knowledge graph in a timely manner, leading to inaccurate answers to related questions. To address this issue, the GoG (Generate-on-Graph) model proposes an incomplete knowledge graph question answering task, where the knowledge graph may not contain all the triples needed to answer a question. This model treats a large language model as both an agent and a knowledge graph, retrieving or generating useful triples to answer complex questions. However, the set of triples obtained by the GoG model through retrieving relevant relation sets and entity sets may still not provide sufficient knowledge for the question. For example, when answering the question about the release location of a movie, if the knowledge graph only contains information about the movie's genre, retrieving entity-related relations and tail entity sets will not effectively solve the problem. This is because it is difficult to deduce valid triples related to the release location based solely on existing genre information and entity relations, thus failing to provide an accurate answer. Therefore, a more comprehensive and efficient information retrieval mechanism is needed for question answering based on large language model knowledge graphs. Summary of the Invention

[0005] In view of the above, the purpose of this invention is to provide a method and apparatus for incomplete knowledge graph question answering based on triplet retrieval enhancement. This method uses a large language model to generate thought processes, actions, and post-action observations for decomposing a question. When performing an action, relevant triples are retrieved at the triplet level. An existing sentence encoder is fine-tuned by constructing (question, triplet) sample pairs based on the question-to-answer path. The fine-tuned encoder encodes the question and triples and calculates their embedding representation similarity, identifying triples with high similarity as relevant. The fine-tuned encoder can simultaneously handle both retrieval and generation actions. This method further enhances the reasoning ability and answer accuracy of large language model knowledge graph question answering, thereby providing more reliable support for knowledge graph question answering in various fields such as medicine, finance, science, education, and commerce.

[0006] To achieve the above-mentioned objectives, the present invention provides the following technical solution:

[0007] In a first aspect, the present invention provides an incomplete knowledge graph question-answering method based on triplet retrieval enhancement, comprising the following steps:

[0008] Using a thinking-retrieval-generation framework, a multi-step reasoning process is generated to answer the input question by using a large language model based on incomplete knowledge graphs and prompt templates in the fields of medicine, finance, science, education, or business. Each step of reasoning includes, in sequence: thinking to decompose the question, the type of action to be performed, and the observation results after performing the action.

[0009] When the action type is retrieval, the triples in the subgraph that are highly similar to the question are used as the observation results. When the action type is generation, the triples in the subgraph that are highly similar to the question are used as context to guide the generation of observation results. Specifically, the question and the triples in the subgraph are encoded separately using a sentence encoder, and the similarity score of their embedding representations is calculated to select the triples with high similarity.

[0010] We construct positive and negative sample pairs in the form of (question, triple) using a set of multi-hop paths from question to answer. We then fine-tune the sentence encoder based on these positive and negative sample pairs and apply the fine-tuned sentence encoder to the two action types of retrieval and generation.

[0011] Preferably, the prompt template used to generate a multi-step reasoning process includes:

[0012] This section describes instructions that specify tasks to be completed through alternating steps such as thinking, acting, and observing. It introduces instructions for inputs, outputs, and goals of three action types: retrieval, generation, and completion. It also provides sample inputs and outputs for an incomplete knowledge graph question-answering task, where the input is the question and the output includes the thinking, acting, and observing content required to answer the question.

[0013] Preferably, when the action type is generation, using triples in the subgraph that have a high similarity to the question as context to guide the generation of observation results includes:

[0014] Based on the given generation prompt template, triples in subgraphs with high similarity scores are used as the context of the question to guide the generation of new triples that help answer the question. Based on the verification prompt template and these new triples, reliable triples are further generated as the final observation of the generation action.

[0015] Preferably, the step of constructing positive and negative sample pairs in the form of (question, triplet) using the set of multi-hop paths from question to answer includes:

[0016] Construct positive and negative sample pairs using the set of two-hop paths from the question to the answer, when the path is... At that time, obtain positive sample pairs (question, triplet): and Generate (question, triplet) negative sample pairs: and ;

[0017] in, The first part of the problem Path, , and Representing the question entity, intermediate entity, and answer entity respectively. and Indicates a relationship. This refers to the set of relationships that have appeared in the path set corresponding to the problem. and Let these represent the entity set and relation set of the incomplete knowledge graph, respectively. To indicate a problem, Representing relations or The triples in the negative sample pair are not included in the path's relation set to ensure that they are irrelevant to the problem. Indicates from according to and The tail entities selected from the defined set of tail entities. Indicates from according to and The header entities selected from a defined set of header entities.

[0018] Preferably, the sentence encoder fine-tuned based on positive and negative sample pairs includes:

[0019] Based on the constructed positive and negative sample pairs in the form of (question, triple), the existing sentence encoder is fine-tuned using the cosine similarity loss function.

[0020] Preferably, the generation prompt template for generating new triples includes:

[0021] The instructions specify the task as generating new triples, along with input and output sample examples, where the input includes the corresponding thought process and contextual triples selected based on similarity, and the output is the generated triples.

[0022] Preferably, the verification prompt template for generating reliable triples includes:

[0023] This is used to specify the task as filtering triples, and provides sample input and output examples. The input includes the question, a list of candidate triples generated multiple times, and the output is the final triples obtained from the generation action.

[0024] Secondly, embodiments of the present invention also provide an incomplete knowledge graph question answering device based on triplet retrieval enhancement, which is implemented using the above-mentioned incomplete knowledge graph question answering method based on triplet retrieval enhancement, including: a question reasoning module, a triplet interaction module, and an encoder optimization module;

[0025] The problem reasoning module is used to answer questions by using a thinking-retrieval-generation framework and generating a multi-step reasoning process based on an incomplete knowledge graph and prompt templates in the fields of medicine, finance, science, education, or business through a large language model. Each reasoning step includes, in sequence: thinking about decomposing the problem, the type of action to be performed, and the observation results after performing the action.

[0026] The triplet interaction module is used to select triplets with high similarity to the question in the subgraph as observation results when the action type is retrieval, and to select triplets with high similarity to the question in the subgraph as context to guide the generation of observation results when the action type is generation. Specifically, the question and the triplets in the subgraph are encoded using a sentence encoder, and the similarity score of their embedding representations is calculated to select the triplets with high similarity.

[0027] The encoder optimization module is used to construct positive and negative sample pairs in the form of (question, triple) using the set of multi-hop paths from question to answer, and to fine-tune the sentence encoder based on the positive and negative sample pairs. The fine-tuned sentence encoder is then applied to two action types: retrieval and generation.

[0028] Thirdly, embodiments of the present invention also provide an electronic device, including a memory and one or more processors, wherein the memory is used to store a computer program, and the processor is used to implement the above-described incomplete knowledge graph question answering method based on triplet retrieval enhancement when executing the computer program.

[0029] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a computer, implements the above-described incomplete knowledge graph question-answering method based on triplet retrieval enhancement.

[0030] Compared with the prior art, the beneficial effects of the present invention include at least the following:

[0031] This invention introduces a thinking-retrieval-generation framework, enabling large-scale models to simulate the multi-step reasoning process of humans and more accurately understand the intent of questions. During the reasoning process, the question is meticulously decomposed and considered, and targeted retrieval is performed using an incomplete knowledge graph. Triples are filtered using similarity scores to obtain information on triples highly relevant to the question. These triples are then used as anchors for further mining, and entities and relationships related to the question but not directly included in the original knowledge graph are introduced using a large language model. This compensates for the deficiencies of the knowledge graph, providing more comprehensive and richer information support for subsequent reasoning and guiding the generation of more accurate answers. Furthermore, by constructing positive and negative sample pairs to fine-tune the sentence encoder, the diversity of triples and matching effects are further optimized, enhancing the model's ability to handle complex questions. This invention effectively solves the problem of poor performance of existing technologies in complex reasoning scenarios, significantly improving the reasoning and question-answering capabilities of large-scale models in complex reasoning scenarios such as healthcare, finance, science, education, and commerce, providing users with more reliable and intelligent reasoning and question-answering services. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a flowchart illustrating the incomplete knowledge graph question answering method based on triplet retrieval enhancement provided in this embodiment of the invention.

[0034] Figure 2 This is a schematic diagram of the structure of the incomplete knowledge graph question answering device based on triplet retrieval enhancement provided in an embodiment of the present invention;

[0035] Figure 3 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the scope of protection of this invention.

[0037] The inventive concept of this invention is as follows: Addressing the problem that existing incomplete knowledge graph question answering methods may fail to provide sufficient knowledge for complex questions when retrieving relevant triplet sets, thus affecting the accuracy of answers, this invention provides an incomplete knowledge graph question answering method and apparatus based on triplet retrieval enhancement. It constructs (question, triplet) sample pairs based on the path from question to answer, fine-tunes an existing sentence encoder using these sample pairs, and uses the fine-tuned sentence encoder to obtain the embedding representations of the question and triplets during retrieval and generation actions. By calculating the similarity of the embedding representations, it selects triplets with high similarity, thereby improving the performance of incomplete knowledge graph question answering.

[0038] like Figure 1 As shown, the embodiment provides a question-answering method for incomplete knowledge graphs based on triplet retrieval enhancement, including the following steps:

[0039] S1 uses a thinking-retrieval-generation framework to generate a multi-step reasoning process to answer the input question by using a large language model based on an incomplete knowledge graph and prompt templates in the fields of medicine, finance, science, education, or business. Each step of reasoning includes, in sequence: thinking about decomposing the question, the type of action to be performed, and the observation results after performing the action.

[0040] In this embodiment, step S1 uses a large language model to generate a multi-step reasoning process for the input question based on a prompt template. Specifically, the prompt template for generating the multi-step reasoning process includes: instructions that clearly define the task to be completed through alternating steps such as thinking, action, and observation; instructions that introduce the input, output, and objective of the three action types: retrieval, generation, and completion; and sample input and output examples for an incomplete knowledge graph question-answering task, where the input is the question and the output includes the thinking, action, and observation content required to answer the question.

[0041] Specifically, the instructions used to specify the task are as follows:

[0042] "Solve problems using a combination of thinking, action, and observation. You should think about breaking down the problem before taking action. There are three types of actions: (1) Retrieve [question|triple 1|triple 2|...], search and return the most relevant triples on the provided knowledge graph. You should only provide the question in the first retrieval, and in subsequent retrievals you can provide the question and extract the most relevant triples from the previous observation. The number of triples should not exceed 5. (2) Generate [thinking], generate triples related to thinking. These triples may come from internal knowledge or reasoning given triples. (3) Complete [answer 1|answer 2|...], return the answer to the question and end the task. The answer should be the entity name that appears in the retrieval or generated observation. If the answer is unknown, the output is Complete [unknown]. Here are some specific examples."

[0043] Taking question answering in the education field as an example, one example of the input and output samples for an incomplete knowledge graph question answering task is as follows:

[0044] Question: What did Person A study in university?

[0045] Question 1: I need to find out what Person A studied in university;

[0046] Action 1: Search for [What did Person A study at university?];

[0047] Observation 1: Person A, Occupation: Lawyer;

[0048] Person A, Occupation: Politician;

[0049] Person A, nationality, a certain country;

[0050] Reflection 2: The above information does not answer what Person A studied in university. I need to find out more about what Person A studied in university.

[0051] Action 2: Search [What did Person A study in university? | Person A, Occupation, Lawyer | Person A, Occupation, Politician];

[0052] Observation 2: Person A, political party, a certain party;

[0053] Person A, Religion, a certain religion;

[0054] Character A, child, character B;

[0055] Reflection 3: The above information does not help answer what Person A studied in university. I need to generate more triples based on the existing information and internal knowledge to answer this question.

[0056] Action 3: Generate [What does Character A study at university?];

[0057] Observation 3: Person A, majoring in history;

[0058] Person A, majoring in political science;

[0059] Reflection 4: Person A studies history and political science at university;

[0060] Action 4: Complete [History|Political Science]".

[0061] S2, when the action type is retrieval, the triples in the subgraph that are highly similar to the question are used as the observation results. When the action type is generation, the triples in the subgraph that are highly similar to the question are used as context to guide the generation of observation results. Specifically, the question and the triples in the subgraph are encoded using a sentence encoder, and the similarity score of their embedding representations is calculated to select the triples with high similarity.

[0062] In the embodiment, in step S2, when the action type is generation, based on the given generation prompt template, the triples with high similarity scores in the subgraph are used as the context of the question to guide the generation of new triples that help answer the question, and based on the verification prompt template and these new triples, reliable triples are further generated as the final observation result of the generation action.

[0063] Taking the film and entertainment industry as a specific example in the business field, if the question is "Where is the release location of film series 1?", the first step after consideration is to retrieve "[Where is the release location of film series 1?]", using a fine-tuned sentence encoder to encode and calculate the similarity score of the triples in the subgraph corresponding to the entity "film series 1" in the question. The observation result is that the three triples with the highest similarity scores after calculation are (film series 2, release location, a certain country), (film series 3, release location, a certain country), and (film series 2, distribution company, a certain film company). Based on this observation and the internal knowledge of the large model, the second step of consideration concludes that the release location of film series 1 is the same as that of film series 2, which is a certain country, and the corresponding action is to complete "[a certain country]".

[0064] If the question is "Where does Person E go to school?", and the question cannot be answered by searching, the large model needs to calculate the similarity between the thought and the embedded representation obtained by the fine-tuned sentence encoder of the retrieved triples, select the triples with high similarity to the current thought as known triples, and generate new triples to assist the answer based on the thought and known triples.

[0065] Specifically, the generated prompt template is as follows:

[0066] "Given a known triplet, generate a new triplet to help answer the question you are currently thinking about. The entity that generates the triplet should appear in your thinking."

[0067] Think about it: What is the time zone of region Z?

[0068] Given a triple: region Z is located in a certain place in a certain country;

[0069] A certain country and location, time zone, Pacific Standard Time;

[0070] Generate a triple: region Z, time zone, Pacific Standard Time.

[0071] Specifically, to reduce the randomness of generation, after generating three triples, the verification prompt template is as follows:

[0072] "Given the triples generated by a large language model, please select the triples that are most relevant to the question and most likely to be the correct answer. Output only the selected triples, without any redundant words;"

[0073] Question: What is the time zone of region Z?

[0074] Generate triples:

[0075] ### 1

[0076] Region Z, time zone, Pacific Standard Time;

[0077] ### 2

[0078] A certain country and location, time zone, Pacific Standard Time;

[0079] Region Z, time zone, Pacific Standard Time;

[0080] ### 3

[0081] Region Z, Time Zone, Eastern Standard Time;

[0082] Answer: Region Z, Time Zone, Pacific Standard Time.

[0083] The final answer triple is the observation result of the generated action.

[0084] In this way, the fine-tuned sentence encoder can simultaneously perform both retrieval and generation actions.

[0085] S3 utilizes a set of multi-hop paths from question to answer to construct positive and negative sample pairs in the form of (question, triplet). Based on the positive and negative sample pairs, the sentence encoder is fine-tuned, and the fine-tuned sentence encoder is applied to two action types: retrieval and generation.

[0086] In this embodiment, since conventional sentence encoders typically produce similar triples that include entities mentioned in the question, positive and negative sample pairs are constructed using a set of two-hop paths from the question to the answer to fine-tune the sentence encoder used in step S2 in order to enhance the diversity of triples.

[0087] In this embodiment, when constructing (question, triple) sample pairs, for example, if the question is "What is the name of person J's brother?", and the answer is person L, a two-hop path can be found as (person J, father, person K, child, person L). Based on this path, the positive sample pairs are (What is the name of person J's brother?, (person J, father, person K)) and (What is the name of person J's brother?, (person K, child, person L)). When constructing negative samples, the tail entity or head entity of the triple remains unchanged, and the relation is replaced with a relation that does not appear in the path to ensure that the replaced triple cannot effectively answer the question. The resulting negative samples are (What is the name of person J's brother?, (region Y, birthplace / birth person, person K)) and (What is the name of person J's brother?, (person K, nationality, country)).

[0088] Based on constructed (question, triplet) positive and negative sample pairs, the existing transformer-based sentence encoder msmarco-distilbert-base-tas-b is fine-tuned using a cosine similarity loss function. Loss function Defined as:

[0089] ,

[0090] in, The number of samples is equal for both positive and negative samples. The labels for the triples are 1 for positive samples and 0 for negative samples. Let represent the embeddings of the problem and the triples, respectively. The elements of each triple are directly concatenated as input. This indicates the calculation of cosine similarity.

[0091] Based on the same inventive concept, this invention also provides an incomplete knowledge graph question answering device 200 based on triplet retrieval enhancement, including: a question reasoning module 210, a triplet interaction module 220, and an encoder optimization module 230.

[0092] The question reasoning module 210 is used to answer questions by using a thinking-retrieval-generation framework and generating multi-step reasoning processes based on incomplete knowledge graphs and prompt templates in the fields of medicine, finance, science, education, or business through a large language model. Each step of reasoning includes, in sequence: thinking about decomposing the question, the type of action to be performed, and the observation results after performing the action.

[0093] The triplet interaction module 220 is used to select triplets with high similarity to the question in the subgraph as observation results when the action type is retrieval, and to select triplets with high similarity to the question in the subgraph as context to guide the generation of observation results when the action type is generation. Specifically, the question and the triplets in the subgraph are encoded separately using a sentence encoder, and the similarity score of their embedding representations is calculated to select the triplets with high similarity.

[0094] The encoder optimization module 230 is used to construct positive and negative sample pairs in the form of (question, triple) using the set of multi-hop paths from question to answer. Based on the positive and negative sample pairs, the sentence encoder is fine-tuned and applied to the two action types of retrieval and generation.

[0095] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, including a memory and one or more processors, wherein the memory is used to store a computer program, and the processor is used to implement the above-described incomplete knowledge graph question answering method based on triplet retrieval enhancement when executing the computer program.

[0096] like Figure 3 As shown, the electronic device provided in this embodiment, at the hardware level, includes not only a processor and memory, but also internal buses, network interfaces, memory, and other hardware required for business operations. The memory is non-volatile memory. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to implement the triplet-based retrieval-enhanced incomplete knowledge graph question-answering method described in steps S1-S3 above. Of course, besides software implementation, this invention does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.

[0097] Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a computer, implements the above-described incomplete knowledge graph question-answering method based on triplet retrieval enhancement.

[0098] In this embodiment, computer-readable storage media includes both permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient media, such as modulated data signals and carrier waves.

[0099] It should be noted that the question-answering device, electronic device, and computer-readable storage medium based on triplet retrieval enhancement for incomplete knowledge graphs provided in the above embodiments all belong to the same inventive concept as the question-answering method based on triplet retrieval enhancement for incomplete knowledge graphs. For details of their implementation process, please refer to the embodiments of the question-answering method based on triplet retrieval enhancement for incomplete knowledge graphs, which will not be repeated here.

[0100] The specific embodiments described above illustrate the technical solution and beneficial effects of the present invention in detail. It should be understood that the above description is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A question-answering method for incomplete knowledge graphs based on triplet retrieval enhancement, characterized in that, Includes the following steps: Using a think-retrieve-generate framework, this approach leverages a large language model based on incomplete knowledge graphs from the medical, financial, scientific, educational, or business domains, along with prompt templates, to generate multi-step reasoning processes to answer input questions. Each reasoning step sequentially includes: thinking to break down the question, the type of action to be performed, and the observation result after performing the action. The prompt templates used to generate the multi-step reasoning process include: instructions that clarify the task requires alternating steps of thinking, action, and observation; instructions that introduce the input, output, and goal of the three action types: retrieval, generation, and completion; and sample input and output examples of the incomplete knowledge graph question-answering task. The input is the question, and the output includes the thinking, action, and observation content required to answer the question. When the action type is retrieval, triples with high similarity to the question in the subgraph are used as observations. When the action type is generation, triples with high similarity to the question in the subgraph are used as context to guide the generation of observations. This includes: based on a given generation prompt template, using triples in the subgraph with high similarity scores as context for the question to guide the generation of new triples that help answer the question, and further generating reliable triples based on a verification prompt template and these new triples as the final observations of the generation action. In this case, the question and the triples in the subgraph are encoded using a sentence encoder, and the similarity scores of their embedding representations are calculated to select the triples with high similarity. Constructing positive and negative sample pairs in the form of (question, triple) using a set of multi-hop paths from question to answer, including: constructing positive and negative sample pairs using a set of two-hop paths from question to answer, when the path is... At that time, obtain positive sample pairs (question, triplet): and Generate (question, triplet) negative sample pairs: and ,in, The first part of the problem Path, , and Representing the question entity, intermediate entity, and answer entity respectively. and Indicates a relationship. This refers to the set of relationships that have appeared in the path set corresponding to the problem. and Let these represent the entity set and relation set of the incomplete knowledge graph, respectively. To indicate a problem, Representing relations or The triples in the negative sample pair are not included in the path's relation set to ensure that they are irrelevant to the problem. Indicates from according to and The tail entities selected from the defined set of tail entities. Indicates from according to and The head entities are selected from the defined set of head entities; the sentence encoder is fine-tuned based on positive and negative sample pairs, and the fine-tuned sentence encoder is applied to the two action types of retrieval and generation.

2. The incomplete knowledge graph question answering method based on triplet retrieval enhancement according to claim 1, characterized in that, The sentence encoder fine-tuned based on positive and negative sample pairs includes: Based on the constructed positive and negative sample pairs in the form of (question, triple), the existing sentence encoder is fine-tuned using the cosine similarity loss function.

3. The incomplete knowledge graph question answering method based on triplet retrieval enhancement according to claim 1, characterized in that, The generation prompt templates for generating new triples include: The instructions specify the task as generating new triples, along with input and output sample examples, where the input includes the corresponding thought process and contextual triples selected based on similarity, and the output is the generated triples.

4. The incomplete knowledge graph question answering method based on triplet retrieval enhancement according to claim 1, characterized in that, Verification prompt templates for generating reliable triples include: This is used to specify the task as filtering triples, and provides sample input and output examples. The input includes the question, a list of candidate triples generated multiple times, and the output is the final triples obtained from the generation action.

5. A question-answering device for incomplete knowledge graphs based on triplet retrieval enhancement, implemented using the question-answering method for incomplete knowledge graphs based on triplet retrieval enhancement as described in any one of claims 1 to 4, characterized in that, include: Problem reasoning module, triplet interaction module, encoder optimization module; The problem reasoning module is used to answer questions by using a thinking-retrieval-generation framework and generating a multi-step reasoning process based on an incomplete knowledge graph and prompt templates in the fields of medicine, finance, science, education, or business through a large language model. Each reasoning step includes, in sequence: thinking about decomposing the problem, the type of action to be performed, and the observation results after performing the action. The triplet interaction module is used to select triplets with high similarity to the question in the subgraph as observation results when the action type is retrieval, and to select triplets with high similarity to the question in the subgraph as context to guide the generation of observation results when the action type is generation. Specifically, the question and the triplets in the subgraph are encoded using a sentence encoder, and the similarity score of their embedding representations is calculated to select the triplets with high similarity. The encoder optimization module is used to construct positive and negative sample pairs in the form of (question, triple) using the set of multi-hop paths from question to answer, and to fine-tune the sentence encoder based on the positive and negative sample pairs. The fine-tuned sentence encoder is then applied to two action types: retrieval and generation.

6. An electronic device comprising a memory and one or more processors, the memory being used to store a computer program, characterized in that, The processor is configured to implement the incomplete knowledge graph question answering method based on triplet retrieval enhancement as described in any one of claims 1 to 4 when executing a computer program.

7. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a computer, it implements the incomplete knowledge graph question answering method based on triplet retrieval enhancement as described in any one of claims 1 to 4.