CN113407736A - Knowledge graph detection method and related device, electronic equipment and storage medium - Google Patents

Knowledge graph detection method and related device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113407736A
CN113407736A CN202110957835.6A CN202110957835A CN113407736A CN 113407736 A CN113407736 A CN 113407736A CN 202110957835 A CN202110957835 A CN 202110957835A CN 113407736 A CN113407736 A CN 113407736A
Authority
CN
China
Prior art keywords
entity
sample
node
representation
entities
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110957835.6A
Other languages
Chinese (zh)
Inventor
李直旭
马桂林
邓宸博
张大雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Iflytek Suzhou Technology Co Ltd
Original Assignee
Iflytek Suzhou Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Iflytek Suzhou Technology Co Ltd filed Critical Iflytek Suzhou Technology Co Ltd
Priority to CN202110957835.6A priority Critical patent/CN113407736A/en
Publication of CN113407736A publication Critical patent/CN113407736A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a knowledge graph detection method, a related device, electronic equipment and a storage medium, wherein the knowledge graph detection method comprises the following steps: acquiring a knowledge graph and a target triple in the knowledge graph; the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity; obtaining entity representation of the node entity based on a plurality of reference entities of the node entity; the plurality of reference entities comprise node entities, adjacent entities of the node entities, first entities and second entities, wherein the first entities represent entity classes of the node entities, and the second entities represent entity classes of the adjacent entities; and obtaining a detection result of the target triple based on the entity representation of the target head entity, the relationship representation of the target relationship and the entity representation of the target tail entity. By the scheme, the detection precision of the knowledge graph can be improved.

Description

Knowledge graph detection method and related device, electronic equipment and storage medium
Technical Field
The present application relates to the field of natural language processing technologies, and in particular, to a method and an apparatus for knowledge graph detection, an electronic device, and a storage medium.
Background
With the development of information technology and the advent of the big data age, the industry and academia began to focus on how to organize mass data into conveniently usable forms. Knowledge maps can organize unstructured or semi-structured data into structured data by means of automated construction, and are therefore of great interest. With the development of natural language processing technology, automatic construction and development of knowledge maps are rapidly developed, and large-scale knowledge maps such as DBpedia and Wikidata are produced by the automatic construction technology.
At present, due to the fact that an automatic extraction tool is not perfect, the quality of the knowledge graph is inevitably reduced along with the enlargement of the scale of the knowledge graph, and therefore downstream applications based on the knowledge graph, such as a recommendation system, an entity link and a question and answer system, can be influenced by the quality of the knowledge graph. The inventor of the application finds that the existing knowledge graph detection mode still has the problem of insufficient detection precision, so that the quality of the knowledge graph is difficult to ensure. In view of this, how to improve the detection accuracy of the knowledge graph becomes an urgent problem to be solved.
Disclosure of Invention
The technical problem mainly solved by the application is to provide a knowledge graph detection method, a related device, electronic equipment and a storage medium, and the knowledge graph detection precision can be improved.
In order to solve the above technical problem, a first aspect of the present application provides a method for detecting a knowledge graph, including: acquiring a knowledge graph and a target triple in the knowledge graph; the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity; obtaining entity representation of the node entity based on a plurality of reference entities of the node entity; the plurality of reference entities comprise node entities, adjacent entities of the node entities, first entities and second entities, wherein the first entities represent entity classes of the node entities, and the second entities represent entity classes of the adjacent entities; and obtaining a detection result of the target triple based on the entity representation of the target head entity, the relationship representation of the target relationship and the entity representation of the target tail entity.
In order to solve the above technical problem, a second aspect of the present application provides a knowledge-map detecting apparatus, including: the system comprises a knowledge acquisition module, an entity representation module and a result detection module, wherein the knowledge acquisition module is used for acquiring a knowledge graph and a target triple in the knowledge graph; the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity; the entity representation module is used for obtaining entity representation of the node entity based on a plurality of reference entities of the node entity; the plurality of reference entities comprise node entities, adjacent entities of the node entities, first entities and second entities, wherein the first entities represent entity classes of the node entities, and the second entities represent entity classes of the adjacent entities; and the result detection module is used for obtaining a detection result of the target triple based on the entity representation of the target head entity, the relation representation of the target relation and the entity representation of the target tail entity.
In order to solve the above technical problem, a third aspect of the present application provides an electronic device, including a memory and a processor, which are coupled to each other, wherein the memory stores program instructions, and the processor is configured to execute the program instructions to implement the method for knowledge-graph detection in the first aspect.
In order to solve the above technical problem, a fourth aspect of the present application provides a computer-readable storage medium storing program instructions executable by a processor, the program instructions being configured to implement the method for knowledge-graph detection in the first aspect.
In the scheme, the knowledge graph and the target triple in the knowledge graph are obtained, the knowledge graph comprises a plurality of node entities and entity relations connecting the node entities, the target triple comprises a target head entity, a target tail entity and target relations between the target head entity and the target tail entity, the entity representation of the node entities is obtained based on a plurality of reference entities of the node entities, the plurality of reference entities comprise the node entities, adjacent entities of the node entities, a first entity and a second entity, the first entity represents the entity class of the node entities, the second entity represents the entity class of the adjacent entities, on the basis, the detection result of the target triple is obtained based on the entity representation of the target head entity, the relation representation of the target relation and the entity representation of the target tail entity, and because the node entities and the adjacent entities thereof can be referred in the knowledge representation process of the node entities, the entity type of the node entity and the entity type of the adjacent entity can be referred, so that the accuracy of knowledge representation can be improved, detection is carried out on the basis, and the improvement of the detection accuracy of the knowledge graph is facilitated.
Drawings
FIG. 1 is a schematic flow chart diagram of an embodiment of a method for knowledge-graph testing of the present application;
FIG. 2 is a schematic diagram of an embodiment of a knowledge-graph;
FIG. 3 is a process diagram of one embodiment of a representation of an acquiring entity;
FIG. 4 is a schematic flow diagram of an embodiment of training a knowledge extraction model;
FIG. 5 is a block diagram of an embodiment of a knowledge-graph detection apparatus;
FIG. 6 is a block diagram of an embodiment of an electronic device of the present application;
FIG. 7 is a block diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The following describes in detail the embodiments of the present application with reference to the drawings attached hereto.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, interfaces, techniques, etc. in order to provide a thorough understanding of the present application.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two.
Referring to fig. 1, fig. 1 is a schematic flow chart of an embodiment of a method for knowledge-graph detection according to the present application. Specifically, the method may include the steps of:
step S11: and acquiring the knowledge graph and the target triple in the knowledge graph.
In the embodiment of the disclosure, the knowledge graph includes a plurality of node entities and entity relationships connecting the node entities, and the target triple includes both a target head entity and a target tail entity and a target relationship therebetween. It should be noted that the knowledge graph is a structured semantic network, knowledge in the knowledge graph is organized into a triple form, a triple may include a head entity, a relationship, and a tail entity, for convenience of description, the head entity may be denoted as h, the relationship may be denoted as r, the tail entity may be denoted as t, and the triple may be denoted as (h, r, t). For example, the unstructured text "samara authored by lomicro and juliet" may be formulated as a triplet (samara, authored by lomicro and juliet), and so on for other cases, which are not exemplified herein.
In particular, there are two node entities in the knowledge-graph to which an entity relationship connects and the entity relationship may constitute a triplet form. Referring to fig. 2, fig. 2 is a schematic diagram of an embodiment of a knowledge-graph. It should be noted that fig. 2 only illustrates one possible knowledge graph in the practical application process, and does not limit the actual network structure of the knowledge graph. As shown in fig. 2, a circle represents a node entity, and a text in the circle represents a specific name of the node entity, which may specifically include but is not limited to: a person name, a place name, a facility name, a movie name, a book name, a country name, and the like, but are not limited thereto. For convenience of description, specific names of node entities are denoted herein by "01", "02", and the like. In addition, the straight-line arrow represents an entity relationship, and the text attached to the straight-line arrow represents a relationship category of the entity relationship, which may specifically include but is not limited to: dependency, affinity, containment, inheritance, etc., and are not limited herein. For convenience of description, the relationship category of the entity relationship is represented by "r 1", "r 2", and the like. The direction of the straight line arrow indicates the relationship direction of the entity relationship, i.e. in a triplet, usually from the head entity to the tail entity. For example, taking "inheritance relationship" as an example, the unstructured text "hanwu liu chester inherits from hanjing emperor liu ji" can be formalized into a triple (hanwu liu chester inherits from hanjing emperor liu ji "), i.e., the head entity is" hanwu emperor liu chester ", the entity relationship is" inheritance self ", the tail entity is" hanjing emperor liu ji ", so that the node entity" hanjing emperor liu chester "points to the node entity" hanjing emperor liu ji "in the knowledge graph, and the relationship category is" inheritance self "; similarly, the unstructured text "the chinese scenery emperor liu qi inherits from the chinese emperor liu qi" may be formatted as a triplet (the chinese scenery emperor liu qi inherits from the chinese emperor liu qi), i.e., the head entity is "the chinese scenery emperor liu qi", the entity relationship is "inherit from", the tail entity is "the chinese emperor liu qi", so that the node entity "the chinese scenery emperor liu qi" points to the node entity "the chinese emperor liu qi" in the knowledge graph, the relationship category is "inherit from", and so on, which is not exemplified herein.
In one implementation scenario, the target triples may be triples that are pre-specified in the knowledge-graph. For example, in the process of detecting the knowledge graph, a manual rough quality inspection may be performed first, and on the basis of the rough quality inspection, a plurality of triples in the knowledge graph may be manually specified as target triples. For example, there is a triple (shakebaba, creation, pride and prejudice) in the knowledge graph, and the manual quality inspection cannot determine whether the triple is correct, so that the triple can be used as a target triple, that is, the target head entity is "shakebaba", the target tail entity is "pride and prejudice", and the target relationship is "creation". Other cases may be analogized, and no one example is given here.
In one implementation scenario, the target triples may also be all triples in the knowledge-graph. For example, in the knowledge-graph detection process, manual quality control is not relied on at all, and all triples in the knowledge-graph are directly used as target triples.
Step S12: an entity representation of the node entity is derived based on a number of reference entities of the node entity.
In the embodiment of the disclosure, the plurality of reference entities include a node entity, an adjacent entity of the node entity, a first entity and a second entity, and the first entity represents an entity category of the node entity and the second entity represents an entity category of the adjacent entity. It should be noted that the neighboring entity of the node entity is the node entity directly connected to the node entity. With continued reference to fig. 2, the node entities "01" are directly connected to the node entities "02" to "13" respectively, that is, the adjacent entities of the node entities "01" include the node entities "02" to "13", while for the node entities "02", only the node entities "01" are indirectly connected to the node entities "13" through the node entities "01", so that the adjacent entities of the node entities "02" are the node entities "01". Other cases may be analogized, and no one example is given here. Further, the entity category represents a category to which the node entity belongs. Specifically, for a "people" class node entity, its category may include, but is not limited to, people identities, etc., and an entity category such as the node entity "shakespeare" may include writers, poems, etc.; alternatively, for a "works" class node entity, its category may include, but is not limited to, literature genres, etc., and the entity category such as node entity "romano and juliet" may be drama. Other cases may be analogized, and no one example is given here. In addition, for each node entity in the knowledge-graph, the entity representation of the node entity can be obtained based on a plurality of reference entities of the node entity, so that the entity representation of each node entity in the knowledge-graph can be obtained.
In one implementation scenario, for each node entity in the knowledge-graph, initial representations of several reference entities may be obtained, and the initial representations of the several reference entities are fused to obtain an entity representation of the node entity.
In a specific implementation scenario, the initial representation may be obtained from a pre-training language model, where the pre-training language model may include, but is not limited to BERT (Bidirectional Encoder from Transformers), and the specific obtaining process may refer to technical details of the pre-training language model such as BERT, which are not described herein again; or, the entity names of the reference entities may also be converted by word vector tools such as word2vec and the like to obtain initial representations of the respective reference entities, and the specific conversion process may refer to technical details of the word vector tools such as word2vec and the like, which are not described herein again; or, different reference entities may also be encoded by using an encoding method such as one-hot to obtain an initial representation of each reference entity, and the specific encoding process may refer to technical details of an encoding scheme such as one-hot, which is not described herein again. It should be noted that the initial representation may be specifically expressed by a D-dimensional vector, and a specific numerical value of the vector dimension D may be set according to actual application requirements, for example, the value may be set to 256-dimensional, 512-dimensional, and the like, which is not limited herein.
In another specific implementation scenario, for each node entity, the initial representations of the respective reference entities of the node entity may be averaged for fusion to obtain the entity representation of the node entity.
In one implementation scenario, in order to improve the accuracy of entity representation, for each node entity, the initial representations of several reference entities may be weighted and fused by using the weight parameters of the several reference entities to obtain an entity representation of the node entity, and the relationship attribute of the entity relationship between the reference entities and the node is related to the weight parameter of the reference entity. In the above manner, for each node entity, the initial representations of the plurality of reference entities are continuously weighted and fused by using the weight parameters of the plurality of reference entities, so that the entity representation of the node entity is obtained, and the relationship attribute of the entity relationship between the reference entities and the node is related to the weight parameters of the reference entities, so that the reference entities can be fused to different degrees, and the accuracy of entity representation is improved.
In a specific implementation scenario, the relationship attribute may specifically include at least one of a relationship type and a relationship direction, and the specific meaning of the relationship type and the relationship direction may refer to the foregoing related description, which is not described herein again. Furthermore, in order to improve the accuracy of the representation of the entity as much as possible, the relationship attributes may include both a relationship category and a relationship direction, i.e., for two relationship attributes, as long as the relationship category is different from either of the relationship directions, the two relationship attributes are also different, and the two relationship attributes are the same if and only if the relationship category is the same as the relationship direction. Please continue to refer to fig. 2, for example, the entity relationship "r 1" between the node entity "01" and the node entity "02", and the entity relationship "r 1" between the node entity "01" and the node entity "03", both relationship categories are "r 1", the relationship directions are from the node entity "01" to the adjacent entities, so the relationship attributes of the two are the same; or, for the entity relationship "r 1" between the node entity "01" and the node entity "02" and the entity relationship "r 2" between the node entity "01" and the node entity "05", although both relationship directions point from the node entity "01" to its neighboring entity, but one of the relationship categories is "r 1" and one is "r 2", so that the relationship attributes of the two are different; or, for the entity relationship "r 1" between the node entity "01" and the node entity "02" and the entity relationship "r 1" between the node entity "01" and the node entity "07", the relationship categories of the two are both "r 1", but the relationship direction is one from the node entity "01" to the adjacent entity, and the other to the node entity "01", so the relationship attributes of the two are different; alternatively, the entity relationship "r 1" between the node entity "01" and the node entity "02" and the entity relationship "r 2" between the node entity "01" and the node entity "13" are different in relationship attribute because the relationship attributes are different between the two because the relationship types are different and the relationship directions are different. Other cases may be analogized, and no one example is given here.
In a specific implementation scenario, the entity relationship between the first entity and the node entity is a predetermined relationship, that is, the entity relationship between the entity category of the node entity and the node entity is a predetermined relationship. Referring to fig. 3, fig. 3 is a process diagram of an embodiment of acquiring an entity. As shown in fig. 3, unlike other entities, the preset relationship between the first entity and the node entity may be specifically set to isA, so that the entity relationship between other reference entities and the node entity may be distinguished. For example, special characters (e.g., # or the like) may be employed to represent relationship categories.
In a specific implementation scenario, an entity relationship between a node entity in the plurality of reference entities and the node entity may also be a preset relationship, that is, the entity relationship between the node entity and the node entity may be a preset relationship, in order to distinguish the entity relationship between the first entity and the node entity, the entity relationship between the first entity and the node entity may be referred to as a first preset relationship, and the entity relationship between the node entity and the node entity may be referred to as a second preset relationship, and a relationship attribute of the first preset relationship is different from a relationship attribute of the second preset relationship. With continued reference to FIG. 3, as mentioned above, the predetermined relationship between the node entity and itself can be specifically denoted as self-loop, and specifically, different special characters (e.g., @) can be used to denote the relationship between the node entity and itself.
In one specific implementation scenario, the entity relationship between the second entity and the node entity is the same as the entity relationship between the adjacent entity corresponding to the second entity and the node entity, and here the second entity represents the entity category of the corresponding adjacent entity. With continuing reference to fig. 2, taking node entity "01" and node entity "02" as examples, in the process of calculating the entity representation of the node entity "01", the node entity "02" is taken as an adjacent entity of the node entity "01", the entity category of the node entity "02" is "a", the entity category can be regarded as a second entity "a", and the adjacent entity corresponding to the second entity "a" is the node entity "02", so that the entity relationship between the second entity "a" and the node entity "01", and the entity relationship between the adjacent entity '02' corresponding to the second entity and the node entity is the same, i.e. the entity relationship between the second entity "a" and the node entity "01" is also the entity relationship "r 1", that is, the relationship category of the entity relationship is "r 1", and the relationship direction is from the node entity "01" to the second entity "A". Other cases may be analogized, and no one example is given here.
In a specific implementation scenario, under the condition that the relationship attributes corresponding to the reference entities are the same, the weight parameters of the reference entities are the same, and under the condition that the relationship attributes corresponding to the reference entities are different, the weight parameters of the reference entities are different, so that different reference entities are referred to in different degrees, and the accuracy of entity representation is improved.
In a specific implementation scenario, in order to improve the detection speed, the adjacent entities may be divided into several entity sets based on the relationship attributes corresponding to the adjacent entities, and the relationship attributes corresponding to the adjacent entities in the entity set are the same, and on this basis, for each entity set, in the case that there are a plurality of adjacent entities having the same entity category, the same entity category may be uniformly represented as the second entity. As shown in fig. 3, based on the node entity "01" in the knowledge graph shown in fig. 2, firstly, according to the relationship class, the adjacent entity and the node entity "01" connected with the node entity "01" by the relationship class r1 may be extracted as a sub-graph Rel _1, and the adjacent entity and the node entity "01" connected with the node entity "01" by the relationship class r2 may be extracted as a sub-graph Rel _ 2. Other cases may be analogized, and no one example is given here. On the basis, for adjacent entities in each sub-map, the adjacent entities can be further divided into a plurality of entity sets according to the relation direction. With continued reference to fig. 3, for the sub-map Rel _1, the adjacent entity "02", the adjacent entity "03" and the connecting entity "04" can be divided into an entity set Rel _1(in) according to the relationship direction, and since the adjacent entity "02" and the adjacent entity "03" in the entity set have the same entity category, the same entity category can be regarded as a second entity (as shown by the dashed circle connecting the adjacent entity "02" and the adjacent entity "03" with dashed lines in the figure); furthermore, the adjacent entity "07", the adjacent entity "08", the adjacent entity "09" and the adjacent entity "10" can be divided into an entity set Rel _1(out) according to the relationship direction, and since the adjacent entity "07", the adjacent entity "08" and the adjacent entity "09" in the entity set have the same entity category, the same entity category can be regarded as a second entity (as indicated by the dashed circle connecting the adjacent entity "07", the adjacent entity "08" and the adjacent entity "09" in the figure) and since the adjacent entity "09" and the adjacent entity "10" in the entity set also have the same entity category, the same entity category can be regarded as a second entity (as indicated by the dashed circle connecting the adjacent entity "09" and the adjacent entity "10" in the figure); similarly, for the sub-map Rel _1, the adjacent entity "05", the adjacent entity "06" and the adjacent entity "07" can be divided into an entity set Rel _2(in) according to the relationship direction, and since the three entities do not have the same entity category, a corresponding second entity cannot be extracted from the entity set; similarly, the adjacent entity "11", the adjacent entity "12" and the adjacent entity "13" can be divided into an entity set Rel _2(out) according to the relationship direction, and since the adjacent entity "11" and the adjacent entity "12" have the same entity category, the same entity category can be regarded as a second entity (as shown by a dashed circle connecting the adjacent entity "11" and the adjacent entity "12" with a dashed line in the figure), and so on, are not illustrated.
In a specific implementation scenario, in order to facilitate calculation of entity representations, second entities extracted from each entity set may be added to the entity set, in addition, the first entity and the node entity may be separately used as entity sets, that is, relationship attributes of entity relationships between each entity and the node entity in the same entity set are the same, on this basis, the initial representation of the entity in each entity set may be weighted by using the same weight parameter to obtain a weighted representation, and the weight parameter used by the entity set is related to the relationship attributes of the entity relationships between each entity and the node entity in the entity set, and then the weighted representations obtained by corresponding weighting of each entity set are added to obtain a fused representation of the entity node, and the fused representation is activated by using an activation function, an entity representation of the node entity is obtained. Referring to fig. 3, the entity set Rel _1(out), the entity set Rel _1(in), the entity set Rel _2(out), the entity set Rel _2(in), the entity set isA (including the first entity) and the entity set self-loop (including the node entity itself) respectively have different weighting parameters, on this basis, the initial representation of each entity in the entity set can be weighted by using the weighting parameters of each entity set, so as to obtain a weighted representation of each entity set, the weighted representations of each entity set are summed to obtain a fused representation, and the fused representation is processed by the excitation function, so as to obtain an entity representation of the node entity "01". In addition, the excitation function may include, but is not limited to, a ReLU (Rectified Linear Unit), etc., and is not limited herein. Other cases may be analogized, and no one example is given here.
In an implementation scenario, in order to improve the extraction efficiency and accuracy of entity representation, a knowledge extraction model may be trained in advance, and on this basis, the knowledge extraction model may be used to extract entity representations of each node entity in the knowledge graph, and a specific training process of the knowledge extraction model may refer to relevant descriptions in the following disclosed embodiments, which are not repeated herein.
In one specific implementation scenario, the knowledge extraction model may include several network layers, and for each network layer the following steps may be performed: and for each node entity, carrying out weighted fusion on entity representations output by the plurality of reference entities in the last network layer by using the weight parameters of the plurality of reference entities, and carrying out the circulation on the entity representations of the node entities to deeply mine the semantic information of the node entities. It should be noted that, for the first entity and the second entity in the several reference entities, the entity representation at each network layer may be the same. For example, the knowledge extraction model may be obtained after the training convergence, or may be extracted by using a pre-trained language model, a word vector tool, and the like as described above, which is not limited herein. In addition, for the first network layer, the entity representation output by the previous network layer is the initial representation of the reference entity.
In a specific implementation scenario, for ease of description, for the ith node entity eiIn other words, the entity representation of the i-th node entity when the i-th network layer is input can be denoted as ei (l)And node entity eiOf the plurality of reference entities (except itself) the jth reference entity is denoted as ejReference entity ejThe entity representation when inputting the l-th network layer is marked as ej (l)And will be associated with node entity eiThe set of reference entities with the same relationship attribute r between them is denoted as Ni rAfter the processing of the l-th layer network layer, the node entity eiEntity of (d) represents ei (l+1)Can be expressed as:
ei (l+1)=σ(ei (l)W0 (l)+∑r∈Rj∈Ni rej (l)Wr (l))……(1)
in the above formula (1), σ represents an activation function, such as ReLU, and is not limited herein. W0 (l)Representing a node entity eiWeight parameter, W, corresponding to the l-th network layerr (l)Representation and node entity eiThe reference entities with the same relation attribute R between the reference entities correspond to weight parameters in the l-th network layer, wherein R represents a reference node and a node entity eiA set of relational attributes r. Note that, the weight parameter W is described above0 (l)、Wr (l)Optimization adjustment can be performed during the training process of the knowledge extraction model.
Step S13: and obtaining a detection result of the target triple based on the entity representation of the target head entity, the relationship representation of the target relationship and the entity representation of the target tail entity.
Specifically, after the processing, the entity representation of each node entity in the knowledge graph can be obtained, and on this basis, the entity representation of the target head entity and the entity representation of the target tail entity can be obtained, so that the detection result of the target triple can be obtained based on the entity representation of the target head entity, the relationship representation of the target relationship and the entity representation of the target tail entity. It should be noted that the relationship representation may be preset, for example, in the training process of the knowledge extraction model, the relationship representations of different entity relationships may be preset, and the model training may be performed; alternatively, the relationship representation may also be preset and updated in the training process of the knowledge extraction model, and obtained after the training of the knowledge extraction model converges, which may specifically refer to the related description in the following disclosure embodiments, and will not be described herein again.
In one implementation scenario, the detection result may include any one of the detection of the target triplet as error-free and the detection of the target triplet as error.
In one implementation scenario, for convenience of description, the entity representation of the target head entity in the target triple may be denoted as h, the entity representation of the target tail entity in the target triple may be denoted as t, and the relationship representation of the target relationship in the target triple may be denoted as r, and then the detection result of the target triple may be obtained based on the detection score E (h, r, t) of the entity representation and the relationship representation in the target triple under the transition assumption.
In a specific implementation scenario, the detection score E (h, r, t) may be calculated by | | h + r-t | |, i.e. a modulus of a difference between a sum of the entity representation h of the target head entity and the relationship representation r of the target relationship and the entity representation r of the target tail entity.
In a specific implementation scenario, the smaller the detection score E (h, r, t), the higher the probability that the target triplet is error-free, whereas the larger the detection score E (h, r, t), the higher the probability that the target triplet is error-free. For example, for a target triple (shakespeare, creation, proud and prejudice), the entity representation of the target head entity "shakespeare", the entity representation of the target tail entity "proud and prejudice" and the relationship representation of the target relationship "creation" may be obtained, and a detection score under the transition hypothesis may be calculated, and in a case that the detection score is lower than a preset threshold, it may be determined that the detection result includes the target triple detection without error, or otherwise, it may be determined that the detection result includes the target triple detection with error. Other cases may be analogized, and no one example is given here.
In the scheme, the knowledge graph and the target triple in the knowledge graph are obtained, the knowledge graph comprises a plurality of node entities and entity relations connecting the node entities, the target triple comprises a target head entity, a target tail entity and target relations between the target head entity and the target tail entity, the entity representation of the node entities is obtained based on a plurality of reference entities of the node entities, the plurality of reference entities comprise the node entities, adjacent entities of the node entities, a first entity and a second entity, the first entity represents the entity class of the node entities, the second entity represents the entity class of the adjacent entities, on the basis, the detection result of the target triple is obtained based on the entity representation of the target head entity, the relation representation of the target relation and the entity representation of the target tail entity, and because the node entities and the adjacent entities thereof can be referred in the knowledge representation process of the node entities, the entity type of the node entity and the entity type of the adjacent entity can be referred, so that the accuracy of knowledge representation can be improved, detection is carried out on the basis, and the improvement of the detection accuracy of the knowledge graph is facilitated.
Referring to fig. 4, fig. 4 is a flow chart illustrating an embodiment of training a knowledge extraction model. As described above, the entity representation may be extracted by using a knowledge extraction model, the knowledge extraction model is obtained by using a sample knowledge graph, and the sample knowledge graph includes a plurality of sample node entities and a sample entity relationship connecting the sample node entities. Specifically, the training process may include the steps of:
step S41: and carrying out knowledge extraction on the sample knowledge graph by using a knowledge extraction model to obtain sample entity representation of the sample node entity.
Specifically, the specific process of extracting knowledge from the sample knowledge graph by using the knowledge extraction model to obtain the sample entity representation of the sample node entity may refer to the description related to extracting knowledge from the knowledge graph by using the knowledge extraction model to obtain the entity representation of the node entity in the foregoing disclosed embodiment, and is not described herein again.
Step S42: for a sample triple in the sample knowledge graph, a first confidence coefficient of the sample triple is obtained based on a first quality score of the sample triple, a first sub-loss of the sample triple is obtained based on the first confidence coefficient of the sample triple, a second confidence coefficient of the sample triple is obtained based on a second quality score of the sample triple, and a second sub-loss of the sample triple is obtained based on the second confidence coefficient of the sample triple.
In the embodiment of the present disclosure, the sample triplet includes a sample header entity, a sample trailer entity, and a sample entity relationship between the sample header entity and the sample trailer entity, which may specifically refer to the related description of the triplet in the foregoing embodiment, and details are not repeated here.
In the embodiment of the disclosure, the first quality score is obtained based on the text representation of the description text of the sample head entity, the sample tail entity and the sample entity relationship. It should be noted that the description text may contain text information associated with an entity or a relationship, and the description text may be carried by the sample knowledge graph itself. In addition, the more description files of the sample head entity, the sample tail entity and the sample entity relationship are matched, the higher the first quality score is. Taking a sample triple (shakebia, authored, aole and prejudice) as an example, the descriptive text of the sample head entity "shakebia" may include "drama, poem in the republic of literary skill in england", the descriptive text of the sample entity relationship "authored" may include "creative literature art", and the descriptive text of the sample tail entity "aole and prejudice" may include "long novel authored by austin, nova novice of england", so it can be seen that there is clearly a discrepancy between the descriptive text of both the sample head entity "shakebia" and the sample tail entity "aole and prejudice". Other cases may be analogized, and no one example is given here.
In an implementation scenario, for a description text of any one of relationships among a sample head entity, a sample tail entity and a sample entity, a keyword in the description text may be encoded to obtain an encoded representation of the keyword, semantic extraction may be performed on the encoded representation to obtain a first semantic representation of the keyword, and an importance of the keyword may be obtained based on a similarity between the first semantic representation and a second semantic representation of a sample triplet, and on this basis, the first semantic representation of the keyword may be weighted by using the importance of the keyword to obtain a text representation of the description text. Therefore, semantic information of key words which are relatively important can be highlighted in text representation, and accuracy of text representation can be improved.
In a specific implementation scenario, keywords in the description text may be extracted in a manner of TF-IDF (Term Frequency-Inverse text Frequency index) and the like, and the keywords may reflect main information of the description text, so that similar entities may have similar keywords. For convenience of description, the keywords in the description text may be denoted as Wn={w1,w2,…,wnN represents the number of keywords in the description text. The specific process of extracting the keywords may refer to technical details of an extraction manner such as TF-IDF, and is not described herein again.
In a specific implementation scenario, keyword coding may be performed at the word level. Specifically, a Gate-controlled round-robin (GRU) network may be used to perform the above-mentioned keyword sequence Wn={w1,w2,…,wnAnd coding to obtain the coded representation of each keyword. For convenience of description, the ith keyword w may beiIs denoted by hi. It should be noted that, a gating mechanism is added to the GRU based on the recurrent neural network, and the gating mechanism can determine the current state of the sequence, which may specifically refer to technical details of the GRU and is not described herein again.
In one particular implementation scenario, after obtaining the encoded representation of each keyword in the keyword sequence, the encoded representation of each keyword may be input into a semantic extraction network, such as BERT, to take the extracted implicit representation as the first semantic representation of the keyword. For convenience of description, the ith keyword w may beiFirst semantics ofIs denoted by ui. It should be noted that the specific process of extracting the semantic representation by the semantic extraction network may refer to the technical details of the semantic extraction network such as BERT, and is not described herein again.
In a specific implementation scenario, the knowledge extraction model may be obtained through several rounds of training, in which case, the second semantic representation of the triplet may be obtained through random initialization during the first round of training, and may be optimally adjusted along with the knowledge extraction model during the training process.
In one implementation scenario, a higher similarity between the first semantic representation of the keyword and the second semantic representation of the sample triplet indicates a higher importance of the keyword to the sample triplet. Specifically, the similarity between the first semantic representation of the keyword and the second semantic representation of the sample triplet may be measured in the ways of inner product, cosine similarity, and the like, and after the similarity corresponding to each keyword is obtained, the similarity corresponding to each keyword may be normalized to obtain the importance of each keyword. For example, the similarity corresponding to each keyword may be normalized by softmax. For convenience of description, the ith keyword w may beiThe importance of (a) is denoted asi
In one implementation scenario, to quantitatively measure the first quality score of a sample triplet, a text representation of a description text of a sample head entity, a sample tail entity and a sample entity relationship may be obtained first, and for convenience of description, the text representation of the description text of the sample head entity may be denoted as dhThe text representation of the description text of the sample tail entity is denoted as dtAnd noting the textual representation of the descriptive text of the sample entity relationships as drThen the first quality score Qd(dh,dr,dt) Can be expressed as:
Qd(dh,dr,dt)=-(γd+H(dh,dr,dt)-H(dh ,dr ,dt ))……(2)
the above formula (2)) Where H represents the distance between text representations, e.g., H (d)h,dr,dt) Distance, H (d), between text representations representing sample triples corresponding to description texth,dr,dt) Specifically, can be represented by | | | dh+dr-dtI.e. it can be calculated by the module value of the difference between the sum of the text representation of the descriptive text of the sample head entity and the text representation of the descriptive text of the sample entity relationship and the text representation of the descriptive text of the sample tail entity, and H (d)h ,dr ,dt ) The distance between the text representations of the description texts corresponding to the negative example triples is represented, and the specific calculation process is shown in H (d)h,dr,dt) And will not be described herein. Gamma raydThe meta-parameter is expressed, and the specific value is not limited herein. In addition, at least one of the relation among the sample head entity, the sample tail entity and the sample entity in the sample triplet (h, r, t) is replaced, so that a negative-case triplet can be obtained, wherein the negative-case triplet is an error triplet. For example, the sample tail entity in the sample triplet (shakebia, authored, roman and juliet) can be replaced by "proud and bias" to obtain a negative triplet (shakebia, authored, proud and bias). On the basis, H (d) can be obtained by using the text representation of the description text of the sample head entity, the sample tail entity and the sample entity relation in the negative example tripleh ,dr ,dt )。
In an implementation scenario, the knowledge extraction model is obtained through multiple rounds of training, and the higher the first quality score is, the higher the possibility that the sample triplet is correct is, the higher the first quality score is, in the case that the first quality score is not lower than a preset threshold in the current round of training, the first confidence coefficient in the current round of training is higher than the first confidence coefficient in the previous round of training in the current round of training, and in the case that the first quality score is lower than the preset threshold in the current round of training, the first confidence coefficient in the current round of training is lower than the first confidence coefficient in the previous round of training. Specifically, the preset threshold may be set according to actual conditions, for example, may be set to 0, and furthermore, in the present invention, the preset threshold may be set according to actual conditionsIn the case that the first quality score in the current round of training is not lower than the preset threshold, a first numerical value (the first numerical value is a positive number) may be added to the first confidence in the previous round of training to serve as a first confidence in the current round of training, and in the case that the first quality score in the current round of training is lower than the preset threshold, a second numerical value (the second numerical value is greater than 0 and less than 1) may be multiplied by the first confidence in the previous round of training to serve as a first confidence in the current round of training. For convenience of description, the first confidence in the current round of training may be denoted as DT(t)The first confidence in the last training round can be recorded as DT(t-1)Then the first confidence coefficient DT in the training of the current round(t)Can be expressed as:
Figure 92140DEST_PATH_IMAGE001
……(3)
in the above formula (3), v represents a first numerical value, u represents a second numerical value, and QthrRepresenting a preset threshold. It should be noted that, in the first round of training, there is substantially no previous round of training, and the first confidence in the previous round of training may be initialized to 1.
In one implementation scenario, after obtaining the first confidence level, the first sub-loss may be obtained based on a difference between sample scores E (h, r, t) of the sample entity representations and the sample relationship representations in the sample triples under the transition hypothesis and sample scores E (h ', r ', t ') of the sample entity representations and the sample relationship representations in the corresponding negative triplet, and the first confidence level. Specifically, a marginal-based score function may be used to calculate a sum of the edge over parameter γ and the above-mentioned score difference, and take a larger value between the sum and 0, and then take the product of the larger value and the first confidence as the first sub-loss. In addition, if there are multiple negative example triples in a sample triplet, for each negative example triplet, a corresponding larger value may be obtained in the above manner, and the multiple larger values are summed, and the product of the summation result and the first confidence is taken as the first sub-loss. It should be noted that, the process of calculating the sample score may refer to the related description of the detection score in the foregoing embodiments, and is not described herein again.
In an embodiment of the present disclosure, the second quality score is obtained based on the sample entity representation of the sample head entity, the sample entity representation of the sample tail entity, and the sample relationship representation of the sample entity relationship. Specifically, the second quality score Q may be obtained based on the sample score E (h, r, t) of the sample entity representation and the sample relationship representation in the sample triplet under the transition hypothesis, and the sample score E (h ', r ', t ') of the sample entity representation and the sample relationship representation in the negative-case triplet corresponding to the sample triplet under the transition hypothesisloc(h,r,t):
Qloc(h,r,t)=-(γd+E(h,r,t)-E(h’,r’,t’))……(4)
In the above formula (4), γdThe meta-parameter is expressed, and the specific value is not limited herein. As previously described, a higher second quality score Q, based on the assumption of a transitionloc(h, r, t), which indicates that the sample triplet is highly correct, the second confidence in the current round of training is higher than the second confidence in the previous round of training when the second quality score in the current round of training is not lower than the preset threshold, and the second confidence in the current round of training is lower than the second confidence in the previous round of training when the second quality score in the current round of training is lower than the preset threshold. Specifically, the preset threshold may be set according to actual conditions, for example, may be set to 0, and in addition, in a case that the second quality score in the current training is not lower than the preset threshold, a first value (the first value is a positive number) may be added to the second confidence in the previous training as the second confidence in the current training, and in a case that the second quality score in the current training is lower than the preset threshold, a second value (the second value is greater than 0 and less than 1) may be multiplied by the second confidence in the previous training as the second confidence in the current training. For ease of description, the second confidence in the current round of training may be denoted as LT(t)The second confidence in the previous training round can be recorded as LT(t-1)The second confidence level LT in the training of the current round(t)Can be expressed as:
Figure 606298DEST_PATH_IMAGE002
……(5)
in the above formula (5), v represents a first numerical value, u represents a second numerical value, and QthrRepresenting a preset threshold. It should be noted that, in the first round of training, there is substantially no previous round of training, and the first confidence in the previous round of training may be initialized to 1.
In an implementation scenario, since the number of entities is much greater than the number of relationships in a real-world scenario, for the entity relationships, a relationship representation set may be maintained and updated during a training process, where the relationship representation set may include relationship representations of different entity relationships, and during an ith round of training, the relationship representations updated after the ith-1 round of training may be used, and the above steps are repeated until the knowledge extraction model training converges, so that the relationship representations of the entity relationships may be obtained. And then, in the knowledge graph detection process, the relation representation of the target relation can be directly obtained by inquiring from the relation representation set, so that the consistency of the training stage and the prediction stage can be favorably ensured, and the knowledge graph detection precision can be favorably further improved.
In one implementation scenario, after obtaining the second confidence level, the second sub-loss may be obtained based on a difference between the sample scores E (h, r, t) of the sample entity representations and the sample relationship representations in the sample triples under the transition hypothesis and the sample scores E (h ', r ', t ') of the corresponding sample entity representations and the sample relationship representations in the negative triplet, and the second confidence level. Specifically, a marginal-based score function may be used to calculate a sum of the edge over parameter γ and the above-mentioned score difference, and take a larger value between the sum and 0, and then take the product of the larger value and the second confidence as the second sub-loss. In addition, if there are multiple negative example triples in a sample triplet, for each negative example triplet, the corresponding larger value may be obtained in the above manner, the multiple larger values are summed, and the product of the summation result and the second confidence is used as the second sub-loss. It should be noted that, the process of calculating the sample score may refer to the related description of the detection score in the foregoing embodiments, and is not described herein again.
Step S43: optimizing the knowledge extraction model based on the first and second sub-losses of each sample triplet.
In an implementation scenario, weighting processing may be performed on the first sub-loss and the second sub-loss to obtain weighted sub-losses of the sample triples, and on this basis, the weighted sub-losses of each sample triplet may be summed to obtain a total loss of the knowledge extraction model, and on this basis, network parameters of the knowledge extraction model may be optimized based on optimization manners such as gradient descent. In addition, as described above, in the process of optimizing the network parameters, the second semantic representation of the optimized sample triplet and the relationship representation of the entity relationship may also be synchronously adjusted. The specific process of the optimization adjustment may refer to technical details of an optimization manner such as gradient descent, and is not described herein again.
In an implementation scenario, the first confidence degree and the second confidence degree respectively concern a description text of the knowledge graph and internal information of the triples, and in order to further improve the performance of the knowledge extraction model, a relationship path between entities may be further used to constrain the knowledge extraction model. It should be noted that the ternary inter-group relationship path may generally provide reasoning information for triple error detection. For example, given the relationship paths (zhang, born in, city a) and (zhang, located in, country B), the triples (zhang, born in, country B) can be inferred, so that the performance of the knowledge extraction model can be further improved by further considering the third confidence based on the relationship paths on the basis of the first confidence and the second confidence.
In a specific implementation scenario, a relationship path may be considered more important if the relationship path contains more information flows from the head entity to the tail entity. For the convenience of description, taking the sample node entity pair (h, t) as an example, the amount of resources flowing through a certain path p to the sample tail entity t will be regarded as the reliability of the given relationship path p. Further, for the relationship path p = { r = { (r) }1,…,rlAs far asAnd for the above entity pair (h, t), l steps are required from the sample head entity h to the sample tail entity t, i.e. for the sample head entity h and the relationship path p, the relationship path can be expressed as: e0 → (r)1)→…→(rl)→El,EiRepresents the set of entities at step i, and E0= h, sample tail entity t ∈ El. Then E for the sample node entityiAmount of resource Rp(e) Can be expressed as:
Rp(e)=∑e’∈El-1(.,e)Rp(e’)/|Ei(e’,.)|……(6)
in equation (6) above, El-1(., e) represents a direct predecessor entity set of sample node entities e, and the sample node entities in this set pass through a sample entity relationship riAnd e are connected. Ei(e ',) represents a directly succeeding set of sample node entities e', and the sample node entities in the set pass through the relationship riAnd e' are connected. Finally, the resource amount R is calculated by l steps from h to tp(e) Consider the relational path reliability for a given sample node entity pair (h, t) and path p, which may be denoted as R (h, p, t) for ease of description.
In a specific implementation scenario, the third quality score Q of the sample tripletPT(r,pi) Can be represented by a sample entity relationship r and a path piThe probability of co-occurrence in the knowledge graph is calculated. Specifically, the higher the co-occurrence frequency of the path and the sample entity relationship, the higher the likelihood of representing similar semantics between the two. So for the sample triplet (h, r, t) and the set S (h, t) of all paths from h to t, the ith relationship path pair (r, p)i) Third quality score Q ofPT(r,pi) Can be expressed as:
QPT(r,pi)=ε+(1-ε)P(r,pi)/P(pi)……(7)
in the above formula (7), P (r, P)i) Representing sample entity relationships r and paths piA priori probability of co-occurrence in the knowledge graph, P (P)i) Represents a path piPrior probability of occurrence in knowledge graph, epsilon tableThe specific numerical values are not limited herein.
In a specific implementation scenario, a third quality score Q is obtainedPT(r,pi) And after the reliability R (h, p, t), calculating a third confidence PT (h, R, t) of the sample triplet (h, R, t):
PT(h,r,t)=∑pi∈S(h,t)QPT(r,pi)R(h,p,t)……(8)
in the above equation (8), S (h, t) represents all relationship paths between the sample head entity h and the sample tail entity t.
In one implementation scenario, after obtaining the third confidence level, a third sub-penalty may be obtained based on a difference in values between the sample scores E (h, r, t) of the sample entity representations and the sample relationship representations in the sample triples under the transition hypothesis and the sample scores E (h ', r ', t ') of the corresponding sample entity representations and the sample relationship representations in the negative triples under the transition hypothesis, and the third confidence level. Specifically, a marginal-based score function may be used to calculate a sum of the edge over parameter γ and the above-mentioned score difference, and take a larger value between the sum and 0, and then take a product of the larger value and the third confidence as the third sub-loss. In addition, if there are multiple negative example triples in a sample triplet, for each negative example triplet, the corresponding larger value may be obtained in the above manner, the multiple larger values are summed, and the product of the summation result and the third confidence is used as the third sub-loss. It should be noted that, the process of calculating the sample score may refer to the related description of the detection score in the foregoing embodiments, and is not described herein again.
In an implementation scenario, weighting processing may be performed on the first sub-loss, the second sub-loss, and the third sub-loss to obtain weighted sub-losses of the sample triples, and on this basis, the weighted sub-losses of each sample triplet may be summed to obtain a total loss of the knowledge extraction model, and on this basis, network parameters of the knowledge extraction model may be optimized based on optimization manners such as gradient descent. In addition, as described above, in the process of optimizing the network parameters, the second semantic representation of the optimized sample triplet and the relationship representation of the entity relationship may also be synchronously adjusted. The specific process of the optimization adjustment may refer to technical details of an optimization manner such as gradient descent, and is not described herein again.
In an implementation scenario, as equivalent to the above calculation method, after the first confidence level, the second confidence level, and the third confidence level are obtained respectively, the three confidence levels may also be weighted to obtain a weighted confidence level C (h, r, t), and then the total loss L of the knowledge extraction model may be obtained based on the marginal fractional function:
L=∑(h,r,t)∈T(h’,r’,t’)∈T’max(0,γ+E(h,r,t)-E(h’,r’,t’)C(h,r,t))……(9)
in the above formula (9), E (h, r, t) and E (h ', r ', t ') respectively represent sample scores of the sample triplet and its negative triplet, and γ represents an edge over parameter, and specific values thereof are not limited herein. In addition, T represents a set of sample triples in the sample knowledge-graph, and T' represents a set of negative example triples. By the method, three confidence degrees beneficial to the error detection task are provided for the knowledge graph external text information, the triple internal information and the triple inter-entity path information, the learning effect of the knowledge graph representation is improved, and a better error detection level is achieved.
According to the scheme, the knowledge extraction model is used for carrying out knowledge extraction on the sample knowledge graph to obtain a sample entity representation of a sample node entity, for sample triples in the sample knowledge graph, a first confidence coefficient of the sample triples is obtained based on a first quality score of the sample triples, a first sub-loss of the sample triples is obtained based on the first confidence coefficient of the sample triples, a second confidence coefficient of the sample triples is obtained based on a second quality score of the sample triples, a second sub-loss of the sample triples is obtained based on the second confidence coefficient of the sample triples, on the basis, the knowledge extraction model is optimized based on the first sub-loss and the second sub-loss of each sample triplet, the sample triples comprise a sample head entity, a sample tail entity and a sample entity relationship between the sample head entity and the sample tail entity, and the first quality score is based on the sample head entity, the sample tail entity, the sample entity relationship between the sample head entity and the sample tail entity, The text representation of the description text of the sample tail entity and the sample entity relationship is obtained, namely on one hand, the training of the knowledge extraction model can be restrained by referring to the description text, and the second quality score is obtained based on the sample entity representation of the sample head entity, the sample entity representation of the sample tail entity and the sample relationship representation of the sample entity relationship, on the other hand, the training of the knowledge extraction model can be restrained through the interior of the triples, so that in the training process of the knowledge extraction model, the interior of the sample triples and the description text can be referred to at the same time, the training quality of the knowledge extraction model is favorably improved, and the detection precision of the subsequent knowledge map is improved.
Referring to fig. 5, fig. 5 is a schematic diagram of a framework of an embodiment of the knowledge-graph detecting device 50 of the present application. The knowledge-graph detecting apparatus 50 includes: the system comprises a knowledge acquisition module 51, an entity representation module 52 and a result detection module 53, wherein the knowledge acquisition module 51 is used for acquiring a knowledge graph and a target triple in the knowledge graph; the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity; the entity representation module 52 is configured to obtain an entity representation of the node entity based on a plurality of reference entities of the node entity; the plurality of reference entities comprise node entities, adjacent entities of the node entities, first entities and second entities, wherein the first entities represent entity classes of the node entities, and the second entities represent entity classes of the adjacent entities; the result detection module 53 is configured to obtain a detection result of the target triple based on the entity representation of the target head entity, the relationship representation of the target relationship, and the entity representation of the target tail entity.
In the scheme, the knowledge graph and the target triple in the knowledge graph are obtained, the knowledge graph comprises a plurality of node entities and entity relations connecting the node entities, the target triple comprises a target head entity, a target tail entity and target relations between the target head entity and the target tail entity, the entity representation of the node entities is obtained based on a plurality of reference entities of the node entities, the plurality of reference entities comprise the node entities, adjacent entities of the node entities, a first entity and a second entity, the first entity represents the entity class of the node entities, the second entity represents the entity class of the adjacent entities, on the basis, the detection result of the target triple is obtained based on the entity representation of the target head entity, the relation representation of the target relation and the entity representation of the target tail entity, and because the node entities and the adjacent entities thereof can be referred in the knowledge representation process of the node entities, the entity type of the node entity and the entity type of the adjacent entity can be referred, so that the accuracy of knowledge representation can be improved, detection is carried out on the basis, and the improvement of the detection accuracy of the knowledge graph is facilitated.
In some disclosed embodiments, the entity representation module 52 is specifically configured to, for each node entity, perform weighted fusion on the initial representations of the plurality of reference entities by using the weight parameters of the plurality of reference entities to obtain an entity representation of the node entity; and the relationship attribute of the entity relationship between the reference entity and the node entity is related to the weight parameter of the reference entity.
Therefore, for each node entity, the initial representations of the reference entities are weighted and fused by using the weight parameters of the reference entities to obtain the entity representation of the node entity, and the relationship attributes of the entity relationship between the reference entities and the node entity are related to the weight parameters of the reference entities, so that the initial representations of the reference entities with different relationship attributes between the reference entities and the node entity can be fused to different degrees, and the accuracy of the entity representation of the node entity is improved.
In some disclosed embodiments, the physical relationship between the first entity and the node entity is a predetermined relationship; and/or the entity relationship between the second entity and the node entity is the same as the entity relationship between the adjacent entity corresponding to the second entity and the node entity, and the second entity represents the entity category of the corresponding adjacent entity.
Therefore, setting the entity relationship between the first entity and the node entity as the preset relationship can be beneficial to distinguishing the entity relationships between the second entity, the adjacent entity and the node entity and improving the accuracy of knowledge representation, and setting the entity relationship between the second entity and the node entity and the entity relationship between the adjacent entity and the node entity corresponding to the second entity as the same, and setting the entity category of the adjacent entity corresponding to the second entity as the same, can be beneficial to improving the accuracy of knowledge representation.
In some disclosed embodiments, the weight parameters of the reference entities are the same under the condition that the relationship attributes corresponding to the reference entities are the same, and the weight parameters of the reference entities are different under the condition that the relationship attributes corresponding to the reference entities are different; and/or, the relationship attributes include: at least one of the relationship type and the relationship direction.
Therefore, under the condition that the relationship attributes corresponding to the reference entities are the same, the weight parameters of the reference entities are set to be the same, and under the condition that the relationship attributes corresponding to the reference entities are different, the weight parameters of the reference entities are set to be different, namely, the initial representations of the reference entities with the same relationship attributes with the node entities can be uniformly fused by the same weight parameter, and the efficiency of knowledge representation is improved; the relationship attribute is set to include at least one of the relationship category and the relationship direction, so that the relationship attribute can be favorably defined from the two aspects of the relationship category and the relationship direction, and the accuracy of knowledge representation is favorably further improved.
In some disclosed embodiments, the knowledge-graph detection apparatus 50 includes an entity partitioning module for partitioning adjacent entities into several entity sets based on corresponding relationship attributes of the adjacent entities; wherein, the corresponding relationship attributes of the adjacent entities in the entity set are the same; the knowledge-graph detection apparatus 50 includes an entity extraction module for representing, for each entity set, a same entity class as a second entity in a case where there are a plurality of adjacent entities having the same entity class.
Therefore, based on the relationship attributes corresponding to the adjacent entities, the adjacent entities are divided into a plurality of entity sets, and the relationship attributes corresponding to the adjacent entities in the entity sets are the same, on the basis, for each entity set, under the condition that a plurality of adjacent entities have the same entity category, the same entity category is represented as a second entity, namely, in the process of extracting the second entity, fewer entity categories existing in the entity sets are ignored, so that the number of the second entities can be reduced, the efficiency of knowledge representation can be improved, on the other hand, relatively secondary reference information can be ignored in the process of knowledge representation, and the efficiency of knowledge representation can be further improved on the premise of ensuring the accuracy of knowledge representation.
In some disclosed embodiments, the entity representation is extracted using a knowledge extraction model trained using a sample knowledge graph, and the sample knowledge graph includes a number of sample node entities and sample entity relationships connecting the sample node entities.
Therefore, the entity representation is extracted through the knowledge extraction model, the knowledge extraction model is obtained by training through the sample knowledge graph, and the sample knowledge graph comprises a plurality of sample node entities and sample entity relations connecting the sample node entities, so that the extraction efficiency and accuracy of the knowledge representation can be improved.
In some disclosed embodiments, the knowledge-graph detection apparatus 50 includes a knowledge extraction module for performing knowledge extraction on the sample knowledge graph using a knowledge extraction model to obtain a sample entity representation of the sample node entity; the knowledge-graph detecting device 50 includes a loss calculating module, configured to, for a sample triplet in a sample knowledge graph, obtain a first confidence of the sample triplet based on a first quality score of the sample triplet, obtain a first sub-loss of the sample triplet based on the first confidence of the sample triplet, obtain a second confidence of the sample triplet based on a second quality score of the sample triplet, and obtain a second sub-loss of the sample triplet based on the second confidence of the sample triplet; the knowledge-graph detection apparatus 50 includes a model optimization module for optimizing a knowledge extraction model based on the first and second sub-loss values of each sample triplet; the sample triple comprises a sample head entity, a sample tail entity and a sample entity relationship between the sample head entity and the sample tail entity, the first quality score is obtained based on text representation of description texts of the sample head entity, the sample tail entity and the sample entity relationship, and the second quality score is obtained based on sample entity representation of the sample head entity, sample entity representation of the sample tail entity and sample relationship representation of the sample entity relationship.
Therefore, on one hand, the training of the knowledge extraction model can be constrained by referring to the description text, and the second quality score is obtained based on the sample entity representation of the sample head entity, the sample entity representation of the sample tail entity and the sample relation representation of the sample entity relation, namely, on the other hand, the training of the knowledge extraction model can be constrained by the interior of the triple, so that the interior of the sample triple and the description text can be simultaneously referred to in the training process of the knowledge extraction model, the training quality of the knowledge extraction model is favorably improved, and the detection precision of the subsequent knowledge map is improved.
In some disclosed embodiments, the knowledge-graph detection apparatus 50 includes a representation extraction module for extracting a text representation, where the representation extraction module includes a text encoding sub-module for encoding keywords in the description text to obtain an encoded representation of the keywords; the expression extraction module comprises a semantic extraction submodule and is used for carrying out semantic extraction on the coded expression to obtain a first semantic expression of the keyword; the representation extraction module comprises an importance measurement submodule and is used for obtaining the importance of the keyword based on the similarity between the first semantic representation and the second semantic representation of the sample triple; the expression extraction module comprises an expression weighting submodule used for weighting the first semantic expression of the key words by using the importance of the key words to obtain text expression.
Therefore, semantic information of the keywords which are relatively important can be highlighted in the text representation, and the accuracy of the text representation can be improved.
In some disclosed embodiments, the knowledge extraction model is obtained through multiple rounds of training, and the higher the first quality score is, the greater the likelihood that the sample triplet is correct; and under the condition that the first quality score in the training of the current round is not lower than a preset threshold, the first confidence coefficient in the training of the current round is higher than the first confidence coefficient in the training of the previous round, and under the condition that the first quality score in the training of the current round is lower than the preset threshold, the first confidence coefficient in the training of the current round is lower than the first confidence coefficient in the training of the previous round.
Therefore, under the condition that the first quality score in the training of the current round is not lower than the preset threshold, the first confidence coefficient in the training of the current round is higher than the first confidence coefficient in the last training of the current round, and under the condition that the first quality score in the training of the current round is lower than the preset threshold, the first confidence coefficient in the training of the current round is lower than the first confidence coefficient in the training of the last round, so that the knowledge extraction model can be restrained to learn the entity semantic information more and more accurately in the process of multiple rounds of training, and the performance of the knowledge extraction model can be improved continuously in the process of multiple rounds of training.
In some disclosed embodiments, the relational representation is obtained after the knowledge extraction model is trained to converge.
Therefore, because the relation representation is obtained after the training convergence of the knowledge extraction model, the relation representation after the training convergence can be directly used in the knowledge graph detection stage, so that the efficiency of knowledge graph detection can be improved, the consistency of the relation representation in the training stage and the prediction stage can be improved, and the precision of knowledge graph detection can be improved.
Referring to fig. 6, fig. 6 is a schematic diagram of a frame of an embodiment of an electronic device 60 according to the present application. The electronic device 60 comprises a memory 61 and a processor 62 coupled to each other, the memory 61 storing program instructions, and the processor 62 executing the program instructions to implement the steps in any of the above-described embodiments of the knowledge-graph detection method. Specifically, the electronic device 60 may include, but is not limited to: desktop computers, notebook computers, servers, mobile phones, tablet computers, and the like, without limitation.
In particular, the processor 62 is configured to control itself and the memory 61 to implement the steps in any of the above-described embodiments of the knowledge-graph detection method. The processor 62 may also be referred to as a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip having signal processing capabilities. The Processor 62 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 62 may be collectively implemented by an integrated circuit chip.
According to the scheme, in the knowledge representation process of the node entity, the node entity and the adjacent entity thereof can be referred, and the entity type of the node entity and the entity type of the adjacent entity thereof can be referred, so that the accuracy of knowledge representation can be improved, detection is carried out on the basis, and the improvement of the detection accuracy of the knowledge graph is facilitated.
Referring to fig. 7, fig. 7 is a block diagram illustrating an embodiment of a computer readable storage medium 70 according to the present application. The computer readable storage medium 70 stores program instructions 71 capable of being executed by a processor, the program instructions 71 being for implementing the steps in any of the above-described knowledge-map detection method embodiments.
According to the scheme, in the knowledge representation process of the node entity, the node entity and the adjacent entity thereof can be referred, and the entity type of the node entity and the entity type of the adjacent entity thereof can be referred, so that the accuracy of knowledge representation can be improved, detection is carried out on the basis, and the improvement of the detection accuracy of the knowledge graph is facilitated.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
The foregoing description of the various embodiments is intended to highlight various differences between the embodiments, and the same or similar parts may be referred to each other, and for brevity, will not be described again herein.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (13)

1. A method for knowledge-graph testing, comprising:
acquiring a knowledge graph and a target triple in the knowledge graph; the knowledge graph comprises a plurality of node entities and entity relations connecting the node entities, and the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity;
obtaining an entity representation of the node entity based on a number of reference entities of the node entity; wherein the reference entities comprise the node entity, an adjacent entity of the node entity, a first entity and a second entity, the first entity represents an entity category of the node entity, and the second entity represents an entity category of the adjacent entity;
and obtaining a detection result of the target triple based on the entity representation of the target header entity, the relationship representation of the target relationship and the entity representation of the target tail entity.
2. The method of claim 1, wherein the deriving an entity representation of the node entity based on a number of reference entities of the node entity comprises:
for each node entity, carrying out weighted fusion on the initial representations of the reference entities by using the weight parameters of the reference entities to obtain an entity representation of the node entity;
wherein the relationship attribute of the entity relationship between the reference entity and the node entity is related to the weight parameter of the reference entity.
3. The method of claim 2, wherein the entity relationship between the first entity and the node entity is a predetermined relationship;
and/or the entity relationship between the second entity and the node entity is the same as the entity relationship between the adjacent entity corresponding to the second entity and the node entity, and the second entity represents the entity category of the corresponding adjacent entity.
4. The method according to claim 2, wherein the weight parameters of the reference entities are the same when the relationship attributes corresponding to the reference entities are the same, and the weight parameters of the reference entities are different when the relationship attributes corresponding to the reference entities are different;
and/or, the relationship attribute comprises: at least one of the relationship type and the relationship direction.
5. The method of claim 2, wherein the step of obtaining the second entity comprises:
dividing the adjacent entities into a plurality of entity sets based on the corresponding relationship attributes of the adjacent entities; wherein, the corresponding relationship attributes of the adjacent entities in the entity set are the same;
for each of the entity sets, in a case where there are a plurality of the adjacent entities having the same entity category, the same entity category is represented as the second entity.
6. The method of claim 1, wherein the entity representation is extracted using a knowledge extraction model trained using a sample knowledge graph, and wherein the sample knowledge graph comprises a plurality of sample node entities and sample entity relationships connecting the sample node entities.
7. The method of claim 6, wherein the training step of the knowledge extraction model comprises:
carrying out knowledge extraction on the sample knowledge graph by using the knowledge extraction model to obtain a sample entity representation of the sample node entity;
for a sample triplet in a sample knowledge graph, obtaining a first confidence coefficient of the sample triplet based on a first quality score of the sample triplet, obtaining a first sub-loss of the sample triplet based on the first confidence coefficient of the sample triplet, obtaining a second confidence coefficient of the sample triplet based on a second quality score of the sample triplet, and obtaining a second sub-loss of the sample triplet based on the second confidence coefficient of the sample triplet;
optimizing the knowledge extraction model based on the first and second sub-loss values of each of the sample triples;
wherein the sample triplet includes a sample header entity, a sample trailer entity, and a sample entity relationship between the sample header entity and the sample trailer entity, the first quality score is derived based on textual representations of descriptive text of all three of the sample header entity, the sample trailer entity, and the sample entity relationship, and the second quality score is derived based on a sample entity representation of the sample header entity, a sample entity representation of the sample trailer entity, and a sample relationship representation of the sample entity relationship.
8. The method of claim 7, wherein the step of obtaining the textual representation comprises:
coding the keywords in the description text to obtain coded representation of the keywords;
performing semantic extraction on the coded representation to obtain a first semantic representation of the keyword;
obtaining the importance of the keyword based on the similarity between the first semantic representation and the second semantic representation of the sample triple;
and weighting the first semantic representation of the key words by using the importance of the key words to obtain the text representation.
9. The method of claim 7, wherein the knowledge extraction model is obtained through multiple rounds of training, and the higher the first quality score is, the greater the likelihood that the sample triplet is correct;
wherein, when the first quality score in the training of the current round is not lower than a preset threshold, the first confidence coefficient in the training of the current round is higher than the first confidence coefficient in the last training of the current round, and when the first quality score in the training of the current round is lower than the preset threshold, the first confidence coefficient in the training of the current round is lower than the first confidence coefficient in the last training of the round.
10. The method of claim 6, wherein the relational representation is obtained after the knowledge extraction model is trained to converge.
11. A knowledge-graph detection apparatus, comprising:
the knowledge acquisition module is used for acquiring a knowledge graph and a target triple in the knowledge graph; the knowledge graph comprises a plurality of node entities and entity relations connecting the node entities, and the target triple comprises a target head entity, a target tail entity and a target relation between the target head entity and the target tail entity;
an entity representation module, configured to obtain an entity representation of the node entity based on a plurality of reference entities of the node entity; wherein the reference entities comprise the node entity, an adjacent entity of the node entity, a first entity and a second entity, the first entity represents an entity category of the node entity, and the second entity represents an entity category of the adjacent entity;
and the result detection module is used for obtaining the detection result of the target triple based on the entity representation of the target head entity, the relation representation of the target relation and the entity representation of the target tail entity.
12. An electronic device comprising a memory and a processor coupled to each other, the memory having stored therein program instructions, the processor being configured to execute the program instructions to implement the knowledge-graph detection method of any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that program instructions executable by a processor for implementing the method of knowledge-graph detection of any one of claims 1 to 10 are stored.
CN202110957835.6A 2021-08-20 2021-08-20 Knowledge graph detection method and related device, electronic equipment and storage medium Pending CN113407736A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110957835.6A CN113407736A (en) 2021-08-20 2021-08-20 Knowledge graph detection method and related device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110957835.6A CN113407736A (en) 2021-08-20 2021-08-20 Knowledge graph detection method and related device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113407736A true CN113407736A (en) 2021-09-17

Family

ID=77688938

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110957835.6A Pending CN113407736A (en) 2021-08-20 2021-08-20 Knowledge graph detection method and related device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113407736A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117557425A (en) * 2023-12-08 2024-02-13 广州市小马知学技术有限公司 Question bank data optimization method and system based on intelligent question bank system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117557425A (en) * 2023-12-08 2024-02-13 广州市小马知学技术有限公司 Question bank data optimization method and system based on intelligent question bank system
CN117557425B (en) * 2023-12-08 2024-04-16 广州市小马知学技术有限公司 Question bank data optimization method and system based on intelligent question bank system

Similar Documents

Publication Publication Date Title
CN111738004A (en) Training method of named entity recognition model and named entity recognition method
CN111738003B (en) Named entity recognition model training method, named entity recognition method and medium
CN110674850A (en) Image description generation method based on attention mechanism
CN110321563B (en) Text emotion analysis method based on hybrid supervision model
CN110727779A (en) Question-answering method and system based on multi-model fusion
US20190317955A1 (en) Determining missing content in a database
CN112256866B (en) Text fine-grained emotion analysis algorithm based on deep learning
CN112507039A (en) Text understanding method based on external knowledge embedding
CN116992005B (en) Intelligent dialogue method, system and equipment based on large model and local knowledge base
CN111125520B (en) Event line extraction method based on deep clustering model for news text
CN113360582B (en) Relation classification method and system based on BERT model fusion multi-entity information
CN112685539A (en) Text classification model training method and device based on multi-task fusion
CN112784031B (en) Method and system for classifying customer service conversation texts based on small sample learning
CN113268592B (en) Short text object emotion classification method based on multi-level interactive attention mechanism
CN108304568B (en) Real estate public expectation big data processing method and system
CN113407736A (en) Knowledge graph detection method and related device, electronic equipment and storage medium
CN111581365B (en) Predicate extraction method
CN113743079A (en) Text similarity calculation method and device based on co-occurrence entity interaction graph
Salem et al. Refining semantic similarity of paraphasias using a contextual language model
Xu et al. Research on Depression Tendency Detection Based on Image and Text Fusion
CN115034302B (en) Relation extraction method, device, equipment and medium for optimizing information fusion strategy
CN113836941B (en) Contract navigation method and device
CN111797194B (en) Text risk detection method and device, electronic equipment and storage medium
CN114579876A (en) False information detection method, device, equipment and medium
CN113516094A (en) System and method for matching document with review experts

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination