A sparse relational reasoning method and device based on rule fusion coding
By adopting a sparse relationship method based on the rules -based fusion coding in natural corpus, obtain the frequent rules of the head entity, entity relationship, and tail entity, and use the right to re -coded physical relations to solve the problem of inefficient reasoning relationships in sparse data. Improve the accuracy and data mining quality of relational reasoning.
Patent Information
- Application Number
- CN202311578987.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2043-11-22
AI Technical Summary
The problem of inefficient acquisition of inference relationships in natural corpus of existing sparse features.
Adopt the method of sparse relationships based on rules -based fusion coding, obtain head entities, entity relationships, and tail entities from natural corpus, to obtain frequent rules for the contribution of computing entities. Code the physical relationship, and finally obtain the intervals of the relationship through training.
Improve the accuracy and integrity of the intercourse reasoning in the sparse data, improve the quality of data mining, and provide a data basis for the recommendation, prediction and query based on physical relations.
Smart Images

Figure CN117474105B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of entity relationship reasoning, and in particular to a sparse relationship reasoning method and device based on rule fusion coding. Background Art
[0002] Nowadays, relational reasoning has become an important requirement for big data mining in business areas such as social user profiling, financial risk assessment, and smart healthcare. The purpose is to infer the missing relationships between target entities based on various known related information, such as completing the target user's social network, inferring institutional financial relationships, and constructing associations between symptom and disease knowledge.
[0003] With the rapid development of natural language processing technology, the method of reasoning about entity relationships by mining semantic features has become a research hotspot and has been widely used. These models are often trained with a large amount of corpus data and are relational learning models that contain a large number of parameters. They usually require the support of a variety of external contextual information, which places high demands on the quantity and quality of the collection of training data and contextual information. However, in actual application scenarios, the data that can be publicly obtained often presents sparse features, and there is less relational information with learning value. Research on how to reason about the relationship between entities on sparse data can improve the accuracy and completeness of relational reasoning tasks such as social network user relationships, financial institution risk relationships, and medical knowledge relationships; and can be used as a means to improve the quality of data mining and provide a data basis for further recommendations, predictions, and queries based on entity relationships.
[0004] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention
[0005] The technical problem to be solved by the present invention is how to improve the inefficient acquisition of inference relations in natural corpus with existing sparse features.
[0006] In a first aspect, a sparse relational reasoning method based on rule fusion coding is provided, comprising:
[0007] Obtain head entities, entity relations, and tail entities based on natural language data;
[0008] According to the obtained head entity, entity relationship and tail entity, the contribution of the entity co-occurrence set of each entity is calculated, and the frequent rule set of the head entity and the frequent rule set of the tail entity are obtained according to the contribution, and the head entity is encoded according to the frequent rule set of the head entity to obtain the head entity encoding information, and the tail entity is encoded according to the frequent rule set of the tail entity to obtain the tail entity encoding information;
[0009] Obtain a first weight of the head entity relative to the entity relationship, and obtain a second weight of the tail entity relative to the entity relationship;
[0010] Encoding the entity relationship according to the first weight, the second weight, the head entity encoding information and the tail entity encoding information to obtain relationship encoding information;
[0011] Training the head entity encoding information, the tail entity encoding information and the relationship encoding information to obtain a relationship reasoning model;
[0012] The other head entities and other tail entities that need to be subjected to relational reasoning are input into the relational reasoning model to obtain the entity relations between the other head entities and other tail entities.
[0013] Preferably, the step of obtaining the head entity, entity relationship and tail entity according to the natural language material specifically includes:
[0014] Each sentence in the natural prediction is identified and extracted by manual method and / or annotation learning method to obtain the head entity, entity relationship and tail entity, and the knowledge triple (e) is obtained according to the head entity, entity relationship and tail entity in the same sentence. h , r r , e t );
[0015] Among them, e h is the head entity, r r is the entity relationship, e t The tail entity.
[0016] Preferably, all entities in the same sentence are regarded as co-occurrence entities, and the contribution of the entity co-occurrence set of each entity is calculated to obtain the frequent rule set of the head entity and the frequent rule set of the tail entity, which specifically includes:
[0017] According to all the acquired knowledge triples, the co-reality entity of each entity is acquired to obtain the co-reality entity set;
[0018] For each entity e * , get entity e * All sentences appearing in the natural corpus are regarded as co-occurring natural sentences;
[0019] For entity e * Each co-reality entity e * , obtain the co-reality entity e' and entity e * The number of occurrences of the co-reality entity e' is calculated as the number of occurrences of the co-reality entity e'. * The ratio of the number of co-occurring natural sentences is used as the candidate degree of the co-occurring entity e';
[0020] For entity e *For each co-reality entity e', obtain the co-reality entity e' and entity e * The number of times other co-reality entities in the co-reality entity set are co-reality entities with each other is calculated as the proportion of the number of times the co-reality entities are co-reality entities with each other. * The ratio of the number of co-occurring natural sentences is used as the coupling degree of the co-occurring entity e';
[0021] The candidate degree of the co-reality entity e' and the coupling degree of the co-reality entity e' are added to obtain the contribution degree of the co-reality entity e'. * The co-reality entity with the smallest contribution in the co-reality entity set is eliminated, and the remaining co-reality entities are all regarded as frequent co-reality entities, and the set of all the frequent co-reality entities is regarded as entity e * Frequent rule sets of
[0022] When the entity * If the contributions of all co-existing entities are the same, then entity e * All co-existing entities as entities e * Frequent rule sets of
[0023] When the entity * When the number of co-existing entities is 0, then the entity e * The frequent rule set of is the empty set.
[0024] Preferably, encoding the head entity according to the frequent rule set of the head entity to obtain the head entity encoding information, and encoding the tail entity according to the frequent rule set of the tail entity to obtain the tail entity encoding information specifically includes:
[0025] Perform initial encoding on each entity to obtain initial encoding information;
[0026] Encode according to the initialization coding information of each entity and the initialization coding information of all frequently co-existing entities in its own frequent rule set;
[0027] Among them, the head entity e h The encoding formula is as follows:
[0028]
[0029] in, is the initial encoding information of the head entity, k is the number of entities in the frequent rule set, For the head entity e h The initial coding information of each frequently co-existing entity, q is an integer greater than 0 and less than or equal to k; For the head entity e h The coded information;
[0030] Among them, the tail entity et The encoding formula is as follows:
[0031]
[0032] in, is the initial encoding information of the tail entity, k is the number of entities in the frequent rule set, For the tail entity e t Initial encoding information of each frequently co-present entity, q is an integer greater than 0 and less than or equal to k; For the tail entity e t The encoding information.
[0033] Preferably, the initial encoding of each entity to obtain initialization encoding information specifically includes:
[0034] Extract the words in each entity and convert them into vector form through the vector model as the initial coding information;
[0035] in, e 1i 、e 2i ,…e mi is the value of each dimension of the vector, m is the vector Dimension.
[0036] Preferably, the obtaining of the first weight of the head entity relative to the entity relationship and the obtaining of the second weight of the tail entity relative to the entity relationship specifically include:
[0037] According to all the acquired knowledge triples, for each entity relationship, the number of categories hs of the head entity in the same knowledge triplet as the entity relationship and the number of times |e the head entity of the i-th category and the entity relationship are in the same knowledge triplet are obtained h,i |, where i = 1, 2, ... hs, the first weight of each head entity category relative to the entity relationship is obtained according to the following formula:
[0038]
[0039] Among them, x hi is the first weight of the category of any head entity relative to the entity relationship;
[0040] Get the number of tail entity categories ts that are in the same knowledge triplet as the entity relationship, and the number of times the tail entity of the jth category and the entity relationship are in the same knowledge triplet |e t,j |, where j = 1, 2, ..., ts, the second weight of each tail entity category relative to the entity relationship is obtained according to the following formula:
[0041]
[0042] Among them, y tj is the second weight of the category of any tail entity relative to the entity relationship.
[0043] Preferably, encoding the entity relationship according to the first weight, the second weight, the head entity encoding information and the tail entity encoding information to obtain the relationship encoding information specifically includes:
[0044] The entity relationship is encoded according to the following formula to obtain the relationship encoding information:
[0045]
[0046] in, Encode information for the relationship, W rh and U rt is the training projection parameter.
[0047] Preferably, the step of training the head entity encoding information, the tail entity encoding information and the relationship encoding information to obtain a relationship reasoning model specifically includes:
[0048] Construct an error triplet that does not exist in the natural corpus, input both the knowledge triplet and the error triplet into the scoring model, and Make a judgment:
[0049] when , then the input instance is judged to be the correct instance;
[0050] when , then the input instance is judged to be an error instance;
[0051] According to the correct instance and the wrong instance, the W rh and U rt Perform training to obtain a relational reasoning model.
[0052] Preferably, the step of inputting other head entities and other tail entities that need to be subjected to relational reasoning into the relational reasoning model to obtain entity relationships between other head entities and other tail entities specifically includes:
[0053] After the other head entities and other tail entities that need to perform relational reasoning are input into the relational reasoning model, all types of entity relationships are traversed, the relational encoding information of all entity relationships is sorted according to possibility, the relational encoding information with the greatest possibility is output, and the relational encoding information with the greatest possibility is decoded to obtain the entity relationship between the other head entities and other tail entities.
[0054] In a second aspect, a sparse relational reasoning device based on rule fusion coding comprises at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the sparse relational reasoning method based on rule fusion coding.
[0055] The present invention provides a sparse relational reasoning method and device based on rule fusion coding, which obtains head entities, entity relationships and tail entities from natural corpus, obtains frequent rule sets of each entity by mining the co-occurrence rules of each entity, encodes each entity accordingly through the frequent rule set, and then encodes the entity relationship using the weight of each entity relative to the corresponding entity relationship, thereby training the encoding information of the entity and the encoding information of the entity relationship to obtain a relational reasoning model. The relational reasoning model can obtain relationships for other entities that need to be inferred, improves the problem of inefficient acquisition of reasoning relationships in natural corpus with existing sparse features, and can be used as a data mining method to provide a data basis for tasks such as recommendation, prediction and query based on entity relationships. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 It is a method flow chart of a sparse relational reasoning method based on rule fusion coding provided by an embodiment of the present invention;
[0058] Figure 2 It is a method flow chart of a frequent rule set generation method of a sparse relational reasoning method based on rule fusion coding provided by an embodiment of the present invention;
[0059] Figure 3 It is a flow chart of a method for calculating the weight of an entity relative to an entity relationship in a sparse relational reasoning method based on rule fusion coding provided by an embodiment of the present invention;
[0060] Figure 4 It is a relational reasoning model processing flow chart of a sparse relational reasoning method based on rule fusion coding provided by an embodiment of the present invention;
[0061] Figure 5 It is a schematic diagram of a sparse relational reasoning device based on rule fusion coding provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0063] In the description of the present invention, the terms "inside", "outside", "longitudinal", "lateral", "upper", "lower", "top", "bottom" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and do not require that the present invention must be constructed and operated in a specific orientation. Therefore, they should not be understood as limitations on the present invention.
[0064] The terms "first", "second", etc. in the present invention are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "plurality" means two or more.
[0065] In this application, unless otherwise specified or limited, the term "connection" should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection or an indirect connection through an intermediate medium. In addition, the term "coupling" can be a way of achieving electrical connection for signal transmission.
[0066] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0067] Embodiment 1:
[0068] The embodiment of the present invention provides a sparse relational reasoning method based on rule fusion coding, such as Figure 1 As shown, the method flow is as follows:
[0069] In step 101, a head entity, an entity relationship, and a tail entity are obtained according to natural language data.
[0070] In this embodiment, the natural corpus may be a natural corpus with sparse features, that is, a natural corpus containing a large number of entities and a small number of relationships. The natural corpus may include multiple sentences, some of which include the head entity, entity relationship and tail entity. The head entity is usually the initiator of the action, the entity relationship is usually the action itself, and the tail entity is usually the subject of the action. The above-mentioned head entity, entity relationship and tail entity are illustrated by example: for the sentence "Company A invests in Company B", "Company A" is the head entity, "investment" is the entity relationship, and "Company B" is the tail entity.
[0071] In this embodiment, there may be no entity relationship between most entities in the natural corpus, the categories of entity relationships are much smaller than the number of entities, and the entity relationships are usually concentrated between a small number of entities.
[0072] In step 102, based on the acquired head entity, entity relationship and tail entity, the contribution of the entity co-occurrence set of each entity is calculated, the frequent rule set of the head entity and the frequent rule set of the tail entity are obtained according to the contribution, the head entity is encoded according to the frequent rule set of the head entity to obtain the head entity encoding information, and the tail entity is encoded according to the frequent rule set of the tail entity to obtain the tail entity encoding information.
[0073] In this embodiment, the head entity and the tail entity can be collectively referred to as entities, and the co-occurrence rules of each entity are mined, that is, for an entity, all other entities that co-appear in the same sentence with this entity are obtained, and other entities that co-appear multiple times with the original entity are included in the frequent rule set. Since these entities have multiple relationships with the original entity, the original entity can be encoded through these entities. In this embodiment, the frequent rule set of each entity is obtained by calculating the contribution of the co-occurrence entities of each entity. Since the entities in the frequent rule set frequently have relationships with the original entity, the original entity can be described and encoded through the entities in the frequent rule set.
[0074] In step 103, a first weight of the head entity relative to the entity relationship is obtained, a second weight of the tail entity relative to the entity relationship is obtained, and the entity relationship is encoded according to the first weight, the second weight, the head entity encoding information and the tail entity encoding information to obtain the relationship encoding information.
[0075] Since the entity relationship in natural corpus includes multiple categories, different entity relationships may exist between the same pair of head entity and tail entity, and entity relationships of the same category may be related to different entities. Therefore, the entity relationship can be projected into different entities through the weights of the head entity of each category and the tail entity of each category for the entity relationship, so as to describe the entity relationship and encode the entity relationship.
[0076] In step 104, the head entity encoding information, the tail entity encoding information and the relationship encoding information are trained to obtain a relationship reasoning model.
[0077] In step 105, other head entities and other tail entities that need to be subjected to relational reasoning are input into the relational reasoning model to obtain entity relationships between the other head entities and other tail entities.
[0078] In this embodiment, the head entity, entity relationship and tail entity are obtained from the natural corpus, and the frequent rule set of each entity is obtained by mining the co-occurrence rules of each entity. Each entity is correspondingly encoded by the frequent rule set, and then the entity relationship is encoded by using the weight of each entity relative to the corresponding entity relationship. Thus, the encoding of the entity and the encoding of the entity relationship are trained to obtain a relationship reasoning model. The relationship reasoning model can obtain relationships for other entities that need to be inferred, which improves the problem of inefficient acquisition of reasoning relationships in natural corpus with existing sparse features, and can be used as a data mining method to provide a data basis for recommendation, prediction and query tasks based on entity relationships.
[0079] In this embodiment, for the head entity, entity relationship and tail entity obtained from the natural corpus, it is necessary to group the head entity, entity relationship and tail entity from the same sentence and related to each other into the same group to facilitate subsequent encoding and training. Therefore, this embodiment involves the following designs:
[0080] The step of obtaining the head entity, entity relationship and tail entity according to the natural language data specifically includes:
[0081] Each sentence in the natural prediction is identified and extracted by manual method and / or annotation learning method to obtain the head entity, entity relationship and tail entity, and the knowledge triple (e) is obtained according to the head entity, entity relationship and tail entity in the same sentence. h , r r , e t ), where e h is the head entity, r r is the entity relationship, e t The tail entity.
[0082] In this embodiment, various entities and entity relationships between entities that need to be inferred can be extracted from natural corpus by manual methods and / or annotation learning methods; the entity relationship includes a positive order relationship, that is, the head entity can be used as the initiator of the action but cannot be used as the subject of the action, and the tail entity can be used as the subject of the action but cannot be used as the initiator of the action. Examples of the positive order relationship are as follows: The knowledge triple for the positive order relationship can be (e h , r r , e t ), cannot be (e t , r r , e h ); The entity relationship also includes a reflexive relationship, that is, the head entity can be the initiator of the action or the subject of the action, and the tail entity can be the subject of the action or the initiator of the action. Examples of the reflexive relationship are as follows: The knowledge triple for the reflexive relationship can be (e h , rr , e t ), cannot be (e t , r r , e h ).
[0083] In this embodiment, before encoding the entity, it is necessary to mine the co-occurrence rules of the entity based on all the entities obtained in the natural corpus and the relationship between the entities, so as to obtain the strongly related entities corresponding to each entity. The original entity can be better encoded based on these strongly related entities. Therefore, this embodiment involves the following designs:
[0084] All entities in the same sentence are regarded as co-existing entities, and the frequent rule set of the head entity and the frequent rule set of the tail entity are obtained according to the natural corpus, such as Figure 2 As shown, the method flow includes:
[0085] In step 201, the co-reality entity of each entity is obtained according to all the acquired knowledge triples to obtain the co-reality entity set.
[0086] In this embodiment, the co-existing entity may be: entities in the same sentence are co-existing entities. * , traverse entity e * For all sentences that appear in natural corpus, if another entity e' is related to e * If they appear in the same natural sentence, then e' is called entity e * A common entity. In a natural sentence, e * There may be multiple co-real entities.
[0087] In step 202, for each entity e * , get entity e * All sentences appearing in the natural corpus are regarded as co-occurring natural sentences.
[0088] For example, the entity e * The co-occurrence in each natural sentence is recorded as follows:
[0089] (e * ,e1,e2),(e * ,e3),(e * ,e3,e5), (e * ,e4,e5);
[0090] Each bracket above represents an entity e * In a natural sentence, the co-existent situation (e * ,e1,e2) represents entity e *In a natural sentence, entity e1 and entity e2 appear together in the sentence. * , there are 4 statements recorded above, namely entity e * The total number of natural sentences is 4.
[0091] In step 203, for entity e * Each co-reality entity e * , obtain the co-reality entity e' and entity e * The number of occurrences of the co-reality entity e' is calculated as the number of occurrences of the co-reality entity e'. * The ratio of the number of co-occurring natural sentences is used as the candidate degree of the co-occurring entity e'.
[0092] Step 203 is described by way of example: for example, e1 only appears in (e * ,e1,e2), the candidacy is 25%; similarly, the candidacy of e2 is 25%, the candidacy of e3 is 50%, the candidacy of e4 is 25%, and the candidacy of e5 is 50%.
[0093] In step 204, for entity e * For each co-reality entity e', obtain the co-reality entity e' and entity e * The number of times other co-reality entities in the co-reality entity set are co-reality entities with each other is calculated as the proportion of the number of times the co-reality entities are co-reality entities with each other. * The ratio of the number of co-occurring natural sentences is used as the coupling degree of the co-occurring entity e'.
[0094] Step 204 is described by way of example: e1 co-occurs with the other four co-present entities e2, e3, e4 and e5 only if (e * ,e1,e2), accounting for 25% of the total number of natural sentences, that is, the coupling degree of e1 is 25%; similarly, the coupling degree of e2 is 25%, the coupling degree of e3 is 25%, the coupling degree of e4 is 25%, and the coupling degree of e5 is 50%.
[0095] In step 205, the candidate degree of the co-reality entity e' and the coupling degree of the co-reality entity e' are added to obtain the contribution degree of the co-reality entity e'. * The co-reality entity with the smallest contribution in the co-reality entity set is eliminated, and the remaining co-reality entities are all regarded as frequent co-reality entities, and the set of all the frequent co-reality entities is regarded as entity e * Frequent rule sets.
[0096] Step 205 is illustrated by way of example: the contribution of e1 is 50%, the contribution of e2 is 50%, the contribution of e3 is 75%, the contribution of e4 is 50%, and the contribution of e5 is 100%. Then, e1, e2, and e4 with the smallest contributions are eliminated, and entity e is obtained. * The frequent rule set of is {e3,e5}.
[0097] It should be noted that when the entity e * If the contributions of all co-existing entities are the same, then entity e * All co-existing entities as entities e * Frequent rule sets.
[0098] When the entity * When the number of co-existing entities is 0, then the entity e * The frequent rule set of is the empty set.
[0099] Among all the co-reality entities, some may be in the same sentence with the original entity for many times, and these co-reality entities are strongly correlated with the original entity; some may be seldom in the same sentence with the original entity, and these co-reality entities are weakly correlated with the original entity; some co-reality entities may also co-occur multiple times, and these co-reality entities are indirectly associated with the original entity; this embodiment needs to evaluate the importance of the co-reality entity of the original entity, so a contribution calculation method is designed to screen the co-reality entity as a frequent rule set of the original entity.
[0100] The step of encoding the head entity according to the frequent rule set of the head entity to obtain the head entity encoding information, and encoding the tail entity according to the frequent rule set of the tail entity to obtain the tail entity encoding information, specifically includes:
[0101] Each entity is initially encoded to obtain initialization encoding information.
[0102] Extract the words in each entity and convert them into vector form through the vector model As the initial encoding information.
[0103] in, e 1i 、e 2i ,…e mi is the value of each dimension of the vector, m is the vector Dimension.
[0104] Encoding is performed based on the initialization encoding information of each entity and the initialization encoding information of all frequently co-occurring entities in its own frequent rule set.
[0105] Among them, the head entity e h The encoding formula is as follows:
[0106]
[0107] in, is the initial encoding information of the head entity, k is the number of entities in the frequent rule set, For the head entity e h The initial coding information of each frequently co-existing entity, q is an integer greater than 0 and less than or equal to k; For the head entity e h The encoding information.
[0108] Among them, the tail entity e t The encoding formula is as follows:
[0109]
[0110] in, is the initial encoding information of the tail entity, k is the number of entities in the frequent rule set, For the tail entity e t Initial encoding information of each frequently co-present entity, q is an integer greater than 0 and less than or equal to k; For the tail entity e t The encoding information.
[0111] In this embodiment, since there are usually multiple categories of entity relationships in natural corpus, and the entities associated with each entity relationship are different, some entities are associated with the entity relationship of this category multiple times, while some entities may be associated with the entity relationship of this category only a few times or have nothing to do with the entity relationship of this category. Therefore, if it is necessary to describe the entity relationship through related entities in the encoding, it is necessary to obtain the weight relationship between various entities and the entity relationship, so as to perform corresponding encoding. Therefore, this embodiment involves the following design:
[0112] The first weight of the head entity relative to the entity relationship is obtained, and the second weight of the tail entity relative to the entity relationship is obtained, such as Figure 3 As shown, specifically including:
[0113] In step 301, based on all the acquired knowledge triples.
[0114] In step 302, for each entity relationship, the number of categories of the head entity in the same knowledge triplet as the entity relationship is obtained, as well as the number of times each head entity category and the entity relationship are in the same knowledge triplet |e h,i |, where i = 1, 2,…hs.
[0115] In step 303, a first weight of the category of each head entity relative to the entity relationship is obtained.
[0116] The calculation formula of the first weight is as follows:
[0117]
[0118] Among them, x hi is the first weight of the category of any head entity relative to the entity relationship.
[0119] Get the number of tail entity categories ts that are in the same knowledge triplet as the entity relationship, and the number of times the tail entity of the jth category and the entity relationship are in the same knowledge triplet |e t,j |, where j = 1, 2, ..., ts, the second weight of the category of each tail entity relative to the entity relationship is obtained according to the following formula.
[0120]
[0121] Among them, y tj is the second weight of the category of any tail entity relative to the entity relationship.
[0122] It should be noted that when natural corpus has sparse features, for each entity relationship, hs and ts will not be too large to cause excessive computing pressure.
[0123] The encoding of the entity relationship according to the first weight, the second weight, the head entity encoding information and the tail entity encoding information to obtain the relationship encoding information specifically includes:
[0124] The entity relationship is encoded according to the following formula to obtain the relationship encoding information:
[0125]
[0126] in, Encode information for the relationship, W rh and U rt is the training projection parameter.
[0127] The W rh ,U rt ∈Q l×m , where l is the total number of entity relationship categories.
[0128] In this embodiment, for natural corpus with sparse features, different entity relationships may exist between the same pair of head entity and tail entity, and entity relationships of the same category may be related to different entities, that is, an entity relationship can be a projection in two directions in the vector space composed of the head entity and the tail entity after introducing training projection parameters.
[0129] According to the above entity relationship encoding formula, it is necessary to obtain corresponding training projection parameters in order to obtain the relationship encoding information of the entity relationship according to the head entity encoding information and the tail entity encoding information. Therefore, this embodiment also involves the following design:
[0130] The training of the head entity encoding information, the tail entity encoding information and the relationship encoding information to obtain the relationship reasoning model specifically includes:
[0131] Construct an error triplet that does not exist in the natural corpus, input both the knowledge triplet and the error triplet into the scoring model, and Make a judgment:
[0132] when , the input instance is judged to be the correct instance.
[0133] when , the input instance is judged to be an error instance.
[0134] According to the correct instance and the wrong instance, the W rh and U rt Perform training to obtain a relational reasoning model.
[0135] In this embodiment, the scoring model may be a TransE model, and the W may be quantified by a binary cross entropy loss function. rh and U rt The relational reasoning model is obtained by training.
[0136] The other head entities and other tail entities that need to be subjected to relational reasoning are input into the relational reasoning model to obtain the entity relationship between the other head entities and other tail entities, such as Figure 4 As shown, specifically including:
[0137] In step 401, after the other head entities and other tail entities that need to be subjected to relational reasoning are input into the relational reasoning model, all types of entity relationships are traversed.
[0138] In step 402, the relationship encoding information of all entity relationships is sorted according to likelihood.
[0139] In step 403, the most likely relationship encoding information is output, and the most likely relationship encoding information is decoded to obtain the entity relationship between the other head entity and the other tail entity.
[0140] Embodiment 2:
[0141] Based on Example 1, this example demonstrates the sparse relational reasoning method based on rule fusion coding in Example 1 through actual scenarios.
[0142] In this embodiment, taking the natural language describing the relationship between commercial organizations as an example, there are generally investment relationships, control relationships, guarantee relationships, transaction relationships, etc. between commercial organizations; for example, in the sentence "On January 1, 2023, Group A invested in and established Company B", the triple (Company A, investment, Company B) can be extracted, among which "Company A" is the head entity, "investment" is the relationship, and "Company B" is the tail entity.
[0143] For the obtained knowledge triples (e h , r r , e t ), the co-reality entities of the head entity and the tail entity in each knowledge triple are obtained by the Apriori algorithm, and among all the obtained co-reality entities, the co-reality entities that are in the same sentence with the entity for more than a preset number of times are selected as frequent co-reality entities, and the set of all the frequent co-reality entities is used as the frequent rule set of the entity.
[0144] For example, suppose that the co-occurrence of "Company A" and "Company B" is counted in the natural corpus as follows:
[0145] (Company A, Organization C, Customer D);
[0146] (Company B, Institution C, Bank E);
[0147] (Company A, Company B, Institution C, Bank E);
[0148] (Company B, Bank E).
[0149] The total number of co-occurring sentences for "Company A" is 2, and the total number of co-occurring sentences for "Company B" is 3.
[0150] By calculating the candidacy and coupling of the co-reality entities {Company B, Institution C, Customer D, Bank E} of "Company A", we can see that the candidacy of "Company B" is 50% and the coupling is 50%; the candidacy of "Institution C" is 100% and the coupling is 50%; the candidacy of "Customer D" is 50% and the coupling is 0%; the candidacy of "Bank E" is 50% and the coupling is 0%. That is, the contribution of {Company B, Institution C, Customer D, Bank E} is 100%, 150%, 50%, and 50% respectively. Eliminating the lowest 50% corresponding to "Customer D" and "Bank E", the frequent rule set of "Company A" is {Company B, Institution C}.
[0151] Calculating the candidacy and coupling of the co-reality entities {Company A, Institution C, Bank E} of "Company B", we can see that the candidacy of "Company A" is 33% and the coupling is 33%; the candidacy of "Institution C" is 66% and the coupling is 66%; the candidacy of "Bank E" is 100% and the coupling is 66%. That is, the contribution of {Company A, Institution C, Bank E} is 66%, 132%, and 166% respectively. Eliminating the lowest 66% corresponding to "Company A", the frequent rule set of "Company B" is {Institution C, Bank E}.
[0152] For the triples (Company A, Investment, Company B) extracted in step 1, according to the frequent rule set of the head entity "Company A" and the tail entity "Company B", the encoding information of "Company A" is The coded information of "Company B" is in and It is the m-dimensional initialization encoding information formed by "Company A" and "Company B" through the word vector model Word2Vec. and It is the initialization coding information of "Institution C" and "Bank E" (the calculation method is the same as that of "Company A" and "Company B").
[0153] For the obtained knowledge triples (e h , r r , e t ), the association strength weight is calculated according to the types and numbers of the head and tail entities connected to each relation, and the relation r is encoded by its projection in the head and tail entity spaces of different categories of related triples.
[0154] Taking the extracted knowledge triples (Company A, Investment, Company B) as an example, the relationship "investment" may appear multiple times in all knowledge triples. For example, assuming that in the natural corpus, the relationship "investment" involves the following three knowledge triples: (Company A, Investment, Company B), (D Customer, Investment, Company B) and (E Bank, Investment, F Institution). That is, the head entities involved in "investment" are "Company A", "D Customer" and "Bank E", a total of 3, and the tail entities involved are "Company B" and "Institution F", a total of 2.
[0155] According to the above formula, we can get the coding information of "Company A": Encoded information of "D customer": The coding information of “E Bank”: Get the coded information of "Company B": Coding information of “F institution”:
[0156] Next, calculate the corresponding relationship strength weights of all head entities and tail entities of the "investment" relationship. In the three types of head entities, each head entity appears once; in the two types of tail entities, "Company B" appears twice and "Institution F" appears once. The specific calculation method is as follows:
[0157]
[0158]
[0159]
[0160]
[0161]
[0162] Then the coding of the "investment" relationship is:
[0163]
[0164] Among them, W rh ,U rt ∈Q l×m , are the projection parameters that need to be trained.
[0165] The scoring function and binary cross entropy loss function of the TransE model are used to train the entity encoding information and relationship encoding information to obtain the parameter W of the relational reasoning model. rh and U rt .
[0166] Construct an error triplet that does not exist in the natural corpus, input both the knowledge triplet and the error triplet into the scoring model, and Make a judgment:
[0167] when , the input instance is judged to be the correct instance.
[0168] when , the input instance is judged to be an error instance.
[0169] According to the correct instance and the wrong instance, the W rh and U rt Perform training to obtain a relational reasoning model.
[0170] In this embodiment, the scoring model may be a TransE model, and the W may be quantified by a binary cross entropy loss function. rh and U rt The relational reasoning model is obtained by training.
[0171] The step of inputting other head entities and other tail entities that need to be subjected to relational reasoning into the relational reasoning model to obtain entity relationships between the other head entities and other tail entities specifically includes:
[0172] After the other head entities and other tail entities that need to perform relational reasoning are input into the relational reasoning model, all types of entity relationships are traversed, the relational encoding information of all entity relationships is sorted according to possibility, the relational encoding information with the greatest possibility is output, and the relational encoding information with the greatest possibility is decoded to obtain the entity relationship between the other head entities and other tail entities.
[0173] After the other head entities and other tail entities that need to perform relational reasoning are input into the relational reasoning model, all types of entity relationships are traversed, the relational encoding information of all entity relationships is sorted according to possibility, the relational encoding information with the greatest possibility is output, and the relational encoding information with the greatest possibility is decoded to obtain the entity relationship between the other head entities and other tail entities.
[0174] After obtaining the relational reasoning model, for the head entity and tail entity whose relationship needs to be inferred, such as "G Company" and "H Company", the encoding of all relational words is traversed and the scoring function is used to calculate the relationship between the head entity and the tail entity. Output the relationship between "Company G" and "Company H" obtained by reasoning, sort the relationship coding information of all entity relationships according to possibility, arrange them in order {investment, holding, control, ...}, and output the top three most likely relationship coding information as the relationship reasoning result, that is, the three most likely relationships between "Company G" and "Company H" are "Company G" investing in "Company H", "Company G" holding "Company H" and "Company G" controlling "Company H".
[0175] Embodiment 3:
[0176] like Figure 5 , which is a schematic diagram of a sparse relational reasoning device based on rule fusion coding according to an embodiment of the present invention. The sparse relational reasoning device based on rule fusion coding according to this embodiment includes one or more processors 51 and a memory 52. Figure 5 A processor 51 is taken as an example.
[0177] The processor 51 and the memory 52 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0178] The memory 52 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs and non-volatile computer executable programs, such as the sparse relational reasoning method based on rule fusion coding in the above embodiment. The processor 51 executes the sparse relational reasoning method based on rule fusion coding by running the non-volatile software programs and instructions stored in the memory 52.
[0179] The memory 52 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 52 may optionally include a memory remotely arranged relative to the processor 51, and these remote memories may be connected to the processor 51 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0180] The program instructions / modules are stored in the memory 52, and when executed by the one or more processors 51, the sparse relational reasoning method based on rule fusion coding in the above embodiment is executed, for example, the above described Figures 1 to 4 The steps shown.
[0181] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A sparse relational reasoning method based on rule fusion coding, characterized in that: include: Obtain head entities, entity relations, and tail entities based on natural language data; Calculate the contribution of the entity co-occurrence set of each entity according to the acquired head entity, entity relationship and tail entity; Each sentence in the natural language is identified and extracted by manual method and / or annotation learning method, and the head entity, entity relationship and tail entity are obtained. According to the head entity, entity relationship and tail entity in the same sentence, a knowledge triple (e h , r r , e t ), where e h is the head entity, r r is the entity relationship, e t is the tail entity; All entities in the same sentence are regarded as co-existing entities, and the frequent rule sets of the head entity and the tail entity are obtained, including: According to all the acquired knowledge triples, the co-reality entity of each entity is acquired to obtain the co-reality entity set; For each entity e * , get entity e * All sentences appearing in the natural corpus are regarded as co-occurring natural sentences; For entity e * Each co-reality entity e * , obtain the co-reality entity e ’ With entity e * The number of times in the same statement is used as the co-reality entity e ’ The number of occurrences of the co-reality entity e ’ The number of occurrences of entity e * The ratio of the number of co-occurring natural sentences is taken as the co-occurring entity e ’ The candidacy degree of For entity e * Each co-reality entity e ’ , obtain the co-reality entity e ’ and entity e * The number of times other co-reality entities in the co-reality entity set are co-reality entities with each other is calculated as the proportion of the number of times the co-reality entities are co-reality entities with each other. * The ratio of the number of co-occurring natural sentences is taken as the co-occurring entity e ’ The degree of coupling; The co-reality entity ’ The candidate degree and the co-reality entity e ’ The coupling degree of the co-reality entity e is obtained by adding ’ The contribution of entity e * The co-reality entity with the smallest contribution in the co-reality entity set is eliminated, and the remaining co-reality entities are all regarded as frequent co-reality entities, and the set of all the frequent co-reality entities is regarded as entity e * Frequent rule sets of When the entity * If the contributions of all co-existing entities are the same, then entity e * All co-existing entities as entities e * Frequent rule sets of When the entity * When the number of co-existing entities is 0, then the entity e * The frequent rule set of is an empty set; Acquire a frequent rule set of a head entity and a frequent rule set of a tail entity according to the contribution, encode the head entity according to the frequent rule set of the head entity to obtain head entity encoding information, and encode the tail entity according to the frequent rule set of the tail entity to obtain tail entity encoding information; Perform initial encoding on each entity to obtain initial encoding information; Encode according to the initialization coding information of each entity and the initialization coding information of all frequently co-existing entities in its own frequent rule set; Among them, the head entity e h The encoding formula is as follows: in, is the initial encoding information of the head entity, k is the number of entities in the frequent rule set, For the head entity e h The initial coding information of each frequently co-existing entity, q is an integer greater than 0 and less than or equal to k; For the head entity e h The coded information; Among them, the tail entity e t The encoding formula is as follows: in, is the initial encoding information of the tail entity, k is the number of entities in the frequent rule set, For the tail entity e t Initial encoding information of each frequently co-present entity, q is an integer greater than 0 and less than or equal to k; For the tail entity e t The coded information; Obtain a first weight of the head entity relative to the entity relationship, and obtain a second weight of the tail entity relative to the entity relationship; According to all the acquired knowledge triples, for each entity relationship, the number of categories hs of the head entity in the same knowledge triplet as the entity relationship and the number of times |e the head entity of the i-th category and the entity relationship are in the same knowledge triplet are obtained h,i |, where i = 1, 2, ... hs, the first weight of each head entity category relative to the entity relationship is obtained according to the following formula: Among them, x hi is the first weight of the category of any head entity relative to the entity relationship; Get the number of tail entity categories ts that are in the same knowledge triplet as the entity relationship, and the number of times the tail entity of the jth category and the entity relationship are in the same knowledge triplet |e t,j |, where j = 1, 2, ..., ts, the second weight of each tail entity category relative to the entity relationship is obtained according to the following formula: Among them, y tj is the second weight of the category of any tail entity relative to the entity relationship; Encoding the entity relationship according to the first weight, the second weight, the head entity encoding information and the tail entity encoding information to obtain relationship encoding information; The entity relationship is encoded according to the following formula to obtain the relationship encoding information: in, Encode information for the relationship, W rh and U rt To train the projection parameters; Training the head entity encoding information, the tail entity encoding information and the relationship encoding information to obtain a relationship reasoning model; Construct an error triplet that does not exist in the natural corpus, input both the knowledge triplet and the error triplet into the scoring model, and Make a judgment: when , then the input instance is judged to be the correct instance; when , then the input instance is judged to be an error instance; According to the correct instance and the wrong instance, the W rh and U rt Perform training to obtain a relational reasoning model; The other head entities and other tail entities that need to be subjected to relational reasoning are input into the relational reasoning model to obtain the entity relations between the other head entities and other tail entities.
2. The sparse relational reasoning method based on rule fusion coding according to claim 1 is characterized in that: The initial encoding of each entity to obtain initialization encoding information specifically includes: Extract the words in each entity and convert them into vector form through the vector model as the initial coding information; in, e 1i 、e 2i ,…e mi is the value of each dimension of the vector, m is the vector Dimension.
3. The sparse relational reasoning method based on rule fusion coding according to any one of claims 1 and 2, characterized in that: The step of inputting other head entities and other tail entities that need to be subjected to relational reasoning into the relational reasoning model to obtain entity relationships between other head entities and other tail entities specifically includes: After the other head entities and other tail entities that need to perform relational reasoning are input into the relational reasoning model, all types of entity relationships are traversed, the relational encoding information of all entity relationships is sorted according to possibility, the relational encoding information with the greatest possibility is output, and the relational encoding information with the greatest possibility is decoded to obtain the entity relationship between the other head entities and other tail entities.
4. A sparse relational reasoning device based on rule fusion coding, characterized in that: It includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the sparse relational reasoning method based on rule fusion coding as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Entity relationship recognition method and device
CN111476023A
Knowledge graph representation enhancement method and system based on dense neighbors
CN115062157A
