Rule Knowledge Enhancement-based Data Relationship Extraction Method and Related Devices

By combining structured knowledge graphs and unstructured knowledge texts in data relationship extraction, using probability relationship and loss function optimization, the relationship extraction confusion problem caused by word duplication and entity matching errors in small sample data is solved, and the accuracy and consistency of extraction are improved.

CN115186064BActive Publication Date: 2025-07-22NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210841108.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2025-07-22
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

The existing data relationship extraction technology is prone to shallow inference confusion caused by word duplication and entity matching errors in small samples, and it is difficult to effectively solve the confusion problem of relationship extraction.

Method used

Through a method based on rule knowledge enhancement, structured knowledge graphs and unstructured knowledge texts are used, combined with graph neural networks and text encoders, probability relationships of head entities, tail entities and context semantics are constructed, and cross-entropy loss function, instance-level comparison learning loss function and class-level comparison learning loss function are used to optimize the relationship extraction model to solve the confusion problem.

Benefits of technology

Effectively eliminates the confusion of relationship extraction caused by word duplication and entity matching errors, and improves the accuracy and consistency of relationship extraction under small sample data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115186064B_ABST
    Figure CN115186064B_ABST
Patent Text Reader

Abstract

The present application provides a data relation extraction method and related device based on rule knowledge enhancement; the method includes: determining a head entity type set and a tail entity type set according to the structured knowledge graph of the head entity and the tail entity of the instance, and inputting them into a graph neural network encoder to obtain corresponding head entity prototypes and tail entity prototypes based on the relations of the instances; determining relation descriptions from the unstructured knowledge texts of each instance, and inputting the instance and the relation descriptions into a text encoder to obtain instance representations and relation description representations; obtaining context semantics and context semantic prototypes by interacting the instance representations and the relation description representations with each other; respectively constructing probability relations of the head entity, the tail entity type, and the context semantics belonging to the relation, and accordingly determining a cross-entropy loss function, an instance-level contrastive learning loss function, and a category-level contrastive learning loss function; combining the three to obtain an objective function, and using it to perform data relation extraction on the data set to be extracted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the technical field of data relationship prediction, and in particular, to a method for extracting data relationships enhanced by rule knowledge and related devices. Background Art

[0002] Related data relationship extraction technologies often face the problem of small samples. Insufficient data resources often lead to confusion in relationship extraction models for relationship extraction. Specifically, there are two types of shallow reasoning confusions caused by word repetition and entity type matching.

[0003] Based on this, a solution is needed that can achieve relationship extraction in small samples and solve the shallow reasoning confusion caused by word repetition and entity matching errors to eliminate the prediction confusion that appears. Summary of the Invention

[0004] In view of this, the purpose of the present application is to propose a method for extracting data relationships enhanced by rule knowledge and related devices.

[0005] Based on the above purpose, the present application provides a method for extracting data relationships enhanced by rule knowledge, including:

[0006] According to the structured knowledge graph of the head entity and the tail entity of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of the instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and based on the relationship of the instance, respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity;

[0007] Determine the relationship description of the instance from the unstructured knowledge text of each instance, input the instance and the relationship description into the preset text encoder, and obtain the instance representation and the relationship description representation of the instance; obtain the context semantics and the context semantics prototype of the instance by interacting the instance representation and the relationship description representation with each other;

[0008] For each instance, based on the head entity prototype, the tail entity prototype, and the context semantics prototype, respectively construct the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship, and determine the cross-entropy loss function according to the probability relationships;

[0009] Based on the instance representation of the instance and the instance representations of other instances, determine the instance-level contrastive learning loss function, and based on the context semantics prototype and the relationship description prototype of the obtained relationship, determine the category-level contrastive learning loss function;

[0010] Combine the cross - entropy loss function, the instance - level contrastive learning loss function, and the category - level contrastive learning loss function to obtain an objective function, and use the objective function in a relation extraction model to perform data relation extraction on the dataset to be extracted.

[0011] Further, input the head entity type set and the tail entity type set into a pre - set graph neural network encoder, and respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity based on the relation of the instance, including:

[0012] Input each head entity type in the head entity type set and each tail entity type in the tail entity type set into the graph neural network encoder respectively, and obtain the head entity type representation and the tail entity type representation as shown below:

[0013]

[0014] Among them, f1(*) represents the mapping method of the graph neural network encoder;

[0015] is the head entity type representation, C h represents the head entity type set, c 1 represents any type in C h ;

[0016] is the tail entity type representation, C t represents the tail entity type set, c 2 represents C t ;

[0017] Respectively use the head entity type representation and the tail entity type representation to construct the head entity prototype and the tail entity prototype as shown below:

[0018]

[0019] Among them, r represents any relation of the instance, S r represents the instance set regarding the relation r, and K represents the number of instances in S r ;

[0020] represents the head entity prototype, e h represents the head entity, represents the tail entity prototype, e t represents the tail entity.

[0021] Further, obtain the context semantics and the context semantic prototype of the instance by interacting the instance representation and the relation description representation, including:

[0022] Connect the head entity and the tail entity in the form of vectors to obtain the following entity representation:

[0023]

[0024] wherein, is the entity representation, R represents all relationship types corresponding to all the relationships, and d represents the embedding dimension of the text encoder;

[0025] Adopt the following first interaction method to interact the instance representation and the relationship description representation to obtain a refined instance representation:

[0026]

[0027] wherein, is the refined instance representation, and the subscript a r represents the relationship description regarding the relationship r, and α j represents the j-th instance weight among multiple instance weights; is the instance representation, is the relationship description representation, sum(*) represents the row summation function, [j:] represents the j-th row of the matrix, and the subscript T represents the operation of transposing the matrix;

[0028] Adopt the following second interaction method to interact the instance representation and the relationship description representation to obtain an instance-aware relationship description representation:

[0029]

[0030] wherein, is the instance-aware relationship description representation, and β j represents the j-th attention weight among multiple attention weights;

[0031] Utilize the refined instance representation and the instance-aware relationship description representation, and adopt the following formula to determine the context semantics:

[0032]

[0033] wherein, is the context semantics representation, and Mul(*) represents the multi-layer perceptron;

[0034] Represent the context semantics prototype by the following formula:

[0035]

[0036] wherein, represents the context semantics prototype.

[0037] Further, based on the head entity prototype, the tail entity prototype, and the context semantic prototype, a probability relationship in which the head entity, the tail entity type, and the context semantics belong to the relationship is constructed respectively, including:

[0038] Using the head entity prototype, the tail entity prototype, and the context semantic prototype respectively, a probability relationship in which the head entity, the tail entity type, and the context semantics belong to the relationship is constructed as follows:

[0039]

[0040] where N represents the number of all the relationship types, represents the first probability that the head entity type belongs to the relationship r, represents the second probability that the tail entity type belongs to the relationship r, represents the third probability that the context semantics belongs to the relationship r.

[0041] Further, a cross-entropy loss function is determined according to the probability relationship, including:

[0042] Using the first probability, the second probability, and the third probability, the following formula is adopted to determine the comprehensive probability that the instance P belongs to the relationship r:

[0043]

[0044] where p r represents the comprehensive probability;

[0045] Based on the comprehensive probability, the following formula is adopted to determine the cross-entropy loss function:

[0046]

[0047] where L CE represents the cross-entropy loss function, P represents the support set, and p represents any instance in the support set.

[0048] Further, based on the instance representation of this instance and the instance representations of other instances, an instance-level contrastive learning loss function is determined, and based on the context semantic prototype and the relationship description prototype of the obtained relationship, a class-level contrastive learning loss function is determined, including:

[0049] Using the instance representation and the instance representations of any other instances used for contrastive learning with this instance, the following instance-level contrastive learning loss function is constructed:

[0050]

[0051] Among them, L ins represents the instance-level contrastive learning loss function, and τ1 represents the first temperature hyperparameter;

[0052] Using the instance-aware relationship description representation, determine the instance-aware relationship description prototype of the relationship r as shown below:

[0053]

[0054] Among them, represents the instance-aware relationship description prototype;

[0055] Using the context semantic prototype and the instance-aware relationship description prototype, construct the class-level contrastive learning loss function as follows:

[0056]

[0057] Among them, L cate represents the class-level contrastive learning loss function, and τ2 represents the second temperature hyperparameter.

[0058] Furthermore, combining the cross-entropy loss function, the instance-level contrastive learning loss function, and the class-level contrastive learning loss function, obtain the objective function, including:

[0059] Using the cross-entropy loss function, the instance-level contrastive learning loss function, and the class-level contrastive learning loss function, adopt the formula as shown below to determine the objective function:

[0060] L = L CE + L ins + L cate ,

[0061] Among them, L represents the objective function.

[0062] Based on the same inventive concept, the present application also provides a data relationship extraction device based on rule knowledge enhancement, including: a structured knowledge graph encoding module, an unstructured knowledge text encoding module, a logical rule reasoning module, a subtle difference perception module, and an objective function determination module;

[0063] Among them, the structured knowledge graph encoding module is configured to, according to the structured knowledge graph of the head entity and the tail entity of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of the instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity based on the relationship of the instance;

[0064] The unstructured knowledge text encoding module is configured to determine the relationship description of each instance from the unstructured knowledge text of each instance, input the instance and the relationship description into a preset text encoder, and obtain the instance representation and the relationship description representation of the instance; the context semantics and the context semantic prototype of the instance are obtained by interacting the instance representation and the relationship description representation with each other;

[0065] The logical rule reasoning module is configured to, for each instance, respectively construct the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship based on the head entity prototype, the tail entity prototype, and the context semantic prototype, and determine the cross-entropy loss function according to the probability relationships;

[0066] The subtle difference perception module is configured to determine the instance-level contrastive learning loss function based on the instance representation of the instance and the instance representations of other instances, and determine the category-level contrastive learning loss function based on the context semantic prototype and the relationship description prototype of the obtained relationship;

[0067] The objective function determination module is configured to combine the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function to obtain an objective function, and use the objective function in the relationship extraction model to perform data relationship extraction on the data set to be extracted.

[0068] Based on the same inventive concept, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the data relationship extraction method based on rule knowledge enhancement as described in any one of the above is implemented.

[0069] Based on the same inventive concept, the present application further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the data relationship extraction method based on rule knowledge enhancement as described above.

[0070] As can be seen from the above, the data relationship extraction method and related device provided in this application, based on the relationships among the head entity, tail entity, and context semantics of each instance, comprehensively consider the structured knowledge graph and unstructured knowledge text to calculate the probability that the instance belongs to the specified relationship. By combining the probabilities that the head entity, tail entity, and context semantics respectively belong to the specified relationship in the calculation, the calculated probability that the instance belongs to the specified relationship can evaluate the probability relationship with the specified relationship from three perspectives of the head entity, tail entity, and context semantics of the entire instance. Further, the cross-entropy loss function constructed based on this probability relationship is used to constrain the instance from three directions of the head entity, tail entity, and context semantics, that is, a consistency evaluation criterion is added to the parameters in the relationship extraction model to guide the optimization of the confusion problem caused by word repetition.

[0071] Furthermore, using the instance representation of this instance and the instance representations of other instances, a contrastive learning loss function regarding the distance between instances is constructed, and using the context semantic prototype and the relationship description prototype, a hierarchical contrastive learning loss function regarding the matching degree between the context semantics and the specified relationship is constructed, realizing the differences between different instances and the differences between the context semantics and the specified relationship.

[0072] Furthermore, through the objective function obtained by combining the three loss functions, while solving the confusion problem caused by word repetition, the problem of relationship confusion caused by entity matching is solved, effectively eliminating prediction chaos. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] In order to more clearly illustrate the technical solutions in this application or related technologies, the following will briefly introduce the drawings required for use in the embodiments or related technology descriptions. Obviously, the drawings in the following descriptions are only the embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0074] Figure 1 It is a flowchart of the data relationship extraction method based on rule knowledge enhancement according to the embodiment of this application;

[0075] Figure 2 It is a schematic structural diagram of the data relationship extraction device based on rule knowledge enhancement according to the embodiment of this application;

[0076] Figure 3 It is a schematic structural diagram of the electronic device according to the embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0077] To make the objectives, technical solutions, and advantages of the present application more clear and understandable, the following further elaborates on the present application in detail with reference to specific embodiments and the accompanying drawings.

[0078] It should be noted that unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should have the ordinary meanings understood by those of ordinary skill in the field to which the present application pertains. The terms "first", "second", and similar terms used in the embodiments of the present application do not denote any order, quantity, or importance, but are merely used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. Words such as "connected" or "linked" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Upper", "lower", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0079] As described in the background art section, the related rule-based knowledge-enhanced data relation extraction methods are still difficult to meet the needs of relation extraction for data, especially small-sample data, in actual production.

[0080] The applicant found in the process of implementing the present application that the main problems existing in the related rule-based knowledge-enhanced data relation extraction methods are as follows:

[0081] In related data relation extraction technologies, especially in small-sample relation extraction with limited data volume, whether it is small-sample relation extraction based on naive ML (Meta-Learn, meta-learning) or small-sample relation extraction based on external knowledge-enhanced ML, the problem of prediction confusion caused by insufficient data resources will inevitably occur.

[0082] Specifically, in small-sample relation extraction, naive meta-learning generally uses the original text as the only input to infer the relation type, which can be roughly divided into two types: optimization-based ML and metric-based ML. The focus of optimization-based ML is to find good initialization points for the parameters, which can be easily generalized to new relation types in a few gradient steps; metric-based ML aims to design a metric function that can clearly measure the distance between instances in the embedding space.

[0083] It can be seen that these ML methods cannot perform reliable reasoning in the case of insufficient resources, and are prone to falling into shallow reasoning, resulting in prediction confusion, that is, prediction chaos.

[0084] The applicant also found in the research that in other small-sample relation extractions, such as small-sample relation extraction based on external knowledge-enhanced ML, according to the data structure, external knowledge can be divided into unstructured text knowledge and structured knowledge graphs. Essentially, the above-mentioned ML method based on external knowledge enhancement still builds on shallow reasoning and has the problem of prediction confusion.

[0085] Based on this, the inventors found that the problem of prediction confusion caused by word repetition and entity matching errors can be alleviated by combining logical rule reasoning and subtle difference perception.

[0086] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0087] Reference Figure 1 , a data relation extraction method based on rule knowledge enhancement in an embodiment of the present application, can also be called: Discriminative Rule-based Knowledge, (DRK, a small-sample relation extraction method based on rule knowledge enhancement), and specifically includes the following steps:

[0088] Step S101: According to the structured knowledge graphs of the head entities and tail entities of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of the instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and based on the relation of the instance, respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity.

[0089] In the embodiments of the present application, the relation extraction model for extracting data relations is applied to small-sample data, and small-sample data containing multiple sentences is taken as a specific example.

[0090] Specifically, in this example, there are two data sets, a support set and a query set. Among them, the support set, denoted as P, is used to train the relation extraction model, and the query set, denoted as Q, is used to test the relation extraction model.

[0091] Furthermore, in each of the above data sets, there are multiple sentences. Let s represent any sentence among them. The sentence s has a given word length L s , and has a corresponding head entity e h and a tail entity e t , that is to say, Based on this, it can be seen that the goal of the above-mentioned extraction of data relations is specifically to extract the relation triple: (e h , e t , r), where r is the relation label, which can describe the relation between instances and belongs to a predefined relation label set

[0092] Furthermore, in few-shot relation extraction, for the meta-task under the N-way, K-shot setting, where, in a broad sense, N-way (abbreviated as N in this embodiment) represents the number of categories, and in this embodiment, it can represent the number of relation types of different relations; in a broad sense, K-shot (abbreviated as K in this embodiment) represents the number of samples in each category, and in this embodiment, it can represent the number of different instances included in each relation; based on this, it can be seen that the given support set can be expressed as: Among its N relations, each relation satisfies: and contains K instances, where R represents all relation types.

[0093] It can be seen that few-shot relation extraction aims to predict the relation labels of instances in the query set or other datasets to be predicted based on limited data.

[0094] In this embodiment, for the external knowledge formed by the support set, query set, or other datasets to be predicted, according to the specific data structure, it can be divided into a structured knowledge graph and unstructured knowledge text, where the unstructured knowledge text is denoted as G t ; the structured knowledge graph includes a structured entity-level knowledge graph, denoted as G e , and a structured ontology-level knowledge graph, denoted as G o .

[0095] Specifically, the structured knowledge graph can be represented by relation triples;

[0096] For example, G e can be represented as relation triples: {(e h , e t , r) ∈ ε × ε × R e},where ε and R e represent the entity-level node set and entity-level relation set respectively;

[0097] G o can be represented as relation triples: where and R o represent the ontology-level node set and ontology-level relation label set respectively;

[0098] It should be noted that there is a relationship between ε and namely: That is:

[0099] Furthermore, for G t , it specifically represents containing L rSet of sentence pair relationships of a single word, that is, the description of each relationship r in R.

[0100] In this embodiment, during the training process of the relationship extraction model, based on the given support set, for each instance in its instance set S r For each instance, it includes multiple entities including a head entity and a tail entity, that is, multiple words, and each entity belongs to a certain group of predefined entity types.

[0101] Further, for each instance, taking its head entity e h as an example, the ontology-level knowledge graph G o that is available can be used to construct a set of head entity types corresponding to the head entity, and the relationship between the head entity and the corresponding set of head entity types can be represented by the following formula:

[0102] C h = B h (e h )

[0103] where e h represents the set of head entity types, and B h is a connection function that describes the relationship between e h and C h .

[0104] Similarly, for the tail entity e t in the instance, the ontology-level knowledge graph G o that is available can also be used to construct a set of tail entity types corresponding to the tail entity, and the relationship between the tail entity and the corresponding set of tail entity types can be represented by the following formula:

[0105] C t = B t (e t )

[0106] where e t represents the set of head entity types, and B t is a connection function that describes the relationship between e t and C t .

[0107] Further, the obtained set of head entity types and set of tail entity types are input into a pre-trained graph neural network encoder. In this embodiment, f1 is used to represent the mapping relationship in the graph neural network encoder. Based on this, combined with the output of the graph neural network encoder, the following formula can be used to obtain the head entity type representation:

[0108]

[0109] where, For the head entity type representation, c 1 Represents C h Any type in; |C h | represents the number of elements in this type set.

[0110] It can be seen that for any relationship r, its corresponding instance set S r Contains K instances. Therefore, the head entity type prototype of relationship r (simply referred to as the head entity prototype in this embodiment) can be represented by the following formula:

[0111]

[0112] Among them, K represents S r The number of instances in, Represents the head entity prototype.

[0113] Similarly, for the tail entity type prototype (simply referred to as the tail entity prototype in this embodiment), it can be represented by the following formula:

[0114]

[0115] Among them, Represents the tail entity prototype.

[0116] It should be noted that based on the above training process based on the support set, it can be known that after the training process is completed, in the testing process of the query set, the same method can be adopted: based on the ontology knowledge graph in the query set, construct the head entity type set and the tail entity type set corresponding to the head entity and the tail entity in the query set respectively, and further input them into the graph neural network to respectively obtain the head entity type representation in the query set: And, the tail entity type representation:

[0117] Based on this, the head entity type prototypes corresponding to the head entity and the tail entity in the query set can be determined respectively: And, the tail entity type prototype:

[0118] Step S102: Determine the relationship description of the instance from the unstructured knowledge text of each instance, input the instance and the relationship description into a pre-set text encoder to obtain the instance representation and the relationship description representation of the instance; obtain the context semantics and the context semantic prototype of the instance by interacting the instance representation and the relationship description representation.

[0119] In an embodiment of the present application, during the training process of the relation extraction model, based on the support set of the given relation in the above steps, the separability of the relation can also be increased by combining the above relation with unstructured knowledge text.

[0120] Specifically, based on the instances of the given relation r in the support set: The relation description a corresponding to the relation r can be retrieved from the available unstructured knowledge text G t . r

[0121] Furthermore, the instance and the relation are respectively input into a pre-trained text encoder. In this embodiment, f2 represents the mapping relationship in the text encoder. Based on this, through the mapping of the graph text encoder, an instance representation can be obtained: And, a relation description representation: where d represents the embedding dimension of f2.

[0122] Furthermore, to highlight the entities, the vector representations corresponding to the start positions of the head entity and the tail entity of the instance can be concatenated to obtain an instance representation: In this entity representation, R represents all arbitrary relation types corresponding to all the above relations.

[0123] It can be determined that the above relation description a r specifically describes the relation r. Based on this relation description, the above instance representation can be further refined.

[0124] Specifically, taking the instance as an example, the refined instance representation can be described by the following formula:

[0125]

[0126] where sum(*) is a row summation function, [j:] represents the j-th row of the matrix, and α j represents the j-th instance weight among multiple instance weights. Therefore, this instance weight focuses on the words in the instance; is the refined instance representation, and the subscript T represents the operation of transposing the matrix.

[0127] It can be seen that the relation description can be regarded as a highly concise summary, so its semantics need to be expressed through instances.

[0128] Specifically, for a specified relation r, based on each instance representation the attention to its relation description a r can obtain an instance-aware relation description, which is represented by the following formula:​

[0129]

[0130] Among them, is the instance-aware relationship description representation, and β j represents the j-th attention weight among multiple attention weights.

[0131] It can be seen that the above formula uses the relationship description and the instance representation to solidify its perception weight, and relies on this attention weight to determine the value of the corresponding instance-aware relationship description from the relationship description representation.

[0132] Furthermore, for the context semantic information carried by the context in the text, the separability of the relationship description can be increased by obtaining the computational relationship between the context semantic and the relationship description.

[0133] Specifically, by interacting the instance with the relationship description, the context semantic can be defined by the following formula:

[0134]

[0135] Among them, is the context semantic representation, Mul(*) represents a pre-set multi-layer perceptron, and this multi-layer perceptron can convert the embedding dimension from d to 3d; furthermore, among them

[0136] Furthermore, similar to the above steps, according to the obtained context semantic representation, the following context semantic prototype about the relationship r can be obtained:

[0137]

[0138] Among them, represents this context semantic prototype.

[0139] It should be noted that after the training process is completed, during the testing process of the query set, since there is no relationship description for any instance in the query set, therefore, when defining the context semantic representation of the instance in the query set, the average pooling layer can be used to replace the refined instance representation in the above training process of the support set, and the multi-layer perceptron in the above formula is removed when determining the context semantic representation.

[0140] Based on this, during the testing process of the query set, for the instance q in the query set, the context semantic representation of this instance q can be determined: And the context semantic prototype about the relationship r corresponding to this instance q is obtained and represented as:

[0141] Step S103: For each of the instances, based on the head entity prototype, the tail entity prototype, and the context semantic prototype, construct the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship respectively, and determine the cross-entropy loss function according to the probability relationships.

[0142] In the embodiments of the present application, to solve the problem of simple reasoning confusion caused by word repetition, based on the head entity prototype, the tail entity prototype, and the context semantic prototype obtained in the above steps, it can be solved by judging the probability relationships between the head entity, the tail entity, and the context semantics in the instance and the relationship description respectively.

[0143] For example, during the training process of the support set, taking the "Mother relationship" of the word "Mother" as an example, whether this instance represents this "Mother relationship", the word Mother must meet the following three conditions: the head entity of the instance is of the predefined person type, the tail entity is of the predefined person type, and the context semantics describe the predefined "Mother relationship"; according to this logical rule, these three conditions can be correspondingly transformed into three probabilities.

[0144] Specifically, based on the determined head entity prototype, tail entity prototype, and context semantic prototype, the first probability that the head entity type belongs to the relationship r, the second probability that the tail entity type belongs to the relationship r, and the third probability that the context semantics belong to the relationship r can be determined respectively.

[0145] Furthermore, the first probability can be expressed by the following formula:

[0146]

[0147] The second probability can be expressed by the following formula:

[0148]

[0149] The third probability can be expressed by the following formula:

[0150]

[0151] Wherein, represents the first probability, represents the second probability, represents the third probability.

[0152] Furthermore, based on the determined first probability, second probability, and third probability, the probability that the instance represents belonging to the relationship r can be calculated by the following formula:

[0153]

[0154] Furthermore, based on the above-determined probability relationships, the following cross-entropy loss function can be determined, and this cross-entropy loss function is used to optimize the parameters in the relation extraction model:

[0155]

[0156] It should be noted that the above first probability, second probability, and third probability only represent the ways to establish the corresponding probability relationships during the training of the relation extraction model. When testing the query set, specific calculations of the probability relationships are required. For the query instance q, the first test probability that the head entity type belongs to the relation r, the second test probability that the tail entity type belongs to the relation r, and the third test probability that its context semantics belong to the relation r can be expressed by the following formulas respectively:

[0157]

[0158] Based on this, during the testing process of the query set, based on the above first test probability, second test probability, and third test probability, the probability that the instance q in the query set belongs to the relation r can be calculated by the following formula:

[0159]

[0160] Furthermore, based on the above-determined probability relationships, the following cross-entropy loss function can be determined, and this cross-entropy loss function is used to optimize the parameters in the relation extraction model:

[0161]

[0162] It can be seen that in this embodiment, the probabilities that the head entity, tail entity, and context semantics in the instance belong to the specified relation r are determined according to the rules in the structured knowledge graph and unstructured knowledge text. It can be seen that the probability that the instance belongs to the relation r determined by integrating the above respective probabilities is based on the reasoning of rule logic. By comprehensively considering the respective effects of each entity and context semantics in the instance on the specified relation description, the problem of reasoning confusion caused by word repetition is solved.

[0163] Step S104: Determine the instance-level contrastive learning loss function based on the instance representation of this instance and the instance representations of other instances, and determine the class-level contrastive learning loss function based on the context semantic prototype and the relation description prototype of the obtained relation.

[0164] In the embodiments of the present application, the cross-over loss function determined in the above steps is still unable to solve the relationship confusion problem caused by matching errors between multiple entities, that is, multiple words in a sentence, in relationship extraction. This type of relationship confusion problem can be solved by hierarchical contrastive learning. In this embodiment, the subtle differences in relationships between instances can be explored from two perspectives: the instance layer (also referred to as the instance level in this embodiment) and the category layer (also referred to as the category level in this embodiment).

[0165] Specifically, instance-level based mining can be achieved through instance-level contrastive learning.

[0166] In this step, the specified instance For example, when distinguishing the difference between this instance and any other instance, any other instance is Represents, and further determines the instance and examples Instance representation of .

[0167] Furthermore, based on the example and examples , construct the instance-level contrastive learning loss function as shown below:

[0168]

[0169] Among them, L ins represents the instance-level contrastive learning loss function, and τ1 represents the first temperature hyperparameter in the instance-level contrastive learning loss function.

[0170] It can be determined that if and belong to the same relation, then they constitute a positive example, L ins This can shorten the distance between positive examples.

[0171] In this step, category-level based mining can be achieved through category-level contrastive learning.

[0172] Specifically, for the above specified example Based on the instance-aware relationship description representation determined in the previous step The instance-aware relationship description prototype can be determined as follows:

[0173]

[0174] in, Represents instance-aware relation description prototype.

[0175] It can be seen that the instance-aware relationship describes the prototype Summarize the instance-aware features of the specified relationship r. Specifically, when confusion is encountered in the prediction of relation extraction, the instance-aware features can help the model distinguish the subtle differences between instances.

[0176] It can be determined that among different relation categories, the context semantic prototype determined in the foregoing steps must be close to its corresponding instance-aware relation description prototype and far from other instance-aware relation description prototypes.

[0177] Furthermore, based on the context semantic prototype and the instance-aware relation description prototype construct the category-level contrastive learning loss function as shown below:

[0178]

[0179] where L cate represents the category-level contrastive learning loss function, and τ2 represents the second temperature hyperparameter in this category-level contrastive learning loss function

[0180] Step S105: Combine the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function to obtain an objective function, and use the objective function in the relation extraction model to perform data relation extraction on the dataset to be extracted.

[0181] In the embodiments of the present application, based on the determined cross-entropy loss function, instance-level contrastive learning loss function, and category-level contrastive loss function above, an objective function for the relation extraction model can be obtained.

[0182] It can be seen that the cross-entropy loss function characterizes the consistency between the head entity, the tail entity, and the context semantics in the specified instance. That is to say, through the participation of this cross-entropy loss function, the confusion problem caused by word repetition is solved; furthermore, the instance-level contrastive learning loss function guides the parameter optimization of the relation extraction model from the degree of correlation in the relation between two instances; furthermore, the category-level contrastive learning loss function distinguishes the differences between instances from the distance between the context semantics and the relation description.

[0183] Based on this, the following formula can be adopted to fuse the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive loss function to obtain an objective function:

[0184] L = L CE + L ins + L cate ,

[0185] where L represents the objective function

[0186] In this embodiment, based on the determined objective function, it can be applied to the relation extraction model to predict the query set, so as to complete the test of the relation extraction model, and apply the tested relation extraction model to the relation extraction of other data sets.

[0187] It can be seen that the rule knowledge-enhanced data relation extraction method of the embodiment of the present application, based on the relationships among the head entity, tail entity and context semantics of each instance, comprehensively considers the structured knowledge graph and unstructured knowledge text to calculate the probability that the instance belongs to the specified relation. By combining the probabilities that the head entity, tail entity and context semantics respectively belong to the specified relation in the calculation, the calculated probability that the instance belongs to the specified relation can evaluate the probability relationship between the entire instance and the specified relation from three perspectives of the head entity, tail entity and context semantics, and further enables the cross-entropy loss function constructed based on this probability relationship to implement constraints on the instance from three directions of the head entity, tail entity and context semantics, that is, adding a consistency evaluation criterion for parameters in the relation extraction model to guide the optimization of the confusion problem caused by word repetition.

[0188] Furthermore, using the instance representation of this instance and the instance representations of other instances, a contrastive learning loss function regarding the distance between instances is constructed, and using the context semantic prototype and relation description prototype, a discriminative contrastive learning loss function regarding the matching degree between the context semantics and the specified relation is constructed, realizing the differences between different instances and the differences between the context semantics and the specified relation.

[0189] Furthermore, through the objective function obtained by combining the three loss functions, while solving the confusion problem caused by word repetition, the problem of relation confusion caused by entity matching is solved.

[0190] It should be noted that the method of the embodiment of the present application can be executed by a single device, such as a computer or a server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In this case of a distributed scenario, one of the multiple devices can only execute one or more steps of the method of the embodiment of the present application, and these multiple devices will interact with each other to complete the described method.

[0191] It should be noted that some embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the above embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0192] Based on the same inventive concept, corresponding to any of the above-described method embodiments, an embodiment of the present application further provides a data relationship extraction device based on rule knowledge enhancement.

[0193] Referring to Figure 2 , the data relationship extraction device based on rule knowledge enhancement includes: a structured knowledge graph encoding module 201, an unstructured knowledge text encoding module 202, a logical rule reasoning module 203, a subtle difference perception module 204, and an objective function determination module 205;

[0194] Among them, the structured knowledge graph encoding module 201 is configured to, according to the structured knowledge graphs of the head entities and tail entities of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of the instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and based on the relationship of the instance, respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity;

[0195] The unstructured knowledge text encoding module 202 is configured to, from the unstructured knowledge text of each instance, determine the relationship description of the instance, input the instance and the relationship description into the preset text encoder, and obtain the instance representation and the relationship description representation of the instance; by interacting the instance representation and the relationship description representation, obtain the context semantics and the context semantics prototype of the instance;

[0196] The logical rule reasoning module 203 is configured to, for each instance, respectively construct the probability relationship that the head entity, the tail entity type, and the context semantics belong to the relationship based on the head entity prototype, the tail entity prototype, and the context semantics prototype, and determine the cross-entropy loss function according to the probability relationship;

[0197] The subtle difference perception module 204 is configured to determine the instance-level contrastive learning loss function based on the instance representation of the instance and the instance representations of other instances, and determine the category-level contrastive learning loss function based on the context semantics prototype and the relationship description prototype of the obtained relationship;

[0198] The target function determination module 205 is configured to obtain a target function by combining the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function, and use the target function in the relation extraction model to perform data relation extraction on the dataset to be extracted.

[0199] As an optional embodiment, the structured knowledge graph encoding module 201 is specifically configured to:

[0200] Input each head entity type in the head entity type set and each tail entity type in the tail entity type into the graph neural network encoder, and obtain the following head entity type representation and tail entity type representation:

[0201]

[0202] Wherein, f1(*) represents the mapping method of the graph neural network encoder;

[0203] is the head entity type representation, C h represents the head entity type set, c 1 represents any type in C h ;

[0204] is the tail entity type representation, C t represents the tail entity type set, c 2 represents any type in C t ;

[0205] Construct the following head entity prototype and tail entity prototype by using the head entity type representation and the tail entity type representation respectively:

[0206]

[0207] Wherein, r represents any relation of the instance, S r represents the instance set regarding the relation r, and K represents the number of instances in S r ;

[0208] represents the head entity prototype, e h represents the head entity, represents the tail entity prototype, e t represents the tail entity.

[0209] As an optional embodiment, the unstructured knowledge text encoding module 202 is specifically configured to:

[0210] Connect the head entity and the tail entity in the form of a vector to obtain the following entity representation:

[0211]

[0212] where is the entity representation, R represents all relationship types corresponding to all the relationships, and d represents the embedding dimension of the text encoder;

[0213] Adopt the following first interaction method to interact the instance representation and the relationship description representation to obtain a refined instance representation:

[0214]

[0215] where is the refined instance representation, the subscript a r represents the relationship description regarding the relationship r, and α j represents the j-th instance weight among multiple instance weights; is the instance representation, is the relationship description representation, sum(*) represents the row summation function, [j:] represents the j-th row of the matrix, and the subscript T represents the operation of transposing the matrix;

[0216] Adopt the following second interaction method to interact the instance representation and the relationship description representation to obtain an instance-aware relationship description representation:

[0217]

[0218] where is the instance-aware relationship description representation, and β j represents the j-th attention weight among multiple attention weights;

[0219] Use the refined instance representation and the instance-aware relationship description representation, and adopt the following formula to determine the context semantics:

[0220]

[0221] where is the context semantics representation, and Mul(*) represents a multi-layer perceptron;

[0222] The context semantics prototype is represented by the following formula:

[0223]

[0224] where represents the context semantics prototype.

[0225] As an optional embodiment, the logic rule inference module 203 is specifically configured to:

[0226] Respectively utilize the head entity prototype, the tail entity prototype, and the context semantic prototype to construct the following probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship:

[0227]

[0228]

[0229] where N represents the number of all the relationship types, represents the first probability that the head entity type belongs to the relationship r, represents the second probability that the tail entity type belongs to the relationship r, represents the third probability that the context semantics belongs to the relationship r.

[0230] Furthermore, utilize the first probability, the second probability, and the third probability, and adopt the following formula to determine the comprehensive probability that this instance P belongs to the relationship r:

[0231]

[0232] where p r represents the comprehensive probability;

[0233] Based on the comprehensive probability, adopt the following formula to determine the cross-entropy loss function:

[0234]

[0235] where L CE represents the cross-entropy loss function, P represents the support set, and p represents any instance in the support set.

[0236] As an optional embodiment, the subtle difference perception module 204 is specifically configured to:

[0237] Utilize the instance representation and the instance representations of any other instances used for contrastive learning with this instance to construct the following instance-level contrastive learning loss function:

[0238]

[0239] where L ins represents the instance-level contrastive learning loss function, and τ1 represents the first temperature hyperparameter;

[0240] Using the instance-aware relationship description representation, determine the instance-aware relationship description prototype of the relationship r as shown below:

[0241]

[0242] where represents the instance-aware relationship description prototype;

[0243] Construct the following category-level contrastive learning loss function using the context semantic prototype and the instance-aware relationship description prototype:

[0244]

[0245] where L cate represents the category-level contrastive learning loss function, and τ2 represents the second temperature hyperparameter.

[0246] As an optional embodiment, the objective function determination module 205 is specifically configured to:

[0247] Using the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function, adopt the following formula to determine the objective function:

[0248] L = L CE + L ins + L cate ,

[0249] where L represents the objective function.

[0250] For the convenience of description, when describing the above device, it is divided into various modules according to functions and described separately. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0251] The device in the above embodiment is used to implement the corresponding rule knowledge-enhanced data relationship extraction method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0252] Based on the same inventive concept, corresponding to the method in any of the above embodiments, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the rule knowledge-enhanced data relationship extraction method in any of the above embodiments.

[0253] Figure 3Shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. Among them, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other inside the device through the bus 1050.

[0254] The processor 1010 can be implemented in ways such as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.

[0255] The memory 1020 can be implemented in forms such as a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 1020 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of the present application through software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0256] The input / output interface 1030 is used to connect to an input / output module to implement information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0257] The communication interface 1040 is used to connect to a communication module (not shown in the figure) to implement communication interaction between this device and other devices. Among them, the communication module can implement communication in a wired manner (such as USB, network cable, etc.) or in a wireless manner (such as a mobile network, WIFI, Bluetooth, etc.).

[0258] The bus 1050 includes a path for transmitting information between various components of the device (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0259] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiment of the present application, and does not necessarily include all the components shown in the figure.

[0260] The device in the above embodiment is used to implement the corresponding data relationship extraction method based on rule knowledge enhancement in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0261] Based on the same inventive concept, corresponding to the method in any of the above embodiments, the present application also provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the data relationship extraction method based on rule knowledge enhancement described in any of the foregoing embodiments.

[0262] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.

[0263] The computer instructions stored in the storage medium of the above embodiment are used to cause the computer to execute the data relationship extraction method based on rule knowledge enhancement described in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0264] Those of ordinary skill in the art should understand that the discussion of any of the above embodiments is only exemplary, and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; under the idea of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of brevity.

[0265] In addition, for simplicity of explanation and discussion, and so as not to make the embodiments of the present application difficult to understand, well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Further, the devices may be shown in block diagram form so as not to make the embodiments of the present application difficult to understand, and this also takes into account the fact that details regarding the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (i.e., these details should be fully within the understanding of those skilled in the art). In cases where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it will be apparent to those skilled in the art that the embodiments of the present application may be practiced without these specific details or with variations of these specific details. Accordingly, these descriptions are to be regarded as illustrative rather than restrictive.

[0266] Although the present application has been described in connection with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0267] Embodiments of the present application are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of the present application shall be included within the protection scope of the present application.

Claims

1. A method for extracting data relationships enhanced by rule knowledge, characterized in that Including: According to the structured knowledge graph of the head entity and the tail entity of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of the instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and based on the relationship of the instance, respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity, including: input each head entity type in the head entity type set and each tail entity type in the tail entity type set into the graph neural network encoder, and obtain the head entity type representation and the tail entity type representation as shown below: Among them, f1(*) represents the mapping method of the graph neural network encoder; is the head entity type representation, C h represents the set of head entity types, c 1 represents any type in C h ; is the tail entity type representation, C t represents the set of tail entity types, c 2 represents any type in C t ; Respectively use the head entity type representation and the tail entity type representation to construct the head entity prototype and the tail entity prototype as shown below: Among them, r represents any relationship of this instance, and S r represents the set of instances regarding the relationship r, and K represents the number of instances r contained in S; represents the prototype of the head entity, and e h represents the head entity, represents the prototype of the tail entity, and e t represents the tail entity; Determine the relationship description of the instance from the unstructured knowledge text of each instance, input the instance and the relationship description into the preset text encoder, and obtain the instance representation and the relationship description representation of the instance; obtain the context semantics and the context semantics prototype of the instance by interacting the instance representation and the relationship description representation with each other; For each instance, respectively construct the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship based on the head entity prototype, the tail entity prototype, and the context semantics prototype, and determine the cross-entropy loss function according to the probability relationships; Based on the instance representation of the instance and the instance representations of other instances, determine the instance-level contrast learning loss function, and based on the context semantics prototype and the relationship description prototype of the obtained relationship, determine the category-level contrast learning loss function; Combine the cross-entropy loss function, the instance-level contrast learning loss function, and the category-level contrast learning loss function to obtain the objective function, and use the objective function in the relationship extraction model to perform dataset relationship extraction on the data to be extracted.

2. The method according to claim 1, characterized in that, The obtaining the context semantics and the context semantics prototype of the instance by interacting the instance representation and the relationship description representation with each other includes: Connect the head entity and the tail entity in the form of a vector to obtain the entity representation as shown below: Among them, is the entity representation, R represents all relationship types corresponding to all the relationships, and d represents the embedding dimension of the text encoder; Adopt the following first interaction method to interact the instance representation and the relationship description representation to obtain a refined instance representation: Among them, is the refined instance representation, and the subscript a r represents the relationship description regarding the relationship r, and α j represents the j-th instance weight among multiple instance weights; is the instance representation, is the relationship description representation, sum(*) represents the row summation function, [j:] represents the j-th row of the matrix, and the subscript T represents the operation of transposing the matrix; Adopt the following second interaction method to interact the instance representation and the relationship description representation to obtain an instance-aware relationship description representation: Among them, is the instance-aware relationship description representation, and β j represents the j-th attention weight among multiple attention weights; Use the refined instance representation and the instance-aware relationship description representation, and adopt the following formula to determine the context semantics: Among them, is the context semantic representation, and Mul(*) represents a multi-layer perceptron; The context semantics prototype is represented by the following formula: Among them, represents the context semantic prototype.

3. The method according to claim 2, wherein The respectively constructing the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship based on the head entity prototype, the tail entity prototype, and the context semantics prototype includes: Respectively use the head entity prototype, the tail entity prototype, and the context semantics prototype to construct the probability relationships of the head entity, the tail entity type, and the context semantics belonging to the relationship as shown below: and where N represents the number of all the relationship types, represents the first probability that the head entity type belongs to the relationship r, represents the second probability that the tail entity type belongs to the relationship r, represents the third probability that the context semantics belongs to the relationship r.

4. The method according to claim 3, characterized in that, The determining the cross-entropy loss function according to the probability relationships includes: Using the first probability, the second probability, and the third probability, the following formula is adopted to determine the comprehensive probability that the instance P belongs to the relationship r: where p r represents the comprehensive probability; Based on the comprehensive probability, the following formula is adopted to determine the cross-entropy loss function: Among them, L CE represents the cross-entropy loss function, P represents the support set, and p represents any instance in the support set.

5. The method according to claim 3, characterized in that Based on the instance representation of this instance and the instance representations of other instances, an instance-level contrastive learning loss function is determined. Based on the context semantic prototype and the relationship description prototype of the obtained relationship, a category-level contrastive learning loss function is determined, including: Using the instance representation and the instance representations of any other instances used for contrastive learning with this instance, the following instance-level contrastive learning loss function is constructed: Among them, L ins represents the instance-level contrastive learning loss function, and τ1 represents the first temperature hyperparameter; Using the instance-aware relationship description representation, the following instance-aware relationship description prototype of the relationship r is determined: Among them, represents the instance-aware relationship description prototype; Using the context semantic prototype and the instance-aware relationship description prototype, the following category-level contrastive learning loss function is constructed: Among them, L cate represents the category-level contrastive learning loss function described above, and τ2 represents the second temperature hyperparameter.

6. The method according to claim 1, characterized in that, Combining the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function, the objective function is obtained, including: Using the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function, the following formula is adopted to determine the objective function: L = L CE + L ins + L cate , where L represents the objective function.

7. An apparatus for extracting data relationships enhanced by rule knowledge, comprising: A structured knowledge graph encoding module, an unstructured knowledge text encoding module, a logical rule reasoning module, a subtle difference perception module, and an objective function determination module; Among them, the structured knowledge graph encoding module is configured to, according to the structured knowledge graphs of the head entities and tail entities of each instance in the preset support set, respectively determine the head entity type set and the tail entity type set of this instance, input the head entity type set and the tail entity type set into the preset graph neural network encoder, and respectively obtain the head entity prototype and the tail entity prototype corresponding to the head entity and the tail entity based on the relationship of this instance, including: inputting each head entity type in the head entity type set and each tail entity type in the tail entity type set into the graph neural network encoder respectively, and obtaining the following head entity type representation and tail entity type representation: Among them, f1(*) represents the mapping method of the graph neural network encoder; is the head entity type representation, C h represents the set of head entity types, c 1 represents any type in C h ; is the tail entity type representation, C t represents the set of tail entity types, c 2 represents C t any type in; Using the head entity type representation and the tail entity type representation respectively, the following head entity prototype and tail entity prototype are constructed: Among them, r represents any relationship of this instance, and S r represents the set of instances regarding the relationship r, and K represents the number of instances r contained in S; represents the prototype of the head entity, and e h represents the head entity, represents the prototype of the tail entity, and e t represents the tail entity; The unstructured knowledge text encoding module is configured to determine the relationship description of this instance from the unstructured knowledge text of each instance, input this instance and the relationship description into the preset text encoder, and obtain the instance representation and the relationship description representation of this instance; the context semantics and context semantic prototype of this instance are obtained by interacting the instance representation and the relationship description representation with each other; The logical rule reasoning module is configured to, for each instance, respectively construct the probability relationship that the head entity, the tail entity type, and the context semantics belong to the relationship based on the head entity prototype, the tail entity prototype, and the context semantic prototype, and determine the cross-entropy loss function according to the probability relationship; The fine-grained difference perception module is configured to determine an instance-level contrastive learning loss function based on the instance representation of this instance and the instance representations of other instances, and determine a category-level contrastive learning loss function based on the context semantic prototype and the relation description prototype of the obtained relation; The objective function determination module is configured to combine the cross-entropy loss function, the instance-level contrastive learning loss function, and the category-level contrastive learning loss function to obtain an objective function, and use the objective function in a relation extraction model to perform data relation extraction on the dataset to be extracted.

8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable by the processor, characterized in that, When the processor executes the computer program, the method described in any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions for causing a computer to execute the method described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge graph representation learning method and system based on text graph enhancement

    CN114580638A

  • System and method for knowledge graph construction using capsule neural network

    US20220180065A1