A quaternion-based knowledge graph embedding method and system

By constructing a projection matrix and loss function based on a quaternion-based knowledge graph embedding method, the shortcomings of existing models in entity classification and relational pattern modeling are addressed. This enables multiple representations and completion of the knowledge graph, thereby improving entity classification performance and the ability to predict complex relationships.

CN116108189BActive Publication Date: 2025-11-18CENT SOUTH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211257576.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-14
Publication Date
2025-11-18
Estimated Expiration
2042-10-14

AI Technical Summary

Technical Problem

Existing knowledge graph embedding models ignore the modular information of entity embedding when modeling relational patterns, resulting in decreased entity classification performance and difficulty in inferring complex relational patterns.

Method used

A quaternion-based knowledge graph embedding method is adopted. By constructing a projection matrix, multiple representations of different types of entities are realized. The quaternion modulus is used to build a hierarchical structure. The entity and relation representations are learned by combining the loss function, and the connections are predicted to realize knowledge graph completion.

Benefits of technology

It improves entity classification performance, effectively predicts missing triplet facts, and completes knowledge graphs, especially excelling in handling complex relational patterns.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116108189B_ABST
    Figure CN116108189B_ABST
Patent Text Reader

Abstract

The application discloses a knowledge graph embedding method and system based on quaternions, comprising the following steps: S1, constructing a projection matrix for the hierarchical structure of a triple; S2, constructing a knowledge graph embedding model based on quaternions, using the knowledge graph embedding model based on quaternions to realize the rotation between entities, using the modulus of the quaternion to realize the ability of constructing the hierarchical structure; obtaining a score function of the knowledge graph embedding model based on quaternions, and constructing a final loss function through the score function; S3, using the knowledge graph embedding model based on quaternions to model a main relationship mode; S4, learning the problem of entity and relationship representation in the knowledge graph through the final loss function of the knowledge graph embedding model based on quaternions, predicting the connection, so as to obtain the missing and real triple facts in the knowledge graph, realize the completion of the knowledge graph, and solve the multiple representations of entities in different scenes and improve the entity classification performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of knowledge graphs, and specifically relates to a knowledge graph embedding method and system based on quaternions. Background Technology

[0002] A knowledge graph is a medium for storing objective factual information, describing real-world entities, concepts, and events, as well as the relationships between them, in a graph-like manner. A knowledge graph contains a large number of triples; more precisely, it is a graph-oriented database, where each triple (e...) represents a unique set of data. h ,e r ,e t Knowledge graphs can connect knowledge scattered across specific domains, with ternary operators representing head entities, relational entities, and tail entities, respectively. Many companies have built knowledge graphs such as DBpedia, Freebase, WordNet, and Yago. However, despite their widespread application, existing knowledge graphs still suffer from incompleteness. Therefore, future research should focus on improving knowledge completion and automatically predicting missing facts. Knowledge graph embedding (KGE) aims to provide the ability to automatically predict missing entities in knowledge graphs.

[0003] The primary goal of knowledge graph embedding is to map entities and relations within a knowledge graph to a low-dimensional vector space. While existing knowledge graph embedding models, such as translation models and their variants like TransE and RotatE, have achieved good performance, significant challenges remain in modeling relational patterns, including symmetric / antisymmetric, inverse, and combinatorial relational patterns, as well as predicting complex edge-to-edge relations. A significant drawback of these methods is that they neglect the use of modal information in entity embedding, leading to a decline in entity classification performance. Furthermore, the semantic hierarchy of entities is a major component of ontology design and is widely present in knowledge graphs; these models cannot infer complex relational patterns. Summary of the Invention

[0004] To address the above technical problems, this invention discloses a knowledge graph embedding method and system based on quaternions. It constructs a projection matrix to achieve multiple representations of different types of entities, defines each relation as a unit quaternion, and the entity as a pure quaternion. Through loss function calculation in this invention, it predicts connections by learning the entity and relation representations in the knowledge graph.

[0005] A knowledge graph embedding method based on quaternions includes the following steps:

[0006] S1: Construct the hierarchical structure of the projection matrix for triples;

[0007] S2: Construct a quaternion-based knowledge graph embedding model, realize the rotation between entities using the quaternion-based knowledge graph embedding model, and realize the ability to construct hierarchical structures using the modulus of quaternions; obtain the scoring function of the quaternion-based knowledge graph embedding model, and construct the final loss function through the scoring function;

[0008] S3: Model the main relational patterns of a public dataset using a quaternion-based knowledge graph embedding model;

[0009] S4: By utilizing the final loss function of the quaternion-based knowledge graph embedding model to learn the representation of entities and relations in the knowledge graph, predictive connections are made to obtain the missing and true triplet facts in the knowledge graph, thereby achieving knowledge graph completion.

[0010] Furthermore, the projection matrix in S1 includes the projection matrix M for entity e. e The projection matrix M of the head entity rh The projection matrix M of the tail entity rt The projection matrix M of entity e e As shown in the following formula:

[0011] M e =α1M t(1) +α2M t(2) +…+α n M t(k) ;

[0012] Where k represents the number of types to which entity e belongs, t (i) This indicates that entity e can be of the i-th type. It is t (i) The projection moment, α i This represents the weight corresponding to t;

[0013] Projection matrix M of the head entity rh In a triple (e h ,e r ,e t The representation in ) is as follows:

[0014]

[0015] Among them, T rh Represents the head type set in a specific relation r, and the triple (e h ,e r ,e t ) in e h Represents the head entity, e r Represents the tail entity, e t Represents a relational entity;

[0016] The projection matrix M of the tail entityrt In a triple (e h ,e r ,e t The representation in ) is as follows:

[0017]

[0018] Furthermore, the quaternion-based knowledge graph embedding model in S2 includes a scoring function. for:

[0019] or

[0020]

[0021] In the formula, ☉ represents the dot product, and e h =[0,h] is a pure quaternion, and e r It is a unit quaternion.

[0022] Furthermore, the head prediction loss function Loss of the quaternion-based knowledge graph embedding model in S2 h and tail prediction loss function Loss t The head prediction loss function Loss h as follows:

[0023]

[0024] Where γ and σ are hyperparameters, representing fixed margin and the sigmoid function, respectively. It is the i-th negative triplet divided by the positive triplet. and probability distribution, The definition is as follows:

[0025]

[0026] Where T α It is the sampling temperature;

[0027] The tail prediction loss function Loss t as follows:

[0028]

[0029] Furthermore, the connection prediction process in S4 is as follows:

[0030] S4-1: Establish embedded models and relational schemas by designing projection matrices of relationships and entities;

[0031] S4-2: Construct head prediction loss function and tail prediction loss function through scoring function, and use public dataset to train embedding model to minimize head prediction loss function and tail prediction loss function, so as to obtain a better knowledge graph embedding model;

[0032] S4-3: Put the new vector in, and another vector can be obtained through the knowledge graph embedding model. This vector is actually the tail entity (h, r, ?) predicted based on the head entity and relation, or the head entity (?, r, t) predicted based on the tail entity and relation.

[0033] This invention also discloses a knowledge graph embedding system based on quaternions, including a hierarchical module, a knowledge graph embedding module, a model modeling module, and a knowledge graph completion module;

[0034] The hierarchical module is used to construct the hierarchical structure of the projection matrix for triples;

[0035] The knowledge graph embedding module is used to construct a quaternion-based knowledge graph embedding model, realize the rotation between entities using the quaternion-based knowledge graph embedding model, realize the ability to construct hierarchical structures using the modulus of quaternions, obtain the scoring function of the quaternion-based knowledge graph embedding model, and construct the loss function through the scoring function;

[0036] The modeling module is used to model the main relational patterns of a public dataset using a quaternion-based knowledge graph embedding model.

[0037] The knowledge graph completion module is used to learn the entity and relation representations in the knowledge graph by utilizing the final loss function of the quaternion-based knowledge graph embedding model, and to make predictive connections, thereby obtaining the missing but true triplet facts in the knowledge graph and realizing knowledge graph completion.

[0038] The beneficial effects of this invention are:

[0039] 1. By constructing a projection matrix, multiple representations of different types of entities are realized, solving the problem of multiple representations of entities in different scenarios, avoiding the neglect of the use of the model information embedded in the entity, and improving the entity classification performance.

[0040] 2. By calculating the loss function in this invention, and by learning the entity and relation representations in the knowledge graph to predict connections, the missing but real triplet facts in the knowledge graph are obtained, thereby achieving knowledge graph completion. Attached Figure Description

[0041] Appendix Figure 1 The diagram below is a schematic diagram of a knowledge graph embedding model based on quaternions. Figure (a) is an illustrative example of a hierarchical encoder, and Figure (b) is a schematic diagram of the RotatQ architecture.

[0042] Appendix Figure 2 This is a schematic diagram showing the results of dimensionality analysis on four datasets: (a) FB15k, (b) FB15k-237, (c) WN18, and (d) WN18RR. The horizontal axis represents the dimension size, and the vertical axis represents the performance of MRR and Hits@n (n = 1, 3, 10). Detailed Implementation

[0043] The embodiments of the present invention will be further described below with reference to the accompanying drawings and examples. It should be noted that the embodiments do not constitute a limitation on the scope of protection of the present invention.

[0044] Example 1

[0045] As attached Figure 1 To be continued Figure 2 As shown, a knowledge graph embedding method based on quaternions includes the following steps:

[0046] S1: Construct the hierarchical structure of the projection matrix for triples;

[0047] Most knowledge graphs contain hierarchical type information, indicating that an entity may play different roles in different scenarios; however, most knowledge graph embedding models ignore this hierarchical type information. This invention constructs a special type of projection matrix M. e The hierarchical structure solves the problem of multiple representations of entities in different scenarios.

[0048] like Figure 1 As shown in (a), it is clear that most entities reside in more than one hierarchical type, which can be used as supplementary information when representing entities. Accordingly, the present invention sets up a projection matrix M for entity e. e It is composed of a weighted sum of all types of matrices, as shown in formula (1).

[0049]

[0050] Where k represents the number of types to which entity e belongs, and the value of k is generally 3-5, t (i) This indicates that entity e can be of the i-th type. It is t (i) The projection moment, α i This represents the weight corresponding to t.

[0051] However, these triples in knowledge graph embeddings provide a specific relation to connect different entities, thereby estimating the type an entity might belong to within that specific relation. To fully utilize this information, a projection matrix M of the head entity is constructed. rh The projection matrix M of the tail entity rt The projection matrix M of the head entity rhIn a triple (e h ,e r ,e t The representation in ) is shown in formula (2).

[0052]

[0053] Where T rh Represents the set of header types in a specific relation r, (e h ,e r ,e t ) in e h Represents the head entity, e r Represents the tail entity, e t Represents a relational entity.

[0054] The projection matrix M of the tail entity rt In a triple (e h ,e r ,e t The representation in ) is as follows:

[0055]

[0056] S2: Construct a quaternion-based knowledge graph embedding model, realize the rotation between entities using the quaternion-based knowledge graph embedding model, and realize the ability to construct hierarchical structures using the modulus of quaternions; obtain the final loss function of the quaternion-based knowledge graph embedding model;

[0057] like Figure 1 (b) shows the RotatQ model framework based on quaternions for knowledge graph embedding, which, based on Rodrigues' rotation formula, divides the rotation vector v into v ⊥ (orthogonal to the axis of rotation) and v || (Parallel to the axis of rotation), then rotate v respectively ⊥ and v || Two vectors. This invention defines the head entity h = [0, h] as a pure quaternion, and defines the relationship connecting the head entity and the tail entity as a unit quaternion.

[0058] For any vector v rotated by θ degrees along a rotation axis u defined by a unit vector, v' can be obtained through quaternion multiplication. v' represents the vector v after a certain rotation. According to Rodriguez's formula, v' can be decomposed into a vector parallel to the rotation axis and a vector perpendicular to the rotation axis. Assuming q = [sin(θ) + cos(θ)u], where u is a unit vector, then q can be obtained. 2 =[sin(2θ)+cos(2θ)u], p and q are both vectors used as intermediate values ​​for formula reasoning.

[0059] v'=v ||'+v ⊥ '=v || +[cos(θ)v ⊥ +sin(θ)(u×v ⊥ )]

[0060] =v || +[cos(θ)v ⊥ +sin(θ)(uv ⊥ )]

[0061] =v || +(cos(θ)+sin(θ)u)v ⊥ =v || +qv ⊥ =1⊙v || +qv ⊥

[0062] =pp -1 v || +ppv ⊥

[0063] set up Thus, we obtain formula (3):

[0064] v'=pvp * =pvp -1 (3)

[0065] According to formula (1), for the triple (e h ,e r ,e t ), through relational entity e r Tail entity e t It can be viewed as the head entity e h The rotation, i.e., e t =e r ⊙e h ⊙e r -1 or e h =e r ⊙e t ⊙e r -1 Therefore, the quaternion-based knowledge graph embedding model RotatQ's scoring function f in distance form... r t (e h ,e t ) is defined as formula (4):

[0066]

[0067] In the formula, ☉ represents the dot product, e h =[0,h] is a pure quaternion, and er It is a unit quaternion.

[0068] Conversely, if e t Given that, it can be obtained through relation entity e r ,View Head Entity e h For tail entity e t The rotation. Therefore, the score function for predicting head entities in the quaternion-based knowledge graph embedding model RotatQ. It can be written as formula (5).

[0069]

[0070] In summary, the final score function of RotatQ, a knowledge graph embedding model based on quaternions, can be tuned as follows:

[0071]

[0072]

[0073] To better model the RotatQ knowledge graph embedding model based on quaternions, this invention constructs a head prediction loss function, Loss. h and tail prediction loss function Loss t A loss function is constructed using a scoring function, and then the loss function is optimized using the training set to make the S4 prediction results more accurate. Self-adversarial sampling is used to train the model, and the self-adversarial sampling temperature T is set. α When T α When T = 0, self-adversarial sampling degenerates into uniform sampling. α When the score is greater than 0, the sampling weight corresponding to the negative triplet with the smaller score is larger. Where (e h ,e r ,e t ) is a positive triple, and (e h' ,e r ,e t ) or (e h ,e r ,e t' ) represents the damaged triplet. These two loss functions can be expressed by formulas (8) and (9).

[0074]

[0075]

[0076] Where γ and σ are hyperparameters, representing fixed margin and the sigmoid function, respectively. It is the i-th negative triplet divided by the positive triplet. and probability distribution The definition is as follows:

[0077]

[0078] In equation (10), T α It is the sampling temperature.

[0079] S3: The main relation patterns of the public dataset are modeled using a quaternion-based knowledge graph embedding model. The relation model in this paper is contained in the public dataset, such as the test set data of FB15k, where 1-1 relations account for 1.41%, 1-N relations account for 8.9%, N-1 relations account for 1.41%, and NN relations account for 75%.

[0080] Quaternions offer excellent flexibility and representation capabilities, making it easy to model key relational schemas.

[0081] When e r When the imaginary part is set to zero or non-zero, RotatQ, a quaternion-based knowledge graph embedding model, can simulate symmetric and antisymmetric relationships.

[0082] When a triple (e h ,e r ,e t ) Keep, if The relation r1 is the reciprocal of r2. Based on the quaternion conjugate property, we can obtain e. h =e r ⊙e t ⊙e r -1 =e r ⊙e t ⊙e r * ⊙e t =e r -1 ⊙(e r * ) -1 =e r * ⊙e h ⊙(e r * ) -1 .

[0083] That is, e h =e r ⊙e t ⊙e r -1 =e r ⊙e t ⊙e r * (e r1 =e r )⊙et =e r * ⊙e h ⊙(e r * ) -1 (e r2 =e r * ).

[0084] Therefore, RotatQ, a quaternion-based knowledge graph embedding model, can simulate inverse relational patterns.

[0085] If e r1 ,e r2 and e r3 Existence, assumption Then it means e r3 Specially by e r1 and e r2 Combination. For head prediction tasks, if (e h ,e r1 ,e t1 ), (e t1 ,e r2 ,e t ) and (e h ,e r3 ,e t If ) holds true, then e t1 =e r1 ⊙e h ⊙e r1 -1 e t =e r2 ⊙e t1 ⊙e r2 -1 and e t =e r3 ⊙e h ⊙e r3 -1 Therefore, we will get equation (8):

[0086] e r3 ⊙e h ⊙e r3 -1 =e r2 ⊙e t1 ⊙e r2 -1 =e r2 ⊙e r1 ⊙e h ⊙e ri -1 ⊙e r2 -1 (11)

[0087] Therefore, RotatQ, a knowledge graph embedding model based on quaternions, can also simulate merging relationships.

[0088] S4: By utilizing the final loss function of the quaternion-based knowledge graph embedding model to learn the representation of entities and relations in the knowledge graph, predictive connections are made to obtain the missing and true triplet facts in the knowledge graph, thereby achieving knowledge graph completion.

[0089] The process of predicting connections is as follows:

[0090] S4-1: Establish embedded models and relational schemas by designing projection matrices of relationships and entities;

[0091] S4-2: Construct head prediction loss function and tail prediction loss function through scoring function, and use public dataset to train embedding model to minimize head prediction loss function and tail prediction loss function, so as to obtain a better knowledge graph embedding model;

[0092] S4-3: Put the new vector in, and another vector can be obtained through the knowledge graph embedding model. This vector is actually the tail entity (h, r, ?) predicted based on the head entity and relation, or the head entity (?, r, t) predicted based on the tail entity and relation.

[0093] After processing using the above methods, it is possible to construct a projection matrix using a hierarchical encoder of the knowledge graph to realize multiple representations of different types of entities and to perform relation prediction by calculating graph embedding scores.

[0094] The present invention also provides a knowledge graph embedding model RotatQ based on quaternions, which includes functional step modules capable of implementing the above steps.

[0095] This model was evaluated in three implementation cases: triplet classification, link prediction, and relation prediction. Four benchmark knowledge graph datasets were used in the implementation cases: FB15k, WN18, and its variants FB15k-237 and WN18RR. Tables 1 and 2 provide details of the four datasets. FB15k is extracted from Freebase, a large knowledge graph about general world facts. Entities in FB15k represent relatively common knowledge, such as movies and sports. Furthermore, FB15k contains not only many symmetric / antisymmetric and inverse patterns but also many inverse relations. FB15K-237 is a subset of FB15k used to remove inverse relations from FB15k. WN18 is a subset of WordNet, an English vocabulary database. WN18RR was used for the link prediction task.

[0096] For training the RotatQ model, this invention runs it via PyTorch, using the Adam optimizer to find the optimal hyperparameters. Generally, the embedding size k is tuned within {500, 300, 200, 100, 50}, the training batch size b is chosen within {2048, 1024, 512}, and the hyperparameters α and γ are tuned within {1.0, 0.5} and [24, 18, 12, 9, 6], respectively. Finally, the real and imaginary parts of the entity embeddings are uniformly initialized.

[0097] The evaluation metrics for this model include MRR (Mean Reciprocal Ranking), MR (Mean Rank), and Hit@n, where n = 1, 3, and 10. MRR is the average of the inverse prediction ranks of all triples. MR is the average prediction ranking of all triples. Hit@n is the proportion of the top-n correctly predicted entities.

[0098] For a triple (e h ,e r ,e t ), when e h or e t The method for completing the triplet, which is missing, is called link prediction. Specifically, for each triplet in the test set, remove 'e'. h or e t Then, each entity in the dictionary is replaced sequentially, and the resulting triples are called candidate triples (e). h ',e r ',e t Then, a score is obtained by calculating the scoring function of these candidate triples, and they are sorted in ascending order. However, this invention removes these candidate triples that appear in the training, testing, or validation sets.

[0099] This invention introduces three evaluation metrics: MRR, MR, and Hit@n. A lower MR and higher MRR and Hit@n indicate better performance. This invention is run using PyTorch and employs the Adam optimizer to find the optimal hyperparameters.

[0100] Table 1. Statistics of the experimental dataset, where AVG represents the average number of connecting edges per node.

[0101]

[0102] Table 2. Four knowledge graph test datasets

[0103]

[0104]

[0105] Tables 3 and 4 show the link prediction performance of RotatQ with knowledge graph embedding models such as TransE, RotatE, ComplEx, DistMult, ConvE, and OuatE on FB15k, WN18 and its variants FB15k-237 and WN18RR.

[0106] Table 3. Comparison with state-of-the-art knowledge graph embedding models FB15K and WN18

[0107]

[0108] Table 4. Comparison with state-of-the-art knowledge graph embedding models FB15K-237 and WN18RR.

[0109]

[0110] As shown in Table 3, on FB15k, RotatQ clearly outperforms the RotatE model in terms of MRR, Hits@1, and Hits@3, validating the accuracy of RotatQ in link prediction tasks. The WN18 model's MRR, MR, and Hits@1 indices are all higher than other recent state-of-the-art models. However, compared to the best performance in Hits@3 and Hits@10, RotatQ does not exceed 0.3%. However, FB15k and WN18 suffer from test set leakage, meaning that certain specific relationships have an inverse relationship in the training set, thus the triples (e... h ,e r ,e t In the test set, while (e h ,e r -1 ,e t In the training set, the indices in Table 3 are generally higher than those in Table 4. Furthermore, it's easy to see that the simplest TransE model performs better on it. In conclusion, RotatQ delivers excellent results and works well across all relational schemas.

[0111] Table 4 shows that on FB15k-237, RotatQ has a significant advantage in all metrics except MRR. Specifically, RotatQ improves the Hits@10 metric by 1.4% compared to the RotatE model. Furthermore, RotatQ outperforms the recent state-of-the-art RotatE by 1.3% in Hits@1 and Hits@3. Moreover, the MRR of the RotatQ model is consistent with the RotatE model but higher than other models. On WN18RR, except for Hits@10, the MRR, MR, Hits@1, and Hits@3 results in RotatQ surpass previous methods, indicating that RotatQ has some merit. In Hits@1, RotatQ improves by 1.0% compared to QuatE and by 1.8% compared to RotatE. However, there is no significant improvement in these metrics in MRR and Hits@1. As shown in Table 1, the reason why these state-of-the-art (SOTA) models outperform FB15k-237 on WN18RR is that the average number of connected edges per node in WN18RR is lower than that in FB15k-237. In summary, the models in Table 4 yield the most robust results, indicating that RotatQ can handle multiple relationships well.

[0112] The experiments compare RotatQ with many state-of-the-art advanced models, including TransE, ComplEx, and RotatE. To validate the model's effectiveness, the results for relation categories are described in Table 5.

[0113] Table 5. Experimental results of relational categories in FB15k.

[0114] [▼] indicates that the training results provide self-adversarial sampling.

[0115]

[0116] Comparing the results of this experiment with previous studies, it is clear that for edge 1 entity prediction, i.e., the missing e... h Or e t This is suboptimal performance, which immediately demonstrates the superiority of the present invention in solving the edge 1 entity prediction problem. For edge N entity prediction, i.e., the missing e h or e t In neural network (NN) relationships, RotatQ shows increasingly better results on the dataset, indicating that this invention also has the ability to handle complex relationships. Specifically, the MRR metric is improved by 1.3% and 1.4% in RotatQ for predicting NN relationships between head and tail entities, respectively. In summary, the experimental results demonstrate that RotatQ performs better in multi-relationship prediction tasks.

[0117] From the deputy Figure 2Experimental results show that the curve does not change drastically when the dimension size reaches 300. However, when the size is less than 300, the size has a significant impact on the application of knowledge graph embedding. In particular, when the dimension size k is between 50 and 300, Hits@1 changes very significantly, increasing by 37.7%, 23.4%, 54.2%, and 25.7% respectively on the four databases FB15k, FB15k-237, WN18, and WN18RR. Overall, other indicators do not change much with the increase of size, indicating that the invention has good stability, but there are minor deficiencies in accuracy. In addition, except for Hits@1, all indicators are insensitive to the dimension size on FB15k and WN18, proving that the invention is applicable to large-scale knowledge graphs.

[0118] Validation experiments on four commonly used public databases, comparison experiments with other state-of-the-art models, and experimental results on link prediction tasks demonstrate that RotatQ performs well in link prediction tasks, exhibits good performance on most metrics, has the advantage of modeling semantic levels, and demonstrates good stability in large-scale knowledge graphs.

[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A knowledge graph embedding method based on quaternions, characterized in that, Includes the following steps: S1: Construct the hierarchical structure of the projection matrix for triples; S2: Construct a quaternion-based knowledge graph embedding model, realize the rotation between entities using the quaternion-based knowledge graph embedding model, realize the ability to construct hierarchical structures using the modulus of quaternions, obtain the scoring function of the quaternion-based knowledge graph embedding model, and construct the final loss function through the scoring function; S3: Model the main relational patterns of a public dataset using a quaternion-based knowledge graph embedding model; S4: By utilizing the final score function of the quaternion-based knowledge graph embedding model to learn the entity and relation representations in the knowledge graph, predictive connections are made to obtain the missing and true triplet facts in the knowledge graph, thereby achieving knowledge graph completion. The S2-based quaternion knowledge graph embedding model includes a head prediction loss function. and tail prediction loss function The head prediction loss function as follows: ; in , These are hyperparameters, representing fixed margins and the sigmoid function, respectively. It is the first A negative triple divided by a positive triple probability distribution The definition is as follows: ; in It is the sampling temperature; The tail prediction loss function as follows: ; The connection prediction process in S4 is as follows: S4-1: Establish the embedded model and model relationships by designing the relationships and projection matrices of entities; S4-2: Construct head prediction loss function and tail prediction loss function through scoring function, and use public dataset to train embedding model to minimize head prediction loss function and tail prediction loss function, and obtain a knowledge graph embedding model; S4-3: Put the new vector in, and another vector can be obtained through the knowledge graph embedding model. This vector is actually the tail entity (h,r,?) predicted based on the head entity and relation, or the head entity (?,r,t) predicted based on the tail entity and relation.

2. The knowledge graph embedding method based on quaternions as described in claim 1, characterized in that, The projection matrix in S1 includes for entities projection matrix Projection matrix of the head entity Projection matrix of tail entity ,entity projection matrix As shown in the following formula: ; in Representing entities Number of types, Representing entities It can be located in the first Types, yes The projection matrix, express The corresponding weights; Projection matrix of the head entity In a triple The representation in is as follows: ; in, Represents specific relationships Header type set, triples middle Indicates the head entity. Indicates the tail entity. Represents a relational entity; Projection matrix of the tail entity In a triple The representation in is as follows: 。 3. The knowledge graph embedding method based on quaternions as described in claim 1, characterized in that, The scoring function for predicting head entities in the quaternion-based knowledge graph embedding model in S2. for: ; Where, in the formula Represents the dot product. It is a pure quaternion, and It is a unit quaternion.

4. A quaternion-based knowledge graph embedding system, used to run the quaternion-based knowledge graph embedding method according to any one of claims 1-3, characterized in that, It includes a hierarchical module, a knowledge graph embedding module, a model building module, and a knowledge graph completion module; The hierarchical module is used to construct the hierarchical structure of the projection matrix for triples; The knowledge graph embedding module is used to construct a quaternion-based knowledge graph embedding model, realize the rotation between entities using the quaternion-based knowledge graph embedding model, realize the ability to construct hierarchical structures using the modulus of quaternions, and obtain the final score function of the quaternion-based knowledge graph embedding model. The modeling module is used to model the main relational patterns of a public dataset using a quaternion-based knowledge graph embedding model. The knowledge graph completion module is used to learn the entity and relation representations in the knowledge graph by utilizing the final loss function of the quaternion-based knowledge graph embedding model, and to make predictive connections, thereby obtaining the missing and true triplet facts in the knowledge graph and realizing knowledge graph completion.

Citation Information

Patent Citations

  • Three-dimensional rotation embedding method for 3DRTE time knowledge graph

    CN112231469A

  • Knowledge graph embedding model based on entity-relation association graph

    CN113220897A