A method for generating graph relationships, a terminal, and a storage medium.

CN115994229BActive Publication Date: 2026-08-14TSINGHUA UNIVERSITY +1
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-09
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0004]本发明的主要目的在于提供一种图谱关系生成方法、终端及计算机可读存储介质,旨在解决现有技术中对于知识图谱中概念之间关系的构建耗费大量资源和时间成本,其构建效率、准确度低的问题

Benefits of technology

[0037]在本发明实施例中,通过已训练生成式语言模型以及集束算法,可以根据待构建知识图谱的头概念以及获取的预设目标关系,得到头概念对应的若干候选尾概念,从而得到目标知识图谱。也就是说,一个头概念可以得到多个与之关系为预设目标关系的候选尾概念,无需遍历知识图谱中所有的概念对,很大程度的提高了构建图谱中概念之间关系的效率,显著提高了准确度和图谱概念的覆盖率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115994229B_ABST
    Figure CN115994229B_ABST
Patent Text Reader

Abstract

This invention provides a method, terminal, and storage medium for generating knowledge graph relationships. First, a preset target relationship is obtained, and head concepts in the knowledge graph to be constructed are determined. The preset target relationship represents the relationship between concepts. Then, based on the head concepts and the preset target relationship, a trained generative language model and a beam search algorithm are used to generate several candidate tail concepts corresponding to the head concepts. Finally, based on the head concepts, the preset target relationship, and the corresponding candidate tail concepts, the target knowledge graph is generated. This approach improves the efficiency of knowledge graph relationship generation and reduces resource waste.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method for generating graph relationships, a terminal, and a storage medium. Background Technology

[0002] A knowledge graph is essentially a semantic network that describes objective things in the form of a graph. A knowledge graph consists of nodes and edges. Nodes represent concepts and entities; concepts are abstract things, and entities are concrete things. A concept can be a set of entities with the same characteristics. Edges represent relationships between things. Therefore, establishing pairwise relationships between concepts is a key feature of constructing a knowledge graph.

[0003] Because the relationships between concepts in a knowledge graph often require strong professional knowledge, most current methods involve manually constructing these relationships. Furthermore, due to the vast number of concepts in a knowledge graph, spanning diverse fields, it is often necessary to hire experts from different domains or use crowdsourcing to manually determine the relationships between concepts. This process is resource-intensive, time-consuming, and prone to errors, resulting in low efficiency and accuracy. Summary of the Invention

[0004] The main objective of this invention is to provide a method, terminal, and computer-readable storage medium for generating graph relationships, aiming to solve the problems of high resource and time costs, low efficiency and accuracy in constructing relationships between concepts in knowledge graphs in the prior art.

[0005] To achieve the above objectives, embodiments of the present invention provide a method for generating map relationships, comprising:

[0006] Obtain preset target relationships and determine the head concepts in the knowledge graph to be constructed; the preset target relationships are used to represent the relationships between concepts.

[0007] Based on the head concept and the preset target relationship, a number of candidate tail concepts corresponding to the head concept are generated by a trained generative language model and a bundle search algorithm.

[0008] Based on the head concept, the preset target relationship, and the corresponding candidate tail concept, a target knowledge graph is generated.

[0009] Optionally, generating a target knowledge graph based on the head concept, the preset target relationship, and the corresponding candidate tail concepts specifically includes:

[0010] Based on the head concept, the preset target relationship, and the corresponding candidate tail concept, generate the corresponding first triplet and second triplet;

[0011] The first triplet consists of the head concept, the preset target relation, and the corresponding candidate tail concept; the second triplet masks the preset target relation in the first triplet and consists of the head concept, the preset relation mask token, and the corresponding candidate tail concept.

[0012] Based on the second triplet, the predicted target relationship between the head concept and the candidate tail concept is generated through the first pre-trained generative language model.

[0013] Based on the first triplet and the corresponding third triplet, a target triplet is determined, and a target knowledge graph is generated based on the target triplet.

[0014] The third triplet includes: the head concept, the prediction target relation, and the candidate tail concept.

[0015] Optionally, determining the target triplet based on the first triplet and the corresponding third triplet, and generating the target knowledge graph based on the target triplet, specifically includes:

[0016] Determine the semantic similarity between the first triplet and the corresponding third triplet;

[0017] If the semantic similarity is greater than a preset threshold, the third triplet or the first triplet will be used as the target triplet.

[0018] A target knowledge graph is generated based on the target triples.

[0019] Optionally, after determining the semantic similarity between the first triplet and the corresponding third triplet, the method further includes:

[0020] If the semantic similarity is less than the preset threshold, delete the first triplet corresponding to the third triplet.

[0021] Optionally, the step of generating the predicted target relationship between the head concept and the candidate tail concept based on the second triplet through the first pre-trained generative language model specifically includes:

[0022] Based on the second triplet, the predicted target relationship between the head concept and the candidate tail concept is generated using the first pre-trained generative language model and a greedy search algorithm.

[0023] Optionally, based on the head concept and the preset target relationship, a number of candidate tail concepts corresponding to the head concept are generated using a trained generative language model and a beam search algorithm, specifically including:

[0024] Generate a dictionary tree based on all concepts in the knowledge graph to be constructed;

[0025] Based on the head concept and the preset target relationship, the trained generative language model and the bundle search algorithm are used to search from the root node of the dictionary tree to generate several candidate tail concepts corresponding to the head concept.

[0026] The candidate tail concept is a concept in the knowledge graph to be constructed.

[0027] Optionally, the trained generative language model is generated in the following manner:

[0028] Multiple sample triples are extracted from the sample knowledge graph; wherein, the sample triple includes: a sample head concept, a sample target relation, and a corresponding sample tail concept;

[0029] Based on the sample head concept and sample target relationship in the sample triplet, the generated tail concept corresponding to the sample head concept is obtained through the second pre-trained generative language model.

[0030] The second pre-trained generative language model is adjusted based on the sample tail concept and the generation tail concept corresponding to the sample head concept.

[0031] The process continues to execute the step of obtaining the generative tail concept corresponding to the sample head concept in the next sample triplet based on the sample head concept and sample target relationship in the next sample triplet through the second pre-trained generative language model, until the second pre-trained generative language model meets the preset conditions and a trained generative language model is obtained.

[0032] Optionally, adjusting the second pre-trained generative language model based on the sample tail concept and the generated tail concept corresponding to the sample head concept specifically includes:

[0033] Based on the sample tail concept and the generation tail concept corresponding to the sample head concept, the loss function value of the second pre-trained generative language model is determined by the log-likelihood function.

[0034] The second pre-trained generative language model is adjusted based on the loss function value.

[0035] To achieve the above objectives, embodiments of the present invention also provide a terminal, including: a processor and a memory; the memory stores a computer-readable program that can be executed by the processor; when the processor executes the computer-readable program, it implements the steps in the graph relation generation method described above.

[0036] In addition, to achieve the above objectives, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the steps in the graph relation generation method as described in any of the above claims.

[0037] In this embodiment of the invention, by using a trained generative language model and a bundle algorithm, several candidate tail concepts corresponding to the head concept can be obtained based on the head concept of the knowledge graph to be constructed and the acquired preset target relationship, thereby obtaining the target knowledge graph. In other words, a head concept can generate multiple candidate tail concepts with a preset target relationship, eliminating the need to traverse all concept pairs in the knowledge graph. This significantly improves the efficiency of constructing relationships between concepts in the graph, and substantially increases accuracy and the coverage of graph concepts. Attached Figure Description

[0038] Figure 1 A flowchart of a graph relationship generation method provided in an embodiment of the present invention;

[0039] Figure 2 A flowchart of step S102 provided in an embodiment of the present invention;

[0040] Figure 3 A flowchart for generating a trained generative language model provided in an embodiment of the present invention;

[0041] Figure 4 A flowchart of step S103 provided in an embodiment of the present invention;

[0042] Figure 5 A flowchart of step S403 provided in an embodiment of the present invention;

[0043] Figure 6 This is a schematic diagram of the terminal structure provided in an embodiment of the present invention. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, 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 are not intended to limit the invention.

[0045] In existing technologies, the construction of relationships between concepts in knowledge graphs is often done manually. This manual method is resource-intensive and suffers from low efficiency and accuracy. Therefore, this invention provides a graph relationship generation method, terminal, and storage medium to efficiently and accurately generate relationships between concepts, thereby constructing a knowledge graph.

[0046] The invention will be further explained below with reference to the accompanying drawings and through description of the embodiments.

[0047] Figure 1 The flowchart of the graph relationship generation method provided in the embodiments of the present invention is as follows: Figure 1 As shown, the map relationship generation method provided in this embodiment of the invention may include at least the following steps:

[0048] S101, Obtain the preset target relationship and determine the head concept in the knowledge graph to be constructed.

[0049] The knowledge graph to be constructed may be a graph that only contains concepts and has no relationships between any concepts; or it may be a graph that has corresponding relationships between some concepts but is not complete. The knowledge graph to be constructed is not specifically limited in the embodiments of the present invention.

[0050] In this embodiment of the invention, any concept can be selected as the head concept from the knowledge graph to be constructed. The aforementioned preset target relationship can be selected from a preset target relationship library, which stores multiple preset target relationships, such as: because of, is a, etc. That is, the present invention does not need to rely on the existing relationship network in the knowledge graph to be constructed for graph relationship inference. In other words, even when the knowledge graph to be constructed only contains concepts and has no relationship network, it does not rely on specific text to determine the relationship between a specific pair of concepts, and has a wider range of applicability.

[0051] Furthermore, the execution subject of the graph relationship generation method proposed in this embodiment of the invention can be a terminal device (e.g., a mobile phone, tablet computer, etc.) or a server (e.g., a cloud server, etc.). This embodiment of the invention does not specifically limit the execution subject, as long as it can execute the graph relationship generation method provided in this embodiment. In this embodiment, a server can be described as the execution subject.

[0052] S102, based on the above head concept and the preset target relationship, generate several candidate tail concepts corresponding to the head concept through the trained generative language model and the bundle search algorithm.

[0053] Among them, the trained generative language model can be pre-stored on the server.

[0054] Specifically, the head concept and the preset target relationship can be concatenated to obtain the corresponding input text. This input text is then fed into a trained generative language model to generate several candidate tail concepts corresponding to the head concept using the trained generative language model and a beam search algorithm. These "several" can include at least one.

[0055] In this embodiment of the invention, the trained generative language model can be an autoregressive language model that can directly predict the output based on the input.

[0056] In this embodiment of the invention, by using a trained generative language model and a beam search algorithm, several candidate tail concepts with a preset target relationship to the head concept can be obtained. That is, through step S102, each head concept can generate multiple corresponding candidate tail concepts, improving the efficiency of constructing relationships between concepts in the graph. Furthermore, since in this embodiment of the invention, it is not necessary to map concepts and relationships to a vector space, but rather to generate the corresponding target tail concepts in the form of text, computer resources are further saved, and the efficiency of graph relationship generation is improved.

[0057] like Figure 2 As shown, step S102 above can be achieved through at least the following steps:

[0058] S201, Generate a dictionary tree based on all the concepts in the knowledge graph to be constructed.

[0059] S202, based on the head concept and the preset target relationship, a number of candidate tail concepts corresponding to the head concept are generated by searching from the root node of the above dictionary tree through a trained generative language model and a bundle search algorithm.

[0060] In this embodiment of the invention, the aforementioned preset dictionary tree can be constructed based on the concept names of all concepts in the knowledge graph to be constructed. By searching from the root node to the leaf node in this dictionary tree, a concept in the knowledge graph to be constructed can be obtained.

[0061] Because the beam search algorithm may generate tail concepts that do not belong to the knowledge graph to be constructed, this embodiment of the invention constructs a corresponding dictionary tree based on all concepts in the knowledge graph to be constructed. During the process of generating candidate tail concepts using a trained generative language model and the beam search algorithm, the leaf nodes searched from the root node of the dictionary tree yield a concept (i.e., a word) in the knowledge graph to be constructed. This restricts the beam search to the knowledge graph to be constructed, avoiding situations where candidate tail concepts from the head concepts do not belong to the knowledge graph to be constructed, further improving the accuracy of graph relationships in the knowledge graph to be constructed.

[0062] It should be noted that, in this embodiment of the invention, even without using a pre-defined dictionary tree, the generated candidate tail concepts can be compared with the concepts in the knowledge graph to be constructed to exclude candidate tail concepts that do not belong to the knowledge graph, thereby ensuring accuracy. However, due to the large number of concepts in the knowledge graph, this method requires more time and computational resources compared to using a dictionary tree.

[0063] Furthermore, in some embodiments of the present invention, such as Figure 3 As shown, a trained generative language model can be achieved through at least the following steps:

[0064] S301, extract multiple sample triples from the sample knowledge graph.

[0065] The sample triplet includes: the sample head concept, the sample target relationship, and the corresponding sample tail concept.

[0066] The sample knowledge graph in this embodiment of the invention includes both sample concepts and sample target relationships between sample concepts, and multiple sample triples can be extracted from the sample knowledge graph.

[0067] For example, for a sample target relation r, the sample triples in the sample knowledge graph are: in, For the concept of sample header, Let r be the sample tail concept, and let r be the sample target relationship between the sample head concept and the sample tail concept.

[0068] In some embodiments of the present invention, the aforementioned preset target relationship library can be composed of sample target relationships in the sample knowledge graph, that is, the sample target relationships can be used as the aforementioned preset target relationships.

[0069] It should be noted that the number of the above sample knowledge graphs is at least one, and the sample knowledge graphs can be different from each other.

[0070] S302, based on the sample head concept and sample target relationship in the sample triplet, the second pre-trained generative language model generates the generative tail concept corresponding to the sample head concept.

[0071] Specifically, the sample head concept and sample target relation in the sample triple are concatenated to obtain the corresponding input text (e.g., The input text is used as a training sample and fed into the second pre-trained generative language model. Through the second pre-trained generative language model, the generated tail concept is obtained that is related to the sample head concept.

[0072] S303, adjust the second pre-trained generative language model according to the sample tail concept corresponding to the sample head concept and the generation tail concept.

[0073] Specifically, the loss function value of the second pre-trained generative language model can be determined by using the log-likelihood function based on the sample tail concept corresponding to the sample head concept and the generation tail concept; then, the second pre-trained generative language model can be adjusted based on the loss function value.

[0074] Furthermore, the second pre-trained generative language model can be adjusted based on the loss function value, which may involve adjusting the weights of the second pre-trained generative language model accordingly.

[0075] The loss function value of the second pre-trained generative language model is determined by the log-likelihood function, which can be achieved using the following formula:

[0076]

[0077] in, represent The h-th text token or text in the array, p represents the number of text tokens or texts, and L(θ) is the value of the loss function.

[0078] In this embodiment of the invention, the loss function value of the second pre-trained generative language model is calculated by the log-likelihood function, which can maximize the target text given the input text.

[0079] S304, continue executing the step of obtaining the generative tail concept corresponding to the sample head concept in the next sample triplet based on the sample head concept and sample target relationship of the next sample triplet through the second pre-trained generative language model, until the second pre-trained generative language model meets the preset conditions and the trained generative language model is obtained.

[0080] In this embodiment of the invention, the sample head concept and sample target relationship in the next sample triplet can be concatenated to obtain the next input text. The next input text is then input into the adjusted second pre-trained generative language model to generate the generative tail concept corresponding to the sample head concept. The loss function value of the second pre-trained generative language model is further calculated for adjustment until the second pre-trained generative language model meets the preset conditions, thus obtaining the trained generative language model.

[0081] The aforementioned preset conditions may be that the loss function value is less than the corresponding preset threshold, or that the number of training iterations reaches a preset number. These conditions can be selected or combined according to the actual situation, and are not specifically limited in this embodiment of the invention.

[0082] In this embodiment of the invention, a second pre-trained generative language model is trained using sample triples from a sample knowledge graph to obtain a trained generative language model. Compared to using a machine learning model to determine the relationship between two concepts in a given text, this embodiment trains the model using an existing sample knowledge graph, eliminating the need for a given text as an information source and covering all possible combinations of concepts within the graph.

[0083] S103 generates a target knowledge graph based on the head concept, the preset target relationship, and the corresponding candidate tail concepts.

[0084] For the concepts e, e∈ε in the knowledge graph to be constructed and the pre-defined target relations r, r∈R that need to be completed, where the concept set ε={e1,e2,Ke} n} and the relation set R = {r1, r2, Kr} m Let ε represent the set of existing concepts and relationships to be generated in the knowledge graph to be constructed. Concatenating e and r to obtain cat(e,r) is input to the trained generative language model, yielding corresponding candidate tail concepts. By iterating through each concept e in the ε set as the head concept, the relationships between concepts in the knowledge graph to be constructed can be built, generating the target knowledge graph.

[0085] For example, a knowledge graph to be constructed has three concepts: apple, fruit, and banana. These three concepts are designated as head concepts, with preset target relations of "is a type of" and "contain," respectively. Using the method provided in the above embodiment, the following occurs: when apple is the head concept and the preset target relation is "is a type of," the corresponding candidate tail concept is "fruit"; when apple is the head concept and the preset target relation is "contain," there are no candidate tail concepts; when banana is the head concept and the preset target relation is "is a type of," the corresponding candidate tail concept is "fruit"; when banana is the head concept and the preset target relation is "contain," there are no candidate tail concepts; when fruit is the head concept and the preset target relation is "is a type of," there are no candidate tail concepts; when fruit is the head concept and the preset target relation is "contain," the corresponding candidate tail concepts are both "apple" and "banana." In this way, the relationships between all concepts in the knowledge graph to be constructed can be obtained, thereby generating the target knowledge graph.

[0086] The graph relation generation method provided in this invention, through a trained generative language model and a bundle algorithm, can obtain several candidate tail concepts corresponding to the head concept of the knowledge graph to be constructed and the obtained preset target relation, thereby obtaining the target knowledge graph. In other words, a head concept can generate multiple candidate tail concepts with a preset target relation, without needing to traverse all concept pairs in the knowledge graph, greatly improving the efficiency of constructing relations between concepts in the graph, and significantly improving accuracy and graph concept coverage. Furthermore, large graphs typically contain millions or even tens of millions of concepts. Traversing all possible concept combinations requires computation time on the order of N squared, which is practically unsustainable. The graph relation generation method provided in this invention can output multiple generated tail concepts for each concept and the relation to be completed in the graph, thus forming multiple candidate triples for each head concept. When one target head concept generates K candidate tail concepts, for a graph with N concepts, the complexity is O(KN) instead of O(N^2), demonstrating high efficiency in large-scale knowledge graph relation generation tasks.

[0087] In practical use, it is inevitable that discrepancies will occur among the tail concepts corresponding to the head concept generated in the above manner. To further improve the accuracy of the graph relationship generation method provided in this embodiment of the invention, such as... Figure 4 As shown, step S103 provided in this embodiment of the invention can be achieved through at least the following steps:

[0088] S401, based on the head concept, the preset target relationship and the corresponding candidate tail concept, generate the corresponding first triplet and second triplet.

[0089] The first triplet consists of a head concept, a predefined target relation, and a corresponding candidate tail concept; the second triplet masks the predefined target relation in the first triplet and consists of a head concept, a predefined relation mask token, and a corresponding candidate tail concept. For example, the first triplet (e h ,r,e t ), where e h Let r be the head concept, r be the predefined target relation, and e be the head concept. t For candidate tail concepts; : second triplet (e h , <mask>,e t ), where e h For the target head concept, <mask>For the preset relation mask token (model mask token), e t This is a candidate tail concept.

[0090] In this embodiment of the invention, the preset target relationship in the first triplet can be replaced with a preset relationship mask token, that is, the preset target relationship between the head concept and the corresponding candidate tail concept in the first triplet is masked, thereby generating the second triplet.

[0091] S402, based on the second triplet, through the first pre-trained generative language model, generate the predicted target relationship between the head concept and the candidate tail concept in the second triplet.

[0092] Specifically, the head concept, the preset relation mask token, and the corresponding candidate tail concept in the second triplet are concatenated into the corresponding input text according to a preset order. For example, where e h For the concept of head, <mask>e is a preset relation mask token t This is the candidate tail concept. The input text is fed into the first pre-trained generative language model to generate the text masked by the preset relation mask token, which is the predicted target relation.

[0093] Furthermore, based on the second triplet, the predicted target relationship between the head concept and the corresponding candidate tail concept can be generated through the first pre-trained generative language model and the greedy search algorithm.

[0094] The greedy search algorithm ensures that the generated prediction target relationship is the optimal relationship between the head concept and the candidate tail concept.

[0095] In this embodiment of the invention, the first pre-trained generative language model is an untrained generative language model that verifies the function of the first triple by mimicking the language masking task format of the pre-trained language model. The basic model structure of the first pre-trained generative language model and the second pre-trained generative language model can be the same (e.g., T5, GPT2) or different (e.g., the first pre-trained generative language model can also be the biomedical generative language model BioBART). No specific limitation is made in this embodiment of the invention.

[0096] S403, Based on the first triplet and the corresponding third triplet, determine the target triplet, and generate the target knowledge graph based on the target triplet.

[0097] The third triplet includes: head concept, prediction target relationship, and candidate tail concept.

[0098] Furthermore, such as Figure 5 As shown, step S403 in this embodiment of the invention can be implemented through at least the following steps:

[0099] S501, determine the semantic similarity between the first triplet and the corresponding third triplet.

[0100] Furthermore, the semantic similarity between the first triplet and the corresponding third triplet can be determined through a series of corresponding heuristic rules. In this embodiment of the invention, the head concept, the preset target relation, and the corresponding candidate tail concept in the first triplet can be concatenated in a preset order to obtain the first triplet text. Similarly, the third triplet can be concatenated to obtain the third triplet text. The semantic similarity between the first triplet text and the third triplet text can be determined through a series of preset heuristic rules, which serves as the semantic similarity between the first triplet and the corresponding third triplet.

[0101] For example, a first triplet is (e h ,r',e t The corresponding third triplet is (e h ,r,e t ), where e h Let r' be the head concept, r' be the prediction target relation, and e be the head concept. t Let r be the candidate tail concept, and r be the preset target relation. The first triplet text obtained by concatenating them is s = cat(e h ,r,e t The third triplet text is s' = cat(e h ,r',e t ).

[0102] S502, if the semantic similarity is greater than a preset threshold, the third triplet or the first triplet is taken as the target triplet.

[0103] S503, if the semantic similarity is less than a preset threshold, delete the first triplet corresponding to the third triplet.

[0104] S504, Generate a target knowledge graph based on the target triplet.

[0105] For example, if the target relation r' is "because of" and the preset target relation r is "is a", then the generated target relation contradicts the preset target relation, and the target relation r' is deleted. If the target relation r' is "is a typeof" or "is a variant of", and the preset target relation r is "is a", then the target relation r' matches the preset target relation r, and the preset target relation r' is retained to generate a prediction triple. For example, for the head concept "fruit" and the tail concept "apple", if the target relation r' is "is a", the prediction "fruit is a apple" is generated. If the target relation r' is "contains", a prediction triple like "fruit contains apple" is generated. When training a generative language model, semantic similarity is used to exclude "fruit is a apple" and retain "fruit contains apple" (which does not indicate "is a"), deleting the "is a" target relation between the head concept "fruit" and the tail concept "apple".

[0106] In this embodiment of the invention, a second triplet is generated by generating a first triplet that masks the preset target relationship. Then, a predicted target relationship is generated based on the second triplet and the first pre-trained generative language model, thereby obtaining the corresponding third triplet. The accuracy of the first triplet is determined by the semantic similarity between the first triplet and the corresponding third triplet. Inaccurate first triplets are deleted, thereby improving the accuracy of the generated target knowledge graph.

[0107] Based on the above-described graph relationship generation method, this embodiment of the invention also provides a terminal, such as... Figure 6 As shown, it includes at least one processor 60; a display screen 61; and a memory 62, and may also include a communications interface 63 and a bus 64. The processor 60, display screen 61, memory 62, and communications interface 63 can communicate with each other via the bus 64. The display screen 61 is configured to display a preset user guide interface in the initial setup mode. The communications interface 63 can transmit information. The processor 60 can call logical instructions in the memory 62 to execute the graph relationship generation method described in the above embodiment.

[0108] Furthermore, the logical instructions in the aforementioned memory 62 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.

[0109] The memory 62, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, such as program instructions or modules corresponding to the methods in the embodiments of this disclosure. The processor 60 executes functional applications and data processing by running the software programs, instructions, or modules stored in the memory 62, thereby implementing the methods in the above embodiments.

[0110] The memory 62 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal. Furthermore, the memory 62 may include high-speed random access memory (RAM) and non-volatile memory. Examples include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks; these can also be transient storage media.

[0111] Based on the above-described graph relation generation method, this embodiment of the invention also provides a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the steps in the graph relation generation method described in the above embodiments.

[0112] Furthermore, the specific process of loading and executing multiple instruction processors in the aforementioned storage medium and terminal has been described in detail in the above method, and will not be repeated here.

[0113] Secondly, the terminal and storage medium provided in the embodiments of the present invention correspond one-to-one with the method. Therefore, the device and medium also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the terminal and storage medium will not be repeated here.

[0114] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0115] Of course, those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.). The program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The computer-readable storage medium can be a memory, magnetic disk, optical disk, etc.

[0116] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.< / mask> < / mask> < / mask>

Claims

1. A method for generating graph relationships, characterized in that, The method for generating the map relationships includes: Obtain preset target relationships and determine the head concepts in the knowledge graph to be constructed; the preset target relationships are used to represent the relationships between concepts. Based on the head concept and the preset target relationship, a number of candidate tail concepts corresponding to the head concept are generated by a trained generative language model and a bundle search algorithm. Based on the head concept and the preset target relationship, a number of candidate tail concepts corresponding to the head concept are generated using a trained generative language model and a beam search algorithm, specifically including: Generate a dictionary tree based on all concepts in the knowledge graph to be constructed; Based on the head concept and the preset target relationship, the trained generative language model and the bundle search algorithm are used to search from the root node of the dictionary tree to generate several candidate tail concepts corresponding to the head concept. The candidate tail concept is a concept in the knowledge graph to be constructed. Based on the head concept, the preset target relationship, and the corresponding candidate tail concept, a target knowledge graph is generated; The step of generating a target knowledge graph based on the head concept, the preset target relationship, and the corresponding candidate tail concept specifically includes: Based on the head concept, the preset target relationship, and the corresponding candidate tail concept, generate the corresponding first triplet and second triplet; The first triplet consists of the head concept, the preset target relation, and the corresponding candidate tail concept; the second triplet masks the preset target relation in the first triplet and consists of the head concept, the preset relation mask token, and the corresponding candidate tail concept. Based on the second triplet, the predicted target relationship between the head concept and the candidate tail concept is generated through the first pre-trained generative language model. Based on the first triplet and the corresponding third triplet, a target triplet is determined, and a target knowledge graph is generated based on the target triplet. The third triplet includes: the head concept, the prediction target relation, and the candidate tail concept; The step of determining a target triplet based on the first triplet and the corresponding third triplet, and generating a target knowledge graph based on the target triplet, specifically includes: Determine the semantic similarity between the first triplet and the corresponding third triplet; If the semantic similarity is greater than a preset threshold, the third triplet or the first triplet will be used as the target triplet. Generate a target knowledge graph based on the target triples; After determining the semantic similarity between the first triplet and the corresponding third triplet, the method further includes: If the semantic similarity is less than the preset threshold, delete the first triplet corresponding to the third triplet.

2. The method according to claim 1, characterized in that, The step of generating the predicted target relationship between the head concept and the candidate tail concept based on the second triplet through the first pre-trained generative language model specifically includes: Based on the second triplet, the predicted target relationship between the head concept and the candidate tail concept is generated using the first pre-trained generative language model and a greedy search algorithm.

3. The method according to claim 1, characterized in that, The trained generative language model is generated in the following way: Multiple sample triples are extracted from the sample knowledge graph; wherein, the sample triple includes: a sample head concept, a sample target relation, and a corresponding sample tail concept; Based on the sample head concept and sample target relationship in the sample triplet, the generated tail concept corresponding to the sample head concept is obtained through the second pre-trained generative language model. The second pre-trained generative language model is adjusted based on the sample tail concept and the generation tail concept corresponding to the sample head concept. The process continues to execute the step of obtaining the generative tail concept corresponding to the sample head concept in the next sample triplet based on the sample head concept and sample target relationship in the next sample triplet through the second pre-trained generative language model, until the second pre-trained generative language model meets the preset conditions and a trained generative language model is obtained.

4. The method according to claim 3, characterized in that, The step of adjusting the second pre-trained generative language model based on the sample tail concept and the generation tail concept corresponding to the sample head concept specifically includes: Based on the sample tail concept and the generation tail concept corresponding to the sample head concept, the loss function value of the second pre-trained generative language model is determined by the log-likelihood function. The second pre-trained generative language model is adjusted based on the loss function value.

5. A terminal, characterized in that, The terminal includes a processor and a memory; the memory stores a computer-readable program that can be executed by the processor; when the processor executes the computer-readable program, it implements the steps in the graph relation generation method as described in any one of claims 1-4.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the steps in the graph relation generation method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Text generation method and device based on knowledge reasoning, medium and computing equipment

    CN112214608A

  • Entity information processing method and device, electronic equipment and medium

    CN114254642A

  • Relationship triple generation method and device, electronic device and storage medium

    CN114461810A

  • Knowledge injection method of pre-training language model and corresponding interaction system

    CN114936287A