Knowledge graph representation method and system based on FastText-TransH algorithm

By fusing structural and semantic information through the FastText-TransH algorithm, the shortcomings of existing knowledge graph algorithms in representing complex entity relationships and long texts are addressed, more efficient knowledge graph representation and reasoning capabilities are achieved, and the accuracy and interpretability of knowledge graphs are improved.

CN120354925BActive Publication Date: 2025-09-12NANCHANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510855053.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-09-12
Estimated Expiration
2045-06-25

AI Technical Summary

Technical Problem

Existing knowledge graph embedding algorithms have shortcomings in processing complex entity relationships, extracting semantics from long text entities, and utilizing entity category information. As a result, the distribution of entities in the vector space cannot fully reflect the correlation and differences between categories, reducing the accuracy and interpretability of knowledge graph representation.

Method used

The FastText-TransH algorithm is adopted to optimize the vector representation by fusing structural and semantic information, combining the relational projection model and the entity category enhancement mechanism, using the FastText algorithm to obtain word vectors and training them through the TransH algorithm, introducing a dynamic weight mechanism and entity category constraints.

Benefits of technology

It significantly improves the representation ability and reasoning efficiency of large-scale knowledge graphs, can more accurately capture the complex relationships between entities, and improve the accuracy and interpretability of knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120354925B_ABST
    Figure CN120354925B_ABST
Patent Text Reader

Abstract

This invention provides a knowledge graph representation method and system based on the FastText-TransH algorithm. The method comprises: using the FastText algorithm to train text data in a talent knowledge graph, and obtaining a word vector corresponding to each word in the text data based on the training results; inputting the word vector corresponding to each word in the text data into the TransH algorithm for training to obtain an improved TransH algorithm; and inputting triple data to be analyzed into the improved TransH algorithm to obtain target vectors corresponding to the head entity and tail entity in the triple data to be analyzed. The present invention can efficiently and accurately generate vector representations of corresponding entities and relationships.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge graph representation technology, and in particular to a knowledge graph representation method and system based on the FastText-TransH algorithm. Background Art

[0002] In the field of talent knowledge graphs, knowledge graph embedding technology is crucial for accurately representing entities and relationships. Some existing classic embedding algorithms have many limitations when processing talent knowledge graphs.

[0003] While the traditional TransE algorithm boasts simplicity and efficiency, it assumes that entities and relationships exist in the same semantic space. This makes it difficult to accurately represent the semantic differences between entities in different relationships when faced with complex many-to-many relationships and long, semantically rich entities. For example, in talent knowledge graphs involving many-to-many relationships involving diverse professional skills and project collaborations, as well as long patent names such as "Research and Development of a New Communication Technology Based on the Principle of Quantum Entanglement," the TransE algorithm performs poorly.

[0004] The TransR algorithm introduces the concept of relational space, but it still has shortcomings in mining deep semantic features. Furthermore, these traditional methods generally ignore lexical information and entity category information. Long text entities in talent knowledge graphs contain a wealth of specialized knowledge and semantic connotations. Traditional methods are unable to effectively and accurately convert key information and semantic connections into vector representations, which in turn affects the performance of knowledge graphs in areas such as knowledge completion, reasoning, and intelligent retrieval.

[0005] Furthermore, entities in the talent knowledge graph have different categorical attributes, such as papers and publications, patents, awards and honors. Entities in the same category share certain similarities in semantics and features, but traditional embedding methods fail to fully utilize this categorical information. As a result, the distribution of entities in the vector space fails to fully reflect the inter-category correlations and differences, reducing the accuracy and interpretability of the knowledge graph representation. Summary of the Invention

[0006] The purpose of the present invention is to provide a knowledge graph representation method and system based on the FastText-TransH algorithm, aiming to address the shortcomings of existing classic algorithms in processing complex entity relationships, extracting semantics of long text entities, and utilizing entity category information, and to efficiently and accurately generate vector representations of corresponding entities and relationships.

[0007] In a first aspect, the present invention provides a knowledge graph representation method based on the FastText-TransH algorithm, the method comprising:

[0008] Use the FastText algorithm to train the text data in the talent knowledge graph, and obtain the word vector corresponding to each word in the text data based on the training results;

[0009] The word vectors corresponding to each word in the text data are input into the TransH algorithm for training, and the improved TransH algorithm is obtained as follows:

[0010] Acquire triple data about the talent knowledge graph, the triple data including a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtain an initial vector for the triple according to the weighted word vectors of all words in the word set;

[0011] Obtaining the categories to which the head entity and the tail entity belong, encoding the categories, obtaining the head entity vector and the tail entity vector according to the encoding result and the initial vector, and calculating the Euclidean distance according to the head entity vector and the tail entity vector;

[0012] Constructing a loss function according to the Euclidean distance, calculating a loss value according to the loss function, and judging whether the TransH algorithm has converged according to the loss value, and terminating the training if it has converged;

[0013] The triple data to be analyzed is input into the improved TransH algorithm to obtain the target vectors corresponding to the head entity and the tail entity in the triple data to be analyzed.

[0014] In a second aspect, the present invention provides a knowledge graph representation system based on the FastText-TransH algorithm, the system comprising:

[0015] The word vector acquisition module is used to train the text data in the talent knowledge graph using the FastText algorithm and obtain the word vector corresponding to each word in the text data based on the training results;

[0016] The model training module is used to input the word vector corresponding to each word in the text data into the TransH algorithm for training, and obtain the improved TransH algorithm, as follows:

[0017] Acquire triple data about the talent knowledge graph, the triple data including a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtain an initial vector for the triple according to the weighted word vectors of all words in the word set;

[0018] Obtaining the categories to which the head entity and the tail entity belong, encoding the categories, obtaining the head entity vector and the tail entity vector according to the encoding result and the initial vector, and calculating the Euclidean distance according to the head entity vector and the tail entity vector;

[0019] Constructing a loss function according to the Euclidean distance, calculating a loss value according to the loss function, and judging whether the TransH algorithm has converged according to the loss value, and terminating the training if it has converged;

[0020] The triple data analysis module is used to input the triple data to be analyzed into the improved TransH algorithm to obtain the target vectors corresponding to the head entity and the tail entity in the triple data to be analyzed.

[0021] In a third aspect, the present invention provides a storage medium storing one or more programs, which, when executed by a processor, implement the above-mentioned knowledge graph representation method based on the FastText-TransH algorithm.

[0022] In a fourth aspect, the present invention provides an electronic device, comprising a memory and a processor, wherein:

[0023] The memory is used to store computer programs;

[0024] When the processor is used to execute the computer program stored in the memory, it implements the above-mentioned knowledge graph representation method based on the FastText-TransH algorithm.

[0025] In summary, based on the aforementioned knowledge graph representation method based on the FastText-TransH algorithm, a knowledge graph embedding algorithm that integrates structural and semantic information is constructed, combining a relational projection model with an entity category enhancement mechanism to significantly improve the representation capability and reasoning efficiency of large-scale knowledge graphs. By fusing TransH's relational hyperplane projection mechanism with the subword semantic information of entity names and introducing entity category constraints, this framework leverages FastText's subword sharing mechanism to improve semantic generalization for low-frequency entities (such as "high-reliability system") when dealing with complex graphs related to talent and achievements. It also leverages TransH's relational hyperplane to address the modeling challenges of many-to-many relationships (such as "talent-publication-paper"). Furthermore, it optimizes the semantic distribution in the vector space by using entity category information (e.g., distinguishing between "talent category" and "achievement category"). This enables the model to more clearly distinguish between different categories of entities and their relationships, comprehensively improving overall performance on large-scale knowledge graphs and effectively enhancing the accuracy and interpretability of knowledge graph representation. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a flowchart of a knowledge graph representation method based on the FastText-TransH algorithm proposed in one embodiment of the present invention;

[0027] Figure 2A detailed diagram of step S102 according to an embodiment of the present invention;

[0028] Figure 3 This is a structural diagram of a knowledge graph representation system based on the FastText-TransH algorithm proposed in one embodiment of the present invention.

[0029] The following specific embodiments will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Unless otherwise defined, the technical terms or scientific terms used herein should be the common meanings understood by people with ordinary skills in the field to which the invention belongs. The words "including" and similar words used in this article mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects.

[0031] like Figure 1 As shown, an embodiment of the present invention proposes a knowledge graph representation method based on the FastText-TransH algorithm, which includes steps S101 to S103, wherein:

[0032] Step S101: Use the FastText algorithm to train the text data in the talent knowledge graph, and obtain the word vector corresponding to each word in the text data based on the training results;

[0033] FastText is a powerful word vector learning algorithm that has significant advantages in processing text data. Traditional word vector algorithms (such as Word2Vec) usually treat each word as an independent unit for learning and cannot provide effective vector representations for words that do not appear in the training data (out-of-vocabulary words). FastText introduces sub-word information, which enables it to demonstrate powerful capabilities even when dealing with languages such as Chinese. Take the Chinese word "人工智能" (artificial intelligence) as an example. FastText will split it into multiple character n-gram sub-words. When n = 2, the possible sub-words are "人工" (artificial) and "智能" (intelligence). When n = 3, there is "人工智能" (artificial intelligence), etc. During the learning process, FastText not only learns the vector of the entire word "人工智能" but also learns the vectors of these sub-words. This approach allows FastText to generate reasonable vector representations for in-vocabulary words. For example, when encountering an out-of-vocabulary word "人工智能技术" (artificial intelligence technology), since it contains known sub-words such as "人工" and "智能", FastText can use the vector combinations of these sub-words to approximately represent the vector of "人工智能技术".

[0034] It should be noted that after obtaining the text data, the text data in the talent knowledge graph is first preprocessed, such as word segmentation and stop word removal. Then, the processed text data is trained using the FastText algorithm. After the FastText algorithm training is completed, for any word in the text, it is input into the trained FastText algorithm to obtain the corresponding word vector.

[0035] For example, for the talent knowledge graph, patent and paper abstracts contain a wealth of semantic information. These abstracts are collected and segmented using the Jieba tool, removing meaningless words and stop words from the sequence. For example, consider an abstract such as "In this study, we combined artificial intelligence technology to achieve fuzzy license plate recognition." Using the Jieba tool for segmentation yields the following: "In this study, we combined artificial intelligence technology to achieve fuzzy license plate recognition." Punctuation, meaningless words, and stop words (such as "in," "in," and "have") are removed, resulting in: "In this study, we combined artificial intelligence technology to achieve fuzzy license plate recognition." The processed text data is then trained using the FastText algorithm to train word vectors, ultimately generating word vector representations for each word. For example, the word vector for "intelligence" is represented as "[0.00235796, 0.09234943, 0.1239492, ..., 0.043636239]". It is important to note that the word vectors obtained through the above steps are the word vectors of the vocabulary contained in the abstracts of patents, papers, and other articles, rather than just the word vectors representing entities in the knowledge graph.

[0036] After FastText training is complete, a corresponding word vector is generated for any word in the text. For example, if we input "intelligent recognition," the corresponding word vector generated using the trained FastText algorithm will output: "[0.123929396, 0.042232494, 0.00422322, ..., 0.10300029]."

[0037] Step S102: inputting the word vector corresponding to each word in the text data into the TransH algorithm for training to obtain an improved TransH algorithm;

[0038] It should be pointed out that if Figure 2 As shown, this step includes steps S1021 to S1023, wherein:

[0039] Step S1021: Acquire triple data about the talent knowledge graph, wherein the triple data includes a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtain an initial vector for the triple according to the weighted word vectors of all words in the word set;

[0040] In some embodiments, the triple data is first divided into positive triples and negative triples, and then the head entity in the positive triple is set ,relation and tail entity Respectively by It consists of words, and , , In addition, the initial vectors of entities and relations are obtained by weighted combination of the FastText word vectors of the words they contain:

[0041] ;

[0042] in, are the word sets corresponding to the head entity, relation, and tail entity respectively. 、 、 are the first, second, and mth words in the word set corresponding to the head entity, are the first, second, and nth words in the word set corresponding to the relationship, are the first, second, and pth words in the word set corresponding to the tail entity, are the initial vectors corresponding to the head entity, relation, and tail entity respectively, are the weight coefficient and word vector of the i-th word in the word set corresponding to the head entity, are the weight coefficient and word vector of the jth word in the word set corresponding to the relationship, are the weight coefficient and word vector of the kth word in the word set corresponding to the tail entity, respectively. The corresponding word weight coefficients will be learned during subsequent model training to adjust the contribution of different words to entity and relationship representations. Furthermore, these weight coefficients have no specific fixed range before training and theoretically belong to the real number set R. In actual training, to ensure model stability and rationality, they are constrained to the interval [0, 1] after normalization and other operations.

[0043] In summary, regarding traditional knowledge graph embedding methods, especially those using only TransH, it is important to point out that these methods primarily rely on the structural information of the knowledge graph when processing the vector representations of entities and relations, and fail to fully exploit the textual semantic information contained in these entities and relations. This sole reliance on structural information fails to fully consider the rich semantic details in the text and the complementarity between different modalities. As a result, in complex knowledge representation scenarios, the generated vector representations fail to accurately reflect the true semantics of entities and relations, resulting in poor performance in tasks such as knowledge reasoning and link prediction. In this step, the weighted fusion formula based on FastText introduces a dynamic weighting mechanism to achieve a deep fusion of knowledge graph structural information and textual semantic information. Different entities vary in the richness of their textual descriptions and the importance of their structural features. For entities with detailed textual descriptions, such as patent titles, paper titles, and award titles, the textual semantic weight in the formula is increased, allowing the model to more fully capture the unique semantic information contained in the text. For entities dominated by structural features, such as abstract concepts or numerical entities, the structural information weight is prioritized to ensure that key structural features are not overlooked. Varies with relationship type: Different relationships play different roles in the knowledge graph, and their reliance on textual semantics and structural information varies. For relationships with strong semantic connections (such as "belongs to"), the weight of textual semantics is increased to better match the semantic relationship. For relationships that emphasize structural connections (such as "contains"), structural information is given a higher weight to highlight structural connections.

[0044] Step S1022: Obtain the categories to which the head entity and the tail entity belong, encode the categories, obtain the head entity vector and the tail entity vector according to the encoding result and the initial vector, and calculate the Euclidean distance according to the head entity vector and the tail entity vector;

[0045] It should be noted that traditional entity vector representation fusion methods often use simple splicing or fixed weight addition. This method does not fully consider the differences in the contributions of different information sources to entity representation, as well as the changes in the characteristics of entities in different situations. Simple fusion methods cannot effectively capture the dynamic semantic information of entities. In complex knowledge graph scenarios, it is difficult to accurately represent entities, resulting in limited performance in tasks such as knowledge reasoning and link prediction. Based on this, this step first classifies the entities in the knowledge graph, and sets the category set as , the category of the head entity is , the one-hot encoding vector of the category to which the head entity belongs is represented as , the category of the tail entity is , the one-hot encoding vector of the category to which the tail entity belongs is represented as ;

[0046] For example, entity categories in the knowledge graph include personnel information, awards and honors, patents, papers and articles, research projects, schools, and majors, and they belong to category set C. Each category has a one-hot encoding vector. For example, the one-hot encoding vector for personnel information is [1, 0, 0, 0, 0, 0], and the one-hot encoding vector for awards and honors is [0, 1, 0, 0, 0, 0, 0].

[0047] Fuse the initial vector with the one-hot encoded vector representation:

[0048] ;

[0049] in, 、 are the updated head entity vector and tail entity vector respectively, 、 、 、 、 、 are all hyperparameters, This is element-wise multiplication.

[0050] According to the above fusion formula, as the importance of the information source changes, the weight is adjusted through training 、 、 、 、 、 , it can flexibly allocate the contribution of different information sources to the updated vector based on their importance in different tasks or entity characteristics (such as textual semantic information from FastText and the structural information contained in the entity initial vector). In combination with nonlinear interactions, the element-by-element multiplication operation between vectors introduces nonlinear interactions. This operation is not a simple linear superposition, but rather explores the deep semantic associations between the initial vector and the FastText semantic vector. It can discover the synergistic effects between the features of different information sources and generate more discriminative and expressive entity vector representations, thereby better capturing the complex relationships between entities in knowledge graph-related tasks and improving overall performance.

[0051] also, The value range is [0.1, 1], which refers to the weight ratio of the initial vector itself in the updated vector. The larger the value, the greater the influence of the initial vector. The value range of is usually [0,1], which is used to measure the contribution of the category one-hot encoding vector to the updated vector. The larger the value, the more important the category information is in the vector representation. The general value of is in [0,1], which determines the weight of the element-by-element multiplication of the initial vector and the category one-hot encoding vector. The larger the value, the greater the impact of this interaction on the updated vector.

[0052] In addition, in some embodiments, weight matrices of different types of relationships are used to capture the semantic features between entities under different relationship types, and a set of relationship types is defined, such as "personnel information relationship", "award and honor relationship", etc. For each relationship, there is a corresponding relationship type, and weight matrices are introduced for different types of relationships to adjust the entity projection. Each relationship corresponds to a hyperplane normal vector and a relationship vector.

[0053] Specifically, the updated head entity vector and tail entity vector Project onto the hyperplane corresponding to the relation:

[0054] ;

[0055] in, 、 are the projection vectors corresponding to the head entity and the tail entity respectively, is the normal vector of the hyperplane corresponding to the relation, is a weight matrix corresponding to the type of relationship, which updates the parameters in the weight matrix by minimizing the loss function.

[0056] Furthermore, in some embodiments, the weight matrix is ​​expressed as follows:

[0057] .

[0058] is the element in the dth row and dth column of the weight matrix. The value range of any element is .

[0059] The traditional TransH algorithm defines a hyperplane for each relationship, and the hyperplane is composed of the normal vector The entity vector is projected onto a hyperplane via a dot product operation with the normal vector. This only considers the entity's projected position on the hyperplane and does not distinguish the impact of different relationship types on the entity projection. It assumes that different relationships belong to the same hyperplane and that different entities are in the same semantic space. However, this embodiment takes into account the differences in relationship types by introducing a weight matrix for different types of relationships to adjust entity projections. During entity projection, not only is the hyperplane normal vector used for projection calculation, but the updated entity vector is also adjusted in conjunction with the weight matrix corresponding to the relationship type. This ensures that the projected vector representation captures the semantic features between entities under different relationship types, allowing for more flexible entity projection methods for different relationship types. Furthermore, by introducing a relationship type weight matrix, entity projections can be adjusted differently for different relationship types (such as "personnel information relationship" and "award and honor relationship"), exploring subtle differences in entity semantics under different relationship types and ensuring that the vector representations of entities under different relationship types better reflect their true semantics. For example, in "personnel information relationships," more attention may be paid to the semantics related to the basic attributes of personnel; in "reward and honor relationships," more emphasis may be placed on semantics related to honors, allowing the model to capture semantics more accurately.

[0060] In addition, the Euclidean distance needs to be calculated according to the following formula:

[0061] ;

[0062] in, is the Euclidean distance in the positive triplet, d is the dimension of the vector, is the relation vector in the positive triplet, 、 are the i-th element of the projection vector corresponding to the head entity and the tail entity respectively.

[0063] In addition, it should be pointed out that the Euclidean distance in the counterexample triple is obtained in the same way as the Euclidean distance in the positive example triple, except that the objects processed are different. Therefore, the Euclidean distance in the counterexample triple is not described in this embodiment.

[0064] Step S1023: constructing a loss function according to the Euclidean distance, calculating a loss value according to the loss function, and judging whether the TransH algorithm has converged according to the loss value. If converged, the training ends.

[0065] In this step, the loss function is constructed according to the following formula:

[0066] ;

[0067] Among them, L is the loss value, N is the number of triplets, is an interval hyperparameter with a value range of [0.5, 2], which is used to control the score gap between positive and negative examples. is the Euclidean distance in the counterexample triple, is the average distance within the class, is the average distance between classes, G is the set of positive triples in the knowledge graph, is the set of counterexample triples in the knowledge graph, 、 、 are the head entity vector, relation vector, and tail entity vector in the negative triplet, respectively. 、 are the head entity vector and the tail entity vector in the positive example triplet, and are all hyperparameters, and their value ranges are all in [0.01,1]. To take the positive function.

[0068] The average distance within a class is calculated according to the following formula:

[0069] ;

[0070] The average distance between classes is calculated according to the following formula:

[0071] ;

[0072] in, is the average distance within the class, n is the total number of categories of all entities in the triple data, is the category set of the i-th entity, For category collection The number of entities in is the i-th entity category set The mean vector of all entity vectors in , and are the k-th dimension components of the mean vectors of the i-th and j-th categories respectively, For Entity The value of the kth dimension in the vector representation of , e is the set A specific entity in is the average distance between classes, and d is the dimension of the entity vector.

[0073] In summary, since the traditional loss function is mainly based on the maximum margin idea, it optimizes the vector representation of entities and relationships by constraining the distance between positive and negative examples on the hyperplane, focusing on the structural rationality of entities and relationships in triples, but does not take into account the intra-class aggregation and inter-class separation characteristics of entity semantics. When processing semantically similar entities, their vector representations may be insufficiently distinguishable, which is not conducive to accurately capturing semantic details. Based on this, this embodiment incorporates the difference in positive and negative example scores based on the margin on the basis of the traditional TransH loss function, and combines the intra-class and inter-class distance terms to form a more comprehensive loss calculation method. While increasing the gap between the positive and negative example scores, with the help of the intra-class and inter-class distance constraints, the model's distinction between positive and negative examples is not only based on structure, but also considers aggregation and separation at the semantic level. For example, in complex knowledge reasoning tasks, it can more accurately judge the rationality of triple combinations and improve the performance of the model in tasks such as link prediction and knowledge reasoning.

[0074] In addition, the loss value is calculated through the loss function designed in this step, and the parameters are updated using the Adam optimizer. Then, it is determined whether the loss converges. If it converges, the training is terminated, and the improved TransH algorithm is obtained.

[0075] Step S103: inputting the triplet data to be analyzed into the improved TransH algorithm to obtain target vectors corresponding to the head entity and the tail entity in the triplet data to be analyzed.

[0076] It should be noted that the target vector refers to the projection vector, and the triple data to be analyzed is similar to the triple data in the talent knowledge graph during the training process.

[0077] In summary, based on the aforementioned knowledge graph representation method based on the FastText-TransH algorithm, a knowledge graph embedding algorithm that integrates structural and semantic information is constructed, combining a relational projection model with an entity category enhancement mechanism to significantly improve the representation capability and reasoning efficiency of large-scale knowledge graphs. By fusing TransH's relational hyperplane projection mechanism with the subword semantic information of entity names and introducing entity category constraints, this framework leverages FastText's subword sharing mechanism to improve semantic generalization for low-frequency entities (such as "high-reliability system") when dealing with complex graphs related to talent and achievements. It also leverages TransH's relational hyperplane to address the modeling challenges of many-to-many relationships (such as "talent-publication-paper"). Furthermore, it optimizes the semantic distribution in the vector space by using entity category information (e.g., distinguishing between "talent category" and "achievement category"). This enables the model to more clearly distinguish between different categories of entities and their relationships, comprehensively improving overall performance on large-scale knowledge graphs and effectively enhancing the accuracy and interpretability of knowledge graph representation.

[0078] On the other hand, the present invention also proposes a storage medium on which one or more programs are stored, which, when executed by a processor, implement the above-mentioned knowledge graph representation method based on the FastText-TransH algorithm.

[0079] On the other hand, the present invention also proposes an electronic device, including a memory and a processor, wherein the memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory to implement the above-mentioned knowledge graph representation method based on the FastText-TransH algorithm.

[0080] Those skilled in the art will appreciate that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device), or in conjunction with such instruction execution system, apparatus, or device. For purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution system, apparatus, or device.

[0081] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting, or processing it in another suitable manner as necessary, and then storing it in a computer memory.

[0082] It should be understood that various components of the present invention may be implemented using hardware, software, firmware, or a combination thereof. In the aforementioned embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one or a combination of the following technologies known in the art may be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.

[0083] While the embodiments of the present invention have been described in detail above, it will be apparent to those skilled in the art that various modifications and variations of these embodiments are possible. However, it should be understood that such modifications and variations are within the scope and spirit of the present invention as set forth in the claims. Furthermore, the invention described herein is susceptible to other embodiments and may be practiced or implemented in a variety of ways.

Claims

1. A knowledge graph representation method based on the FastText-TransH algorithm, characterized in that: The method comprises: Use the FastText algorithm to train the text data in the talent knowledge graph, and obtain the word vector corresponding to each word in the text data based on the training results; The word vector corresponding to each word in the text data is input into the TransH algorithm for training to obtain the trained TransH algorithm, as follows: Acquire triple data about the talent knowledge graph, the triple data including a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtain an initial vector for the triple according to the weighted word vectors of all words in the word set; Obtaining the categories to which the head entity and the tail entity belong, encoding the categories, obtaining the head entity vector and the tail entity vector according to the encoding result and the initial vector, and calculating the Euclidean distance according to the head entity vector and the tail entity vector; Constructing a loss function according to the Euclidean distance, calculating a loss value according to the loss function, and judging whether the TransH algorithm has converged according to the loss value, and terminating the training if it has converged; The triple data to be analyzed is input into the trained TransH algorithm to obtain the target vectors corresponding to the head entity and the tail entity in the triple data to be analyzed.

2. The knowledge graph representation method based on the FastText-TransH algorithm according to claim 1, characterized in that: The step of obtaining triple data about the talent knowledge graph, wherein the triple data includes a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtaining an initial vector for the triple by weighting the word vectors of all words in the word set includes: Dividing the triplet data into positive example triples and negative example triples; Let the head entity in the positive triple be ,relation and tail entity Respectively by It consists of words, and , , ; The initial vector of the positive triple is obtained according to the following formula: ; in, are the word sets corresponding to the head entity, relation, and tail entity respectively. 、 、 are the first, second, and mth words in the word set corresponding to the head entity, are the first, second, and nth words in the word set corresponding to the relationship, are the first, second, and pth words in the word set corresponding to the tail entity, are the initial vectors corresponding to the head entity, relation, and tail entity respectively, are the weight coefficient and word vector of the i-th word in the word set corresponding to the head entity, are the weight coefficient and word vector of the jth word in the word set corresponding to the relationship, are the weight coefficient and word vector of the kth word in the word set corresponding to the tail entity, respectively.

3. The knowledge graph representation method based on the FastText-TransH algorithm according to claim 2, characterized in that: The steps of obtaining the categories to which the head entity and the tail entity belong, encoding the categories, and obtaining the head entity vector and the tail entity vector according to the encoding results and the initial vector include: Let the category set be , the category of the head entity is , the one-hot encoding vector of the category to which the head entity belongs is represented as , the category of the tail entity is , the one-hot encoding vector of the category to which the tail entity belongs is represented as ; Fuse the initial vector with the one-hot encoded vector representation: ; in, 、 are the updated head entity vector and tail entity vector respectively, 、 、 、 、 、 are all hyperparameters, This is element-wise multiplication.

4. The knowledge graph representation method based on the FastText-TransH algorithm according to claim 3, characterized in that: The step of calculating the Euclidean distance according to the head entity vector and the tail entity vector comprises: The updated head entity vector and tail entity vector Project onto the hyperplane corresponding to the relation: ; in, 、 are the projection vectors corresponding to the head entity and the tail entity respectively, is the normal vector of the hyperplane corresponding to the relation, is the weight matrix corresponding to the type of relationship; The Euclidean distance is calculated according to the following formula: ; in, is the Euclidean distance in the positive triplet, d is the dimension of the vector, is the relation vector in the positive triplet, 、 are the i-th element of the projection vector corresponding to the head entity and the tail entity respectively.

5. The knowledge graph representation method based on the FastText-TransH algorithm according to claim 4, characterized in that: The loss function is constructed according to the following formula: ; Among them, L is the loss value, N is the number of triplets, is the interval hyperparameter used to control the score gap between positive and negative examples. is the Euclidean distance in the counterexample triple, is the average distance within the class, is the average distance between classes, G is the set of positive triples in the knowledge graph, is the set of counterexample triples in the knowledge graph, 、 、 are the head entity vector, relation vector, and tail entity vector in the negative triplet, respectively. 、 are the head entity vector and the tail entity vector in the positive example triplet, and are all hyperparameters, To take the positive function.

6. The knowledge graph representation method based on the FastText-TransH algorithm according to claim 5, characterized in that: The average distance within a class is calculated according to the following formula: ; The average distance between classes is calculated according to the following formula: ; in, is the average distance within the class, n is the total number of categories of all entities in the triple data, is the category set of the i-th entity, For category collection The number of entities in is the i-th entity category set The mean vector of all entity vectors in , and are the k-th dimension components of the mean vectors of the i-th and j-th categories respectively, For Entity The value of the kth dimension in the vector representation of , e is the set A specific entity in is the average distance between classes, and d is the dimension of the entity vector.

7. A knowledge graph representation system based on the FastText-TransH algorithm, characterized in that: The system comprises: The word vector acquisition module is used to train the text data in the talent knowledge graph using the FastText algorithm and obtain the word vector corresponding to each word in the text data based on the training results; The model training module is used to input the word vector corresponding to each word in the text data into the TransH algorithm for training, and obtain the trained TransH algorithm, as follows: Acquire triple data about the talent knowledge graph, the triple data including a word set of a head entity, a relationship, and a tail entity in a triple belonging to the talent knowledge graph, and obtain an initial vector for the triple according to the weighted word vectors of all words in the word set; Obtaining the categories to which the head entity and the tail entity belong, encoding the categories, obtaining the head entity vector and the tail entity vector according to the encoding result and the initial vector, and calculating the Euclidean distance according to the head entity vector and the tail entity vector; Constructing a loss function according to the Euclidean distance, calculating a loss value according to the loss function, and judging whether the TransH algorithm has converged according to the loss value, and terminating the training if it has converged; The triplet data analysis module is used to input the triplet data to be analyzed into the trained TransH algorithm to obtain the target vectors corresponding to the head entity and the tail entity in the triplet data to be analyzed.

8. A storage medium, characterized in that: The storage medium stores one or more programs, which, when executed by the processor, implement the knowledge graph representation method based on the FastText-TransH algorithm as described in any one of claims 1 to 6.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute a computer program stored in the memory, it implements the knowledge graph representation method based on the FastText-TransH algorithm as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Knowledge graph representation learning method and system in combination with entity description

    CN106886543A

  • Knowledge graph representation learning method fusing entity description and types

    CN111753101A