WO2020177142A1 - 一种基于传递关系的本地自适应知识图谱优化方法 - Google Patents
一种基于传递关系的本地自适应知识图谱优化方法 Download PDFInfo
- Publication number
- WO2020177142A1 WO2020177142A1 PCT/CN2019/077728 CN2019077728W WO2020177142A1 WO 2020177142 A1 WO2020177142 A1 WO 2020177142A1 CN 2019077728 W CN2019077728 W CN 2019077728W WO 2020177142 A1 WO2020177142 A1 WO 2020177142A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- entity
- relationship
- distance
- transfer
- knowledge
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/36—Creation of semantic tools, e.g. ontology or thesauri
Definitions
- the invention belongs to the field of knowledge management and information retrieval, and specifically relates to a local adaptive knowledge graph optimization method based on transfer relations.
- Knowledge Graph is a large-scale structured data collection that is used to describe various entities and concepts that exist in the real world, as well as the connections between entities and entities, entities and concepts, and concepts and concepts, and expand the knowledge structure , And then can be identified and analyzed by the computer.
- the knowledge graph consists of triples (h, r, t) (h, r, t represent head entity, relationship, and tail entity, respectively).
- the main method is to embed entities and relationships into the same low-dimensional space, or embed entities and relationships into different low-dimensional spaces.
- These methods can construct the knowledge graph model extremely well, and can obtain good results.
- the TransA model can dynamically determine the parameters of the loss function according to the entities and relationships of the knowledge graph, and theoretically proves the important role of the parameters in the loss function in the localization of the knowledge graph modeling.
- triples to represent (human, image, ape), (ape, image, monkey), (monkey, image, pig).
- the "image” here can be regarded as the "relationship” that often appears in the knowledge graph triplet data.
- we can't and dare not get the triples similar to the first example, such as (human, like, pig) this type of triple. It can be seen from common sense that such triples are wrong triples. But like (human, like, monkey) this type of triples can indeed be acceptable to a certain extent, but it is not completely acceptable.
- the definition of this type of triples is vague and can be considered right and wrong, without a clear definition. However, if it continues to be passed on in this way, it must be considered wrong.
- the present invention proposes a local adaptive knowledge graph optimization method based on the transfer relationship, namely TransAT, which introduces the transfer relationship into the aforementioned TransA model to form a new knowledge graph model, that is, based on the transfer relationship TransAT, a local adaptive knowledge graph model.
- TransAT transfer relationship
- the stochastic gradient descent algorithm in the knowledge graph and the local adaptive knowledge graph model are expanded.
- the resulting stochastic gradient descent algorithm will use different optimization strategies for the replaced entity according to the distance from the original entity. Optimize the effect to obtain a new knowledge graph model.
- edge parameters are generated, which are applied to the loss function to optimize the model to obtain a local adaptive knowledge graph based on transfer relationships.
- a local adaptive knowledge graph optimization method based on transfer relations the specific steps are as follows:
- Step 2 Set any r i to initially belong to a certain distribution, and r i ⁇ R; set any e i to initially belong to a certain distribution, be the same distribution or different from the distribution of r i , and e ⁇ E,e Is h or t;
- Step 3 Normalize r i , h i , t i , the normalization formulas are:
- Step 4 Randomly extract samples with sample size b from the training sample set to form a new training sample set S batch :
- S batch sample(S,b); where sample(S,b) means in the training sample set S Randomly draw b samples;
- Step 7 For the entity h or t, obtain the entity's edge parameter M ent , the formula is as follows:
- t ⁇ P r , t′ ⁇ N r ⁇ T r , l ⁇ T r , t′ ⁇ N r , ⁇ (x) is a function to find the absolute value
- d represents the farthest distance that knowledge can be transferred
- f( i) represents the energy of each part of the entity after transfer and f(i) ⁇ 0
- the total transferred energy in the entire formula should be 1
- R h represents the relationship set involved in the entity h in the triple set
- r represents a certain relationship h involved in the triple set
- n represents the number of relationships in the R h set
- Step 8 For the relationship r, obtain the edge parameter M rel of the relationship, and the formula is as follows:
- represents the distance from a given specific relationship to the relationship in the R h, r set, Indicates the minimum difference between the given relationship and the relationship distance in R h,r , and when
- does not exist or R h,r is empty, M rel 0 ;
- Step 9 Calculate the parameters that the edge parameters change with the entities and relationships.
- the formula is as follows:
- M ent represents the edge parameter of the entity
- M rel represents the edge parameter of the relationship
- the parameter ⁇ controls the ratio of M ent and M rel to M opt , and 0 ⁇ 1;
- Step 10 Bring the newly obtained M opt into the loss function to obtain a new loss function based on the transfer relationship, which is:
- fr is a distance function based on the relation r, specifically, fr (h,t) is the distance function between h+r and t, and fr (h′,t′) is h′+r and t 'The distance function between;
- Step 11 Determine if M opt +f r (h,t)>f r (h′,t′), enter the set of triples T batch , use the stochastic gradient descent function SGD to optimize each entity or relationship vector, The optimized E and R vector sets are obtained, and the knowledge graph optimization is completed. If it is judged that M opt +f r (h,t) ⁇ f r (h′,t′), no optimization is required;
- the stochastic gradient descent function SGD is optimized, and the formula is as follows:
- m represents the entity or relationship
- m′ represents the optimized entity or relationship
- ⁇ represents the learning rate of stochastic gradient descent
- m 0 and m each represent an entity transfer and dissemination of knowledge entities inspiration received
- t r (m 0, d ) represents the relationship of r Based on the range function of knowledge transfer
- d represents the distance of knowledge transfer
- the main method is to embed entities and relationships into the same low-dimensional space, or embed entities and relationships into different low-dimensional spaces.
- These methods can construct the knowledge graph model extremely well, and can obtain good results.
- most of the existing knowledge graph models do not consider the transferability of knowledge, that is, when constructing triples, they do not consider the associations between the relationships and entities in the triples and the entities and relationships in other triples. Or analyze in depth.
- the present invention can make up for the incompleteness of data to a large extent through the introduction of the transitivity of the relationship and the continuous weakness of this transitivity in the process of relationship deduction, and can better express the potential different semantics between the relationship and the entity , So to get better results.
- the new knowledge graph constructed after optimization that is, the optimized E and R vector set link prediction and triple classification have higher accuracy .
- FIG. 1 is a flowchart of a method for optimizing a local adaptive knowledge graph based on a transfer relationship according to an embodiment of the present invention.
- Step 2 Set any r i to initially belong to a certain distribution, and r i ⁇ R; set any e i to initially belong to a certain distribution, and the distribution of r i to belong to the same distribution or different distributions, and e ⁇ E,e is h or t;
- Step 3 Normalize r i , h i , t i , the normalization formulas are:
- Step 4 Randomly extract samples with sample size b from the training sample set to form a new training sample set S batch :
- S batch sample(S,b); where sample(S,b) means in the training sample set S Randomly draw b samples;
- Step 6 Based on the normalized r i , h i , t i , set (h,r,t) ⁇ S batch as the correct triplet, and its corresponding (h',r,t') is wrong Replace the correct triple with the wrong head entity or tail entity to form the wrong training sample set S′(h′,r,t′), and merge it into the triple set T batch :
- T batch T batch ⁇ (h′,r,t′),(h,r,t) ⁇ ;
- Step 7 For the entity h or t, obtain the entity's edge parameter M ent , the formula is as follows:
- t ⁇ P r , t′ ⁇ N r ⁇ T r , l ⁇ T r , t′ ⁇ N r , ⁇ (x) is a function to find the absolute value
- d represents the farthest distance that knowledge can be transferred
- f( i) represents the energy of each part of the entity after transfer and f(i) ⁇ 0
- the total transferred energy in the entire formula should be 1
- R h represents the relationship set involved in the entity h in the triple set
- r represents a certain relationship h involved in the triple set
- n represents the number of relationships in the R h set
- Step 8 For the relationship r, obtain the edge parameter M rel of the relationship, and the formula is as follows:
- represents the distance from a given specific relationship to the relationship in the R h, r set, Indicates the minimum difference between the given relationship and the relationship distance in R h,r , and when
- does not exist or R h,r is empty, M rel 0 ;
- Step 9 Calculate the parameters that the edge parameters change with the entities and relationships.
- the formula is as follows:
- M ent represents the edge parameter of the entity
- M rel represents the edge parameter of the relationship
- the parameter ⁇ controls the ratio of M ent and M rel to M opt , and 0 ⁇ 1;
- Step 10 Bring the newly obtained M opt into the loss function to obtain a new loss function based on the transfer relationship, which is:
- fr is a distance function based on the relation r, specifically, fr (h,t) is the distance function between h+r and t, and fr (h′,t′) is h′+r and t 'The distance function between;
- Step 11 Determine if M opt +f r (h,t)>f r (h′,t′)), enter the set of triples T batch , and use the stochastic gradient descent function SGD to optimize each entity or relationship vector , The optimized E and R vector set is obtained, that is, the knowledge graph optimization is completed. If it is judged that M opt +f r (h,t) ⁇ f r (h′,t′), no optimization is required;
- the stochastic gradient descent function SGD is optimized, and the formula is as follows:
- m represents the entity or relationship
- m′ represents the optimized entity or relationship
- ⁇ represents the learning rate of stochastic gradient descent
- m 0 and m each represent an entity transfer and dissemination of knowledge entities inspiration received
- t r (m 0, d ) represents the relationship of r Based on the range function of knowledge transfer
- d represents the distance of knowledge transfer
- Table 1 Local adaptive knowledge graph model based on knowledge transfer
- the input of the algorithm is the triple set, the entity set, the relationship set, the dimension of the low-dimensional space that the entity and the relationship need to be embedded, the distance for the propagation of entity knowledge, and the constraints on the edge parameters of the entity part and the edge parameters of the relationship part in the edge parameters. parameter.
- the "triple set” here can be obtained from existing resources such as WordNet and Freebase.
- the output of the algorithm is a local adaptive knowledge graph model based on transfer relations. Lines 1 and 2 represent the initial operations on the relationship, each relationship is randomly assigned a position within the constraint in the low-dimensional space, and it can be better processed to normalize the relationship. The third line indicates that all entities are embedded in the low-dimensional space vector, and the positions are randomly allocated in a region.
- Lines 4-18 indicate the cyclic optimization of the adaptive knowledge graph model based on the transfer relationship, where the fifth line indicates the normalization of the entities involved, namely the head entity and the tail entity, and the sixth line indicates the ternary A part of the group set is selected as the training set.
- Lines 7-11 indicate the collection of the correct triples and the wrong triples.
- Lines 9 and 10 indicate the replacement of the head entity or tail entity in the correct triples to form the wrong triples, and the 12th Line -14 is to calculate M ent , M rel , M opt by formula (4), formula (5) and formula (6).
- Lines 15-17 are to optimize the parameters involved in the correct triplet and the wrong triplet.
- Line 15 is the local adaptive loss function based on the transfer relationship to determine whether to optimize the parameters involved.
- the 16th line is to perform stochastic gradient descent operation on h, t, r in the correct triplet and h′, t′, r in the wrong triplet.
- the called stochastic gradient descent function SGD is described in Table 2, using Pseudo code implementation:
- the input of the function SGD is: correct triples, wrong triples, embedded low-dimensional space dimensions in the knowledge graph, the learning rate of the stochastic gradient descent algorithm, and the propagation distance of knowledge, and then get the entity and relationship processing , Position in the low-dimensional embedded space.
- the first line shows the energy value of the exchanged entity in the wrong triplet and the original entity in the correct triplet.
- Lines 2-11 show the cyclic optimization of entities and relationships in the knowledge graph model.
- Lines 3-6 show the results of the optimization of the correct triples.
- lines 7-10 show the wrong triples. Based on the optimized results after supporting the propagation, formula (8) is used.
- the third row and the seventh row respectively represent the derivation of the difference in the correct triplet and the difference in the wrong triplet.
- the gradient descent algorithm is one of the basic methods of model optimization in machine learning.
- the algorithm selects a training sample randomly through the training set, calculates the gradient during the iterative solution process of the model, and calculates the parameters in the model through the calculated gradient Update.
- the main idea of the stochastic gradient descent algorithm is: in a given training sample set M, N samples are randomly selected as the new training sample set to replace the original training sample set M to complete the model training.
- the stochastic gradient descent algorithm optimizes the parameters of the loss function f. It updates the parameter w in the opposite direction of the gradient until the function converges.
- the algorithm is:
- w represents the parameter that needs to be optimized
- w′ represents the value of the new parameter obtained after optimization
- ⁇ represents the learning rate
- Optimized stochastic gradient descent algorithm here actually introduces the transfer relationship.
- h i is a vector of the first entity
- t i is a vector of the end entity
- r i is connected to a head and tail entity entity relationship vector.
- h i ⁇ R k and t i ⁇ R k and r i ⁇ R d where k may be equal to d or not equal to d.
- R k and R d may be the same or different.
- h i, t i, and r i can be fitted in the same space R k, the same h i, t i may be in the space R k, and r i in the space R d.
- ⁇ represents the correct set of triples, that is, this triple appears in the training set, ⁇ 'represents the wrong triple.
- the main idea of the stochastic gradient descent algorithm based on the transfer relationship is: because it cannot be completely determined whether the transfer relationship is distorted during transfer, when the knowledge graph model is optimized, when the transfer has more energy, the relationship propagation The closer the distance, the lower the gradient of the position of the corresponding transformation in the error ternary; the farther the relationship spreads, the lower the energy transferred, and the higher the gradient of the position of the corresponding transformation in the error ternary until Change back to the normal gradient.
- m represents the entity or relationship
- m′ represents the optimized entity or relationship
- ⁇ represents the learning rate of stochastic gradient descent
- H + represents a triple derivative
- t r (m 0, d ) represents the relationship based on the transfer of knowledge of r The range function of, and 0 ⁇ t r (m 0 ,d) ⁇ 1.
- d represents the distance of knowledge propagation.
- t r (m 0, d) may be, exponential function or logarithmic function, depending on the circumstances do specific selection of a linear function.
- the energy loss of the propagation energy changes exponentially during the transfer process, namely farther knowledge transfer, new knowledge of the meaning of the first m + r is not more similar, as the possibility of errors triplet (person, like, dogs) which occurs rapidly increased; when t r (m 0, d) is In the case of a numerical function, it means that as the propagation distance increases, the gradient changes in a logarithmic function, and eventually it will gradually tend to a stable gradient.
- the propagation energy is in the process of transmission.
- the construction of local adaptive knowledge graph model based on transfer relations The main purpose is to construct an optimized knowledge graph by introducing transfer relations and adaptive mechanisms. Mainly divided into the following 2 parts:
- the above-mentioned optimized stochastic gradient descent algorithm can be applied to other knowledge graphs based on embedded translation, that is, the optimized function can be applied to knowledge graph models such as TransE, TransH, TransD, and TransR.
- the optimization function is the stochastic gradient update after calculating the distance between h+r and t;
- TransH the optimization function is the gradient update after calculating the distance from the hyperplane of h and t to r; for TransD, TransR
- the optimized function of the combined TransE, TransH, TransD, and TransR models is the stochastic gradient descent algorithm.
- the stochastic gradient descent algorithm based on the transfer relationship is integrated into the existing optimization algorithm based on the knowledge graph of embedded translation to form the knowledge graph model (TransT) based on knowledge transfer.
- TransT knowledge graph model
- the construction of a knowledge graph combining transfer relationships and adaptive mechanisms.
- the knowledge graph embeds entities and relationships into the same low-dimensional or different low-dimensional vector spaces, and optimizes the knowledge graph model by minimizing the value obtained by the loss function.
- the loss function is composed of the difference between the correct triplet (h,r,t), the edge parameter ⁇ and the wrong triplet (h',r,t').
- Knowledge graph models such as TransE, TransH, and TransD all obtain the value of edge parameters through model training. Therefore, the value of the edge parameter in each loss function will change accordingly with different knowledge graph models.
- the local adaptive knowledge graph model proves the importance of edge parameters in the knowledge graph and the influence of entities and relationships on the edge parameters, but it does not consider the transferability between the relations in the knowledge graph.
- the transfer relationship is considered in TransA to form a new knowledge graph model-TransAT, a local adaptive knowledge graph model based on the transfer relationship.
- the edge parameter changes with the entity and the relationship, here it is set to M opt , and its value is:
- M ent represents the edge parameter of the entity
- M rel represents the edge parameter of the relationship
- the parameter ⁇ controls the ratio of M ent and M rel to M opt , and 0 ⁇ 1.
- the knowledge graph model at this time is the local adaptive knowledge graph model TransA.
- the marginal parameter M ent is composed of the first two types of correct entities and incorrect entities. M ent to the entity closer to h P r, T r and N r and away h, where h T r away from the part, while the other part is considered correct entity, the distance remains fixed, but is completely away from the N r h .
- the value of M ent is obtained by the weighted summation of the distance between the correct entity, the wrong entity, and the passed entity. Then the calculation of M ent in the knowledge graph model based on transfer is as follows:
- t ⁇ P r , t′ ⁇ N r ⁇ T r , l ⁇ T r , t′ ⁇ N r , ⁇ (x) is a function to find the absolute value
- d represents the farthest distance that knowledge can be transferred
- f( i) represents the energy of each part of the entity after transfer and f(i) ⁇ 0
- the total transferred energy in the entire formula should be 1
- R h represents the relationship set involved in the entity h in the triple set
- r represents a certain relationship h involved in the triple set
- n represents the number of relationships in the R h set.
- the knowledge graph model is a local adaptive knowledge graph model.
- N r ⁇ T r is an empty set, that is, all entities have a relationship with h or have no relationship with h at all, M ent is 0.
- T r is the empty set, then the model would be the local knowledge graph adaptive mapping knowledge model.
- M ent can show good characteristics under different ratios of entities and relationships such as 1-to-1, 1-to-N, N-to-1, and N-to-N.
- this algorithm uses the relationship-based edge parameters in the local adaptive knowledge graph model as the edge parameters of the relationship part, and the calculation is as follows:
- represents the distance from a given specific relationship to the relationship in the R h, r set, Represents the minimum difference between the given relationship and the relationship distance in R h,r .
- M opt is composed of M rel and M ent , so the values of M rel and M ent are brought into M opt , that is, formula (5) and formula (4) are brought into formula (6) to obtain the transfer relationship based
- the edge parameters M opt and M opt are calculated as follows:
- the obtained L is the loss function of the local adaptive knowledge graph based on the transfer relationship. Bring the loss function into the knowledge graph to obtain the corresponding local adaptive knowledge graph model based on knowledge transfer.
- the model can automatically adjust the edge parameters, which can not only complete the adaptive adjustment, but also reduce the complexity of building the model.
- This model optimizes and automatically adjusts edge parameters. All knowledge graph models require edge parameters to optimize the graph. Therefore, this model can be applied to knowledge graph models such as TransE, TransH, TransR, and TransD.
- Table 3 is a description of the data set of the embodiment of the present invention.
- WN and FB are shorthand for Wordnet and Freebase respectively, and they are both public data sets.
- WN11 and WN18 indicate that Wordnet contains 11 and 13 relationship types, respectively
- FB13 and FB15K indicate that Freebase contains 13 and 15K relationship types, respectively.
- Table 4 is a description of the software and hardware environment of the embodiment of the present invention.
- Table 5 shows the results of the link prediction experiment of the embodiment of the present invention.
- Link prediction refers to removing the head entity h or the tail entity t from a triple (h, r, t) and predicting the missing entity h or t. It can be seen that, given (h, r) to predict t, given (r, t) to predict h. Link prediction does not return a best result from the knowledge graph, but returns a series of alternative entity results.
- the present invention selects two data sets WN18 and FB15K from the public data set for experiments.
- the present invention uses a variety of methods for comparative experiments, including embedded translation-based knowledge graph models, such as TransE, TransH, TransR, and some energy-based knowledge graph models, such as SME, Unstructed and other methods.
- the edge parameter ⁇ is selected in ⁇ 1, 0.1, 0.01 ⁇
- the learning rate ⁇ of stochastic gradient descent is in ⁇ 1, 0.1, 0.01, 0.001 ⁇
- the dimension n of the low-dimensional space is within ⁇ 20, 50 ⁇
- the propagation distance d of knowledge is between ⁇ 1, 2, 3 ⁇
- the similarity function is the distance space between Euclidean distance L 1 and Manhattan distance L 2
- the energy loss function of propagation is between linear function and exponential Between function and logarithmic function.
- the propagation energy loss function is a logarithmic function
- L 1 is taken as the similarity measure distance
- the energy loss function of transmission is an exponential function
- L 2 is taken as the similarity measurement distance.
- Table 6 shows the results of the triple classification experiment of the embodiment of the present invention.
- triple classification is to predict whether a given triple (h, r, t) is the correct triple or the wrong triple. This is a binary classification problem. Since the data set does not publicly indicate which are the correct triples and which are the wrong triples, the method used by link prediction is used to construct the wrong triples.
- the specific classification method is to set a unique threshold ⁇ r for each relationship r. For a triple (h, r, t), if the similarity measure of fr (h, t) is less than the threshold, then the three Tuples are considered to be correct triples, otherwise they are wrong triples.
- the threshold ⁇ r is optimized by maximizing the result of the verification set.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Devices For Executing Special Programs (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提出一种基于传递关系的本地自适应知识图谱优化方法,包括:设定训练样本集;设定任意r i和e i初始属于某一分布;归一化;组成新的训练样本集;初始化三元组集合为空集;设定正确的三元组,其对应错误的三元组,用错误的三元组头实体或者尾实体替换正确的三元组,组成错误训练样本集,并且合并到三元组集合中;获得其实体的边缘参数;获得关系的边缘参数;计算边缘参数随实体和关系进行变化的参数;得到新的基于传递关系的损失函数;进行判断并使用随机梯度下降函数SGD对每个实体或者关系向量进行优化;本发明可以弥补数据的不完全性,并能够更好地表达出关系与实体间潜在的不同语义,优化后所构建的新的知识图谱具有更高的准确率。
Description
本发明属于知识管理和信息检索领域,具体涉及一种基于传递关系的本地自适应知识图谱优化方法。
知识图谱(Knowledge Graph)是一种大规模的结构化数据集合,它用于描述现实世界中各种存在的实体与概念,以及实体和实体、实体和概念以及概念和概念的联系,扩充知识结构,进而能够通过计算机来识别并进行分析处理。
知识图谱由三元组(h,r,t)组成(h、r、t分别表示头实体、关系、尾实体)。在目前的基于嵌入翻译的知识图谱中,主要方法是将实体与关系嵌入到同一个低维度空间中,或者是将实体和关系分别嵌入到不同的低维度空间中。这些方法都能极好地构建出知识图谱模型,并能获得良好的效果。其中有很多效果比较突出的方法,如TransE、TransH、TransR、TransA等。其中TransA模型根据知识图谱的实体和关系能够动态地决定损失函数中的参数,并从理论上证明了损失函数中的参数在知识图谱建模的本地化中的重要作用。但是就知识具有的传递性这一特点而言,现有的这些基于嵌入翻译的知识图谱模型大多没有对其予以考虑,即在构建三元组时,没有将三元组中的关系、实体等具有与其他三元组中的实体、关系的关联进行考虑或者深入分析。
知识是具有传递性的,我们可以举例进行说明。给出一系列三元组:(猫狮金鱼,属于,虎头金鱼),(虎头金鱼,属于,金鱼),(金鱼,属于,鱼),(鱼,属于,动物)。从这四个三元组中,我们可以提取到很多符合常理且符合生物学的新三元组,分别是(猫狮金鱼,属于,金鱼)、(猫狮金鱼,属于,鱼)、(猫狮金鱼,属于,动物)、(虎头金鱼,属于,鱼)、(虎头金鱼,属于,动物)、(金鱼,属于,动物)。这些三元组都是客观事实存在,但是并未显示出来。知识图谱的基本思想是:如果h+r与t相关,那么h+r≈t,即h+r与t越相关,h+r与t的距离越近,反之h+r与t的距离越远。所以在上述例子中“猫狮金鱼”+“属于”不仅仅应该与“虎头金鱼”的位置更相近,同时也应该与“金鱼”、“鱼”、“动物”等实体的距离更近。不能仅仅因为在三元组中没有这些内容,就将这些定义为不正确的三元组,从而将这些从推理方面符合客观事实且科学的内容相互远离。
虽然知识具有传递性,但如果不加限制地传递,却又是片面和不科学的。例如,我们也可以用三元组进行表示(人,像,猿)、(猿,像,猴)、(猴,像,猪)。这里的“像”可以视为知识图谱三元组数据中经常出现的“关系”。在这里,我们就不能也不敢获得类似于第一个例 子的三元组,例如(人,像,猪)这一类型的三元组。从常理上就可以看出,这类三元组就是错误的三元组。但是像(人,像,猴)这一类型的三元组确实可以在一定程度上能够让人接受,但又不是完全接受。这类三元组的定义模糊不清,既可以让人认为是对的,同时也可以让人认为是错的,没有明确的定义。但是,如果继续这样传递下去,一定可以认为是错的。
从上述的两个例子中,我们可以看出,一方面,知识确实具有传递性,因此由实体和关系构成的三元组也应该表达这种传递性;另一方面,三元组在传递的过程中,会发生失真现象或者某些关系不具有知识传递的能力,使得新获得的三元组变得面部全非。所以,在知识进行传递中,需要有一个度量标准,满足该标准才具有传递性。
发明内容
针对以上技术问题,本发明提出一种基于传递关系的本地自适应知识图谱优化方法,即TransAT,该方法将传递关系引入到前述的TransA模型中,形成新的知识图谱模型,即基于传递关系的本地自适应知识图谱模型TransAT。首先,针对知识图谱中的随机梯度下降算法以及本地自适应知识图谱模型进行扩充,所得到的随机梯度下降算法将替换后的实体根据与原实体的距离不同,采用不同的优化策略,得到不同的优化效果,从而获得新的知识图谱模型。然后,根据实体和关系的位置,结合知识的传递性,产生边缘参数,应用到损失函数中,进行模型优化,获得基于传递关系的本地自适应知识图谱。
一种基于传递关系的本地自适应知识图谱优化方法,具体步骤如下:
步骤1:设定训练样本集为S={(h
i,r
i,t
i)},h
i为一个头实体向量,t
i为一个尾实体向量,r
i为一个连接头实体和尾实体的关系向量,i=1,2,…,N,h
i∈E,t
i∈E,r
i∈R,其中,E为实体集,R为关系集,设定嵌入空间维度为n,知识能够传递的最远距离为d,约束因子为μ;
步骤2:设定任意r
i初始属于某一分布,并且r
i∈R;设定任意e
i初始属于某一分布,与r
i所属分布为同一分布或者为不同分布,并且e∈E,e为h或者t;
步骤3:归一化r
i,h
i,t
i,归一化公式分别为:
其中,||r
i||、||h
i||、||t
i||分别为r
i,h
i,t
i的一阶范数;
步骤4:从训练样本集中随机抽取样本大小为b的样本,组成新的训练样本集S
batch: S
batch=sample(S,b);其中,sample(S,b)表示在训练样本集S中随机抽取b个样本;
步骤5:初始化三元组集合为空集T
batch=Φ;
步骤6:基于归一化后的r
i,h
i,t
i,设定(h,r,t)∈S
batch为正确的三元组,其对应(h’,r,t’)属于错误的三元组,用错误的三元组头实体或者尾实体替换正确的三元组,组成错误训练样本集S′(h′,r,t′),并且合并到三元组集合T
batch中,得到合并后三元组集合T
batch=T
batch∪{(h′,r,t′),(h,r,t)};
步骤7:对于实体h或者t,获得其实体的边缘参数M
ent,公式如下:
其中,t∈P
r,t′∈N
r∪T
r,l∈T
r,t′∈N
r,σ(x)为求绝对值的函数,d表示知识能够传递的最远距离,f(i)表示传递后每部分实体具有的能量且f(i)≥0,并且整个公式中的传递总能量应该为1,所以
R
h代表实体h在三元组集合中涉及的关系集合,r表示h在三元组中涉及的某一个关系,n表示R
h集合中关系的个数,
表示获得正确实体和h的距离与错误实体和h的距离的差值,而
表示获得传递错误实体和h的距离与部分错误实体与h的距离的差值;
步骤8:对于关系r,获得关系的边缘参数M
rel,公式如下:
其中,R
h,r是一个关系集合,R
h,r={r
1,r
2,…,r
n},表示对于实体h除了关系r外,涉及到其他关系的集合,||r
i||-||r||表示给定的特定关系到R
h,r集合中的关系的距离,
表示给定的关系和R
h,r中的关系距离的最小差值,且当||r
i||≥||r||情况不存在、或者R
h,r为空时,M
rel=0;
步骤9:计算边缘参数随实体和关系进行变化的参数,公式如下:
M
opt=μM
ent+(1-μ)M
rel (6)
其中,M
ent表示实体的边缘参数,M
rel表示关系的边缘参数,参数μ控制M
ent和M
rel对M
opt所占的比例,且0≤μ≤1;
步骤10:将新获得的M
opt带入到损失函数中,得到新的基于传递关系的损失函数,即为:
L=∑
(h,l,t)∈S∑
(h′,l,t′)∈S′(M
opt+f
r(h,t)-f
r(h′,t′)) (7)
其中,f
r是基于关系r的距离函数,具体地,f
r(h,t)为h+r与t之间的距离函数,f
r(h′,t′)为h'+r与t'之间的距离函数;
步骤11:判断若M
opt+f
r(h,t)>f
r(h′,t′),输入三元组集合T
batch,使用随机梯度下降函数SGD对每个实体或者关系向量进行优化,得到优化后的E和R向量集合,即完成知识图谱优化,若判断M
opt+f
r(h,t)≤f
r(h′,t′),无需进行优化;
所述随机梯度下降函数SGD进行优化,公式如下:
其中,m表示实体或者关系,m′表示优化后的实体或者关系,λ表示随机梯度下降的学习速率,
表示对三元组h+r与t的相似度距离求导的结果,m
0与m分别表示知识传递的启发实体和传播收到的实体,t
r(m
0,d)表示对于关系r的基于知识传递的范围函数,且0<t
r(m
0,d)<1,d表示知识传播的距离,且d>0。
有益技术效果:
目前,在基于嵌入翻译的知识图谱中,主要方法是将实体与关系嵌入到同一个低维度空间中,或者是将实体和关系分别嵌入到不同的低维度空间中。这些方法都能极好地构建出知识图谱模型,并能获得良好的效果。但是,现有的知识图谱模型大多没有考虑到知识的传递性,即在构建三元组时,没有将三元组中的关系、实体等与其他三元组中的实体、关系的关联进行考虑或者深入地分析。本发明通过关系传递性的引入以及这种传递性在关系推演过程中的不断衰弱,可以在很大程度上弥补数据的不完全性,并能够更好地表达出关系与实体间潜在的不同语义,因此来得到更好地效果。
采用本发明的基于知识传递关系的本地自适应知识图谱优化方法,优化后所构建的新的知识图谱,即优化后的E和R向量集合链接预测和三元组分类方面具有更高的准确率。
图1为本发明实施例的种基于传递关系的本地自适应知识图谱优化方法流程图。
下面结合附图和具体实施实例对发明做进一步说明,一种基于传递关系的本地自适应知识图谱优化方法,如图1所示,具体步骤如下:
步骤1:设定:训练样本集为S={(h
i,r
i,t
i)},h
i为一个头实体向量,t
i为一个尾实体向量, r
i为一个连接头实体和尾实体的关系向量,i=1,2,…,N,h
i∈E,t
i∈E,r
i∈R,其中,E为实体集,R为关系集,设定嵌入空间维度为n,知识能够传递的最远距离为d,约束因子为μ;
步骤2:设定任意r
i初始属于某一分布,并且r
i∈R;设定任意e
i初始属于某一分布,r
i所属分布为同一分布或者为不同分布,并且e∈E,e为h或者t;
步骤3:归一化r
i,h
i,t
i,归一化公式分别为:
步骤4:从训练样本集中随机抽取样本大小为b的样本,组成新的训练样本集S
batch:S
batch=sample(S,b);其中,sample(S,b)表示在训练样本集S中随机抽取b个样本;
步骤5:初始化三元组集合为空集T
batch=Φ;
步骤6:基于归一化后的r
i,h
i,t
i,设定(h,r,t)∈S
batch为正确的三元组,其对应(h’,r,t’)属于错误的三元组,用错误的三元组头实体或者尾实体替换正确的三元组,组成错误训练样本集S′(h′,r,t′),并且合并到三元组集合T
batch中:T
batch=T
batch∪{(h′,r,t′),(h,r,t)};
步骤7:对于实体h或者t,获得其实体的边缘参数M
ent,公式如下:
其中,t∈P
r,t′∈N
r∪T
r,l∈T
r,t′∈N
r,σ(x)为求绝对值的函数,d表示知识能够传递的最远距离,f(i)表示传递后每部分实体具有的能量且f(i)≥0,并且整个公式中的传递总能量应该为1,所以
R
h代表实体h在三元组集合中涉及的关系集合,r表示h在三元组中涉及的某一个关系,n表示R
h集合中关系的个数,
表示获得正确实体和h的距离与错误实体和h的距离的差值,而
表示获得传递错误实体和h的距离与部分错误实体与h的距离的差值;
步骤8:对于关系r,获得关系的边缘参数M
rel,公式如下:
其中,R
h,r是一个关系集合,R
h,r={r
1,r
2,…,r
n},表示对于实体h除了关系r外,涉及到其他关系的集合,||r
i||-||r||表示给定的特定关系到R
h,r集合中的关系的距离,
表示给定的关系和R
h,r中的关系距离的最小差值,且当||r
i||≥||r||情况不存在、或者R
h,r为空时,M
rel=0;
步骤9:计算边缘参数随实体和关系进行变化的参数,公式如下:
M
opt=μM
ent+(1-μ)M
rel (6)
其中,M
ent表示实体的边缘参数,M
rel表示关系的边缘参数,参数μ控制M
ent和M
rel对M
opt所占的比例,且0≤μ≤1;
步骤10:将新获得的M
opt带入到损失函数中,得到新的基于传递关系的损失函数,即为:
L=∑
(h,l,t)∈S∑
(h′,l,t′)∈S′(M
opt+f
r(h,t)-f
r(h′,t′)) (7)
其中,f
r是基于关系r的距离函数,具体地,f
r(h,t)为h+r与t之间的距离函数,f
r(h′,t′)为h'+r与t'之间的距离函数;
步骤11:判断若M
opt+f
r(h,t)>f
r(h′,t′)),输入三元组集合T
batch,使用随机梯度下降函数SGD对每个实体或者关系向量进行优化,得到优化后的E和R向量集合,即完成知识图谱优化,若判断M
opt+f
r(h,t)≤f
r(h′,t′),无需进行优化;
所述随机梯度下降函数SGD进行优化,公式如下:
其中,m表示实体或者关系,m′表示优化后的实体或者关系,λ表示随机梯度下降的学习速率,
表示对三元组h+r与t的相似度距离求导的结果,m
0与m分别表示知识传递的启发实体和传播收到的实体,t
r(m
0,d)表示对于关系r的基于知识传递的范围函数,且0<t
r(m
0,d)<1,d表示知识传播的距离,且d>0。
下面给出TransAT算法的实施例,针对该算法编程即可实现基于知识传递关系的本地自适应知识图谱的优化,构建新的知识图谱,如表1所示,用伪代码实现:
表1:基于知识传递的本地自适应知识图谱模型
该算法中输入是三元组集合、实体集合、关系集合、实体和关系需要嵌入的低维度空间的维度、对于实体知识传播的距离以及边缘参数中对实体部分边缘参数和关系部分边缘参数的约束参数。这里的“三元组集合”可以从WordNet、Freebase等现有资源中获得。算法输出的 是基于传递关系的本地自适应知识图谱模型。第1、2行表示对关系的初始操作,对每个关系在低维度空间中随机赋予约束内一个位置,并且能够更好地处理,将关系进行归一化。第3行表示对所有实体嵌入到低维度空间向量中,并将位置随机分配在一个区域内。第4-18行表示对基于传递关系的自适应知识图谱模型进行循环优化,其中第5行表示对涉及到的实体,分别是头实体和尾实体进行归一化,第6行表示从三元组集合中选取一部分作为训练集。第7-11行表明将正确的三元组和错误的三元组进行集合,其中第9、10行表明替换正确三元组中的头实体或者尾实体,形成错误的三元组,第12-14行是通过公式(4)、公式(5)和公式(6)计算M
ent、M
rel、M
opt。第15-17行是对正确三元组和错误三元组涉及的参数进行优化,第15行是基于传递关系的本地自适应损失函数,判断是否对涉及的参数进行优化操作。第16行是对正确三元组中的h、t、r和错误三元组中的h′、t′、r进行随机梯度下降操作,所调用的随机梯度下降函数SGD描述如表2,用伪代码实现:
表2:基于传递关系的随机梯度下降
函数SGD的输入是:知识图谱中正确的三元组、错误的三元组、嵌入的低维度空间的维度、随机梯度下降算法的学习速率和知识的传播距离,然后获得对实体和关系处理后、在低维度嵌入空间中的位置。第1行显示错误三元组中换掉的实体与正确三元组中的原实体传播后的能量值。第2-11行显示对知识图谱模型中的实体与关系的循环优化,其中第3-6行显示正确三元组优化的结果,使用公式(8),第7-10行显示错误三元组在基于支持传播后的优化结果,使用公式(8)。其中,第3行和第7行分别表示对正确三元组中的差值和错误三元组中的差值进行求导。
以下是本发明算法的原理详细描述:
梯度下降算法是机器学习中作为模型优化的基本方法之一,该算法通过训练集中随机选取某个训练样本,在模型进行迭代求解过程中去计算梯度,并通过计算后的梯度对模型中的参数进行更新。随机梯度下降算法的主要思想是:在给定的训练样本集M中,随机选取其中N个样本作为新的训练样本集,去替代原训练样本集M,完成模型进行训练。在知识图谱中,随机梯度下降算法是对损失函数f进行参数优化。它是按照梯度反方向更新参数w直到函数收敛。算法为:
优化的随机梯度下降算法实现。这里的优化随机梯度下降算法实际上是将传递关系引入进来。具体地,设E是实体集合,R是关系集合,把任意一个三元组定义为(h
i,r
i,t
i)(i=1,2,…,n)。其中,h
i是一个头实体向量,t
i是一个尾实体向量,r
i是一个连接头实体和尾实体的关系向量。且h
i∈R
k和t
i∈R
k且r
i∈R
d,其中k可以等于d,也可以不等于d。R
k与R
d可以相同也可以不相同。h
i、t
i和r
i可以处于同一个嵌入空间R
k中,同样h
i、t
i可以处于R
k空间中,而r
i处于R
d空间中。△表示正确的三元组集合,即这个三元组在训练集合中出现,△′表示错误的三元组。
有多个三元组,分别是(h
1,r
1,t
1)、(t
1,r
1,h
2)、(h
2,r
1,t
2)。可以看出,h
1与h
2可能具有关系的关联性,而t
1与t
2同样可能具有关系的关联性。根据闭包原理中关系传递性原理,h
1与t
2同样可能具有关联性。由于关系本身含义的原因,知识的传递性可能会在传递时失真,无法确保其有效性。所以当传递距离越远时,越是应该减少其关联性,直到为0。因此,基于传递关系的随机梯度下降算法的主要思想是:由于不能完全确定传递的关系是否在传递时失 真,所以在进行对知识图谱模型进行优化时,当传递具有的能量越剧烈,即关系传播的距离越近,错误三元中相应变换的位置远离的梯度就越低;当关系传播的距离越远,传递的能量越低,错误三元中相应变换的位置远离的梯度就越高,直到变回到正常的梯度。
当出现具有传递关系的三元组,进行模型优化时应将错误的三元组梯度对应的梯度相应减少,传递关系越强烈,优化的梯度就应该越低。由此,基于传递关系的随机梯度下算法为:
其中,m表示实体或者关系,m′表示优化后的实体或者关系,λ表示随机梯度下降的学习速率,
表示三元组h+r与t的相似度距离的导数,m
0与m分别表示知识传递的启发实体和传播收到的实体,t
r(m
0,d)表示对于关系r的基于知识传递的范围函数,且0<t
r(m
0,d)<1。d表示知识传播的距离,为了将该模型与随机梯度下降算法作为区别,设置d>0。并且t
r(m
0,d)可以为线性函数、指数型函数或者对数型函数,根据具体情况做具体的选择。从公式(2)可以看出,当λ<t
r(m
0,d)时,则学习速率因子就会为正,即使三元组是错误三元组,同样会使得内容相互靠近。当λ>t
r(m
0,d)时,那么学习速率为负,此时的三元组是错误三元组,同样会使得内容相互远离。但是与原来相比,远离的距离会变小。t
r(m
0,d)是一种连续函数,随m
0和d变化而变化。当t
r(m
0,d)是线性函数时,说明随着传播距离的增大,梯度呈线性变化,前一个传递与后一个传递对于m来说,损失的程度相同;当t
r(m
0,d)是指数型函数时,说明随着传播距离的增大,梯度指数型变化,前一个传递与后一个传递对于m来说,传播能量在传递过程中能量损失呈指数型变化,即知识传递越远,新知识与m+r最初的含义越不相近,如(人,像,狗)这种出现错误三元组的可能性急速增加;当t
r(m
0,d)是对数型函数时,说明随着传播距离的增大,梯度呈对数型函数变化,最终会慢慢趋向一个平稳的梯度,前一个传递与后一个传递对于m来说,传播能量在传递过程中呈对数型变化,即知识越传递,新知识与m+r本身的内容虽越不相近,但是仍然有一定的关系,错误三元组出现的可能性增加,与上一个传播的知识相比,错误三元组出现的概率会缓慢增加。
基于传递关系的本地自适应知识图谱模型构建。主要目的是通过引入传递关系和自适应机制构建优化后的知识图谱。主要分为以下2部分:
1.基于传递关系的知识图谱模型构建。上述优化的随机梯度下降算法可以应用于其他基于嵌入翻译的知识图谱,即可以将优化函数应用到如TransE、TransH、TransD、TransR等知识图谱模型中去。对于TransE来说,优化函数就是对h+r与t计算距离后的随机梯度更新;对于TransH来说,优化函数就是h与t映射到r的超平面计算距离后的梯度更新;对于TransD、 TransR来说,就是h与t映射到r关系空间中计算距离后的梯度更新。当传播范围d=0时,结合后的TransE、TransH、TransD、TransR模型的优化函数就是随机梯度下降算法。
进而,将基于传递关系的随机梯度下降算法融入到现有的基于嵌入翻译的知识图谱的优化算法中,形成基于知识传递的知识图谱模型(TransT)。该模型在知识图谱进行优化时,充分考虑了三元组中传递性,也就是知识具有的传递性。当知识具有传递性时,相互远离的距离相应变小。
2.结合传递关系和自适应机制的知识图谱构建。知识图谱是将实体和关系嵌入到同一低维度或者不同低维度的向量空间中,通过最小化损失函数获得的值来进行知识图谱模型优化。
L=∑
(h,r,t)∈S∑
(h′,r,t′)∈S′(γ+f
r(h,t)+f
r(h′,t′)) (7)
损失函数是由正确三元组(h,r,t)、边缘参数γ与错误三元组(h′,r,t′)之间差值构成的。TransE、TransH、TransD等知识图谱模型都是通过模型训练得出边缘参数的值。因此,每个损失函数中边缘参数的值都会随着知识图谱模型的不同发生相应的改变。
本地自适应知识图谱模型证明了边缘参数在知识图谱中的重要性以及实体与关系对边缘参数的影响,但是它并没有考虑知识图谱中的关系间具有的传递性。本步骤将传递关系考虑到TransA中,形成新的知识图谱模型——基于传递关系的本地自适应知识图谱模型TransAT。
边缘参数随实体和关系进行改变,这里将其设为M
opt,其值为:
M
opt=μM
ent+(1-μ)M
rel (6)
其中,M
ent表示实体的边缘参数,M
rel表示关系的边缘参数,参数μ控制M
ent和M
rel对M
opt所占的比例,且0≤μ≤1。
对于某一个实体h和一个关系r,P
r={t|(h,r,t)∈△}被称作正确的实体,
被称为传播错误实体,其中对r而言,h到t之间可能存在多个三元组,
被称为部分错误实体。当知识图谱不考虑知识的传播性时,
此时的知识图谱模型即为本地自适应知识图谱模型TransA。边缘参数M
ent由正确的实体和错误实体的前两类共同组成。M
ent是为了将P
r向实体h靠近,而N
r和T
r远离h,其中T
r远离h一部分,而另一部分则被认为是正确实体,保持距离不动,而N
r则彻底远离h。M
ent的值是由正确实体、错误实体、传递实体的间距加权求和获得。那么在基于传递的知识图谱模型中M
ent的计算如下:
其中,t∈P
r,t′∈N
r∪T
r,l∈T
r,t′∈N
r,σ(x)为求绝对值的函数,d表示知识能够传递的最远距离,f(i)表示传递后每部分实体具有的能量且f(i)≥0,并且整个公式中的传递总能量应该为1,所以
R
h代表实体h在三元组集合中涉及的关系集合,r表示h在三元组中涉及的某一个关系,n表示R
h集合中关系的个数。
表示获得正确实体和h的距离与错误实体和h的距离的差值,而
表示获得传递错误实体和h的距离与部分错误实体与h的距离的差值。当T
r不为空,且在知识进行传递的距离不到d,知识就无法继续进行传递下去,此时就停止对知识传递的求和操作,不继续进行知识传递。当
的值较大时,M
ent的值主要取决于传递知识获得的边缘参数部分;而
的值较小时,M
ent的值主要取决于正确实体和错误实体获得的边缘参数部分;在特殊情况下,
为0时,M
ent的值完全取决于正确实体和错误实体获得的边缘参数部分,此时的知识图谱模型为本地自适应知识图谱模型。当N
r∪T
r为空集,即所有的实体都是与h有r的关系、或者与h完全没有关系时,M
ent为0。当T
r为空集时,此时的知识图谱模型就成为本地自适应知识图谱模型。
由于采用对实体具有关系的r进行统计运算,且实体包含头实体h和尾实体t两个部分,在进行训练时随机替换h和t其中的一个部分,剩下的一个实体通过公式(5)计算出其自身的M
ent,可以是头实体h的M
ent,也可以是尾实体t的M
ent,然后进行基于知识传递的本地自适应知识图模型构建。所以M
ent可以在1-to-1、1-to-N、N-to-1、N-to-N等实体与关系不同比例下均表现出良好的特性。通过对所有具有关联性的实体和关系进行循环求和运算,然后求出求和运算后的平均值,就得到了M
ent。
对于关系的边缘参数部分M
ent,由于其实体的数量与关系的数量相比,关系的数量差距太大,所以在进行知识传递时,关系能够在距离非常短的情况下传递到大多数其他关系。传播后的三元组会与传输的意义几乎完全不同,传播时损失的含义会变得非常多,所以考虑基 于知识的传播在关系上意义不大。基于此,本算法采用本地自适应知识图谱模型中基于关系的边缘参数作为关系部分的边缘参数,其计算如下:
其中,R
h,r是一个关系集合,R
h,r={r
1,r
2,…,r
n},表示对于实体h除了关系r外,涉及到其他关系的集合,||r
i||-||r||表示给定的特定关系到R
h,r集合中的关系的距离,
表示给定的关系和R
h,r中的关系距离的最小差值。且当||r
i||≥||r||情况不存在、或者R
h,r为空时,M
rel=0。
M
opt是由M
rel与M
ent共同组成,因此将M
rel与M
ent的值带入到M
opt,即将公式(5)、公式(4)带入公式(6)中,获得基于传递关系的边缘参数M
opt,M
opt的计算如下:
将新获得的M
opt带入到公式(3)中,得到新的基于传递关系的损失函数,即为:
L=∑
(h,l,t)∈S∑
(h′,l,t′)∈S′(M
opt+f
r(h,t)-f
r(h′,t′) (8)
得到的L即基于传递关系的本地自适应知识图谱的损失函数。将该损失函数带入知识图谱中,获得相应的基于知识传递的本地自适应知识图谱模型。当实体和关系改变时,该模型能够自动调整边缘参数,不仅能够完成自适应调整,同时能够减少构建模型的复杂度。该模型是对边缘参数进行优化自动调整,所有的知识图谱模型都需要边缘参数对图谱进行优化,因此可以将该模型应用到TransE、TransH、TransR、TransD等知识图谱模型中。
附表说明:
表3为本发明实施例的数据集描述。其中,WN和FB分别为Wordnet和Freebase的简写,它们都是公开的数据集。其中,WN11和WN18分别表示Wordnet中包含11和13个关系类型,FB13和FB15K分别表示Freebase中包含13和15K个关系类型。
表4为本发明实施例的软硬件环境描述。
表5为本发明实施例的链接预测实验结果。
链接预测是指对于一个三元组(h,r,t)去掉其中的头实体h或者尾实体t,预测缺失的实体h或者t。从中可以看出,给定(h,r)来预测t,给定(r,t)来预测h。链接预测并非从知识图谱中返回一个最好的结果,而是返回一系列备选的实体结果。本发明从公开数据集中选取WN18和FB15K这两个数据集进行实验。
在进行数据测试时,对于每个测试中的三元组(h,r,t),通过使用知识图谱中全部实验实体来分别替换(h,r,t)中的h和t,接着通过评分函数f
r计算(h,r)与t和(r,t)与h的距离。并通过获得的相似度距离对所有实体进行降序排序。对于知识图谱模型的评价标准采用平均排序和正确实体排在所有测试实体在前十名的概率(Hits@10)。通常,对于一个好的链接预测结果应该能够获得一个较低的平均排序的数值或者一个较高的Hits@10的数值。然而在进行测试排序时,实验认为的一个错误三元组也有可能存在于知识图谱中的测试三元组集合中。对于这些错误三元组,实验中也应该被认为是正确的三元组。然而在测试时,这些三元组获得非常高的排名,以至于会大幅度降低知识图谱模型的评价标准。因此为了避免上述情况,可以通过过滤出现在知识图谱中的错误三元组,得到真正匹配知识图谱模型的评价指标。本发明将第一种评估设置为“Raw”,第二这个评价设置为“Filter”。
本发明采用多种方法进行对比实验,其中包括基于嵌入翻译的知识图谱模型,例如TransE、TransH、TransR,以及一些基于能量的知识图谱模型,例如SME、Unstructed等方法。本实验选择边缘参数γ在{1,0.1,0.01}之中,随机梯度下降的学习速率λ在{1,0.1,0.01,0.001}之中,低维度空间的维度n在{20,50}之间,知识的传播距离d在{1,2,3}之间,相似度函数即距离空间在欧几里得距离L
1和曼哈顿距离L
2之间,传播的能量损失函数在线性函数、指数函数和对数函数之间。在WN18数据集中,n=20,λ=0.01,d=2,μ=0.6,传播的能量损失函数为对数函数,取L
1为相似性度量距离;在FB15K数据集中,n=50、λ=1、d=1、μ=0.5,传传播的能量损失函数为指数函数,取L
2为相似性度量距离。
从表5的实验结果可见,在两个数据集上,TransAT在平均排序方面均优于其他方法。而在Hits@10时,由于考虑到了知识的传递性,存在一些没有传递的知识却占据较好位置的实体,使得在进行排序时,不能获得前10的排名,使得在Hits@10测试集上,总体效果略差于TransA。
表6为本发明实施例的三元组分类实验结果。
三元组分类的目的是预测一个给定三元组(h,r,t)是正确三元组还是错误三元组。这是一个二元分类问题。由于数据集中没有公开表明哪些是正确三元组,哪些是错误三元组,因此采用链接预测使用的方法来构造错误三元组。具体的分类方法是为每一个关系r设置其特有的阈值δ
r,对于一个三元组(h,r,t),如果f
r(h,t)的相似性度量小于该阈值,则该三元组被 认为是正确三元组,否则为错误三元组。该阈值δ
r通过验证集最大化结果来优化。
在WN11数据集中,n=20,λ=0.1,d=2,μ=0.6传播的能量损失函数为对数函数,取L
1为相似性度量距离;在FB13数据集中,n=50、λ=0.1、d=1、μ=0.5,传播的能量损失函数为指数函数、取L
2为相似性度量距离。
从表6的实验结果可见,在WN11中,TransAT效果优于TransA,因为在此数据集中,知识传递有可靠的基础。而在FB13中则没有,因而在FB13中效果略差于TransA,并比其他方法相比,如NTN仍有一定的差距。
综合表5和表6的实验结果可见,在具有知识传递可靠基础的数据集中,本发明提出的基于传递关系的本地自适应知识图谱优化方法TransAT总体上占据优势。
表3 本发明实验采用的数据集描述
| 数据集 | 关系 | 实体 | 训练集 | 验证集 | 测试集 |
| WN11 | 11 | 38,696 | 112,581 | 2,609 | 10,544 |
| WN18 | 18 | 40943 | 141,442 | 5,000 | 5,000 |
| FB13 | 13 | 75,043 | 316,232 | 5,908 | 23,733 |
| FB15K | 1,345 | 14,951 | 483,142 | 50,000 | 59,071 |
表4 本发明实验的软硬件环境
表5 本发明链接预测的实验结果
表6 本发明三元组分类准确度实验结果(%)
| 数据集 | WN11 | FB13 |
| SE | 53.0 | 75.2 |
| SME(linear) | 70.0 | 63.7 |
| SLM | 69.9 | 85.3 |
| LFM | 73.8 | 84.3 |
| NTN | 70.4 | 87.1 |
| TransE | 75.9 | 81.5 |
| TransH | 78.8 | 83.3 |
| TransR | 85.9 | 82.5 |
| TransA | 93.2 | 82.8 |
| TransAT | 93.8 | 82.2 |
Claims (2)
- 一种基于传递关系的本地自适应知识图谱优化方法,其特征在于,所述基于传递关系的本地自适应知识图谱优化方法,具体步骤如下:步骤1:设定训练样本集为S={(h i,r i,t i)},h i为一个头实体向量,t i为一个尾实体向量,r i为一个连接头实体和尾实体的关系向量,i=1,2,…,N,h i∈E,t i∈E,r i∈R,其中,E为实体集,R为关系集,设定嵌入空间维度为n,知识能够传递的最远距离为d,约束因子为μ;步骤2:设定任意r i初始属于某一分布,并且r i∈R;设定任意e i初始属于某一分布,与r i所属分布为同一分布或者为不同分布,并且e∈E,e为h或者t;步骤3:归一化r i,h i,t i,归一化公式分别为:其中,||r i||、||h i||、||t i||分别为r i,h i,t i的一阶范数;步骤4:从训练样本集中随机抽取样本大小为b的样本,组成新的训练样本集S batch:S batch=sample(S,b);其中,sample(S,b)表示在训练样本集S中随机抽取b个样本;步骤5:初始化三元组集合为空集T batch=Φ;步骤6:基于归一化后的r i,h i,t i,设定(h,r,t)∈S batch为正确的三元组,其对应(h’,r,t’)属于错误的三元组,用错误的三元组头实体或者尾实体替换正确的三元组,组成错误训练样本集S′(h′,r,t′),并且合并到三元组集合T batch中,得到合并后三元组集合T batch=T batch∪{(h′,r,t′),(h,r,t)};步骤7:对于实体h或者t,获得其实体的边缘参数M ent,公式如下:其中,t∈P r,t′∈N r∪T r,l∈T r,t′∈N r,σ(x)为求绝对值的函数,d表示知识能够传递的最远距离,f(i)表示传递后每部分实体具有的能量且f(i)≥0,并且整个公式中的传递总能量应该 为1,所以 R h代表实体h在三元组集合中涉及的关系集合,r表示h在三元组中涉及的某一个关系,n表示R h集合中关系的个数, 表示获得正确实体和h的距离与错误实体和h的距离的差值,而 表示获得传递错误实体和h的距离与部分错误实体与h的距离的差值;步骤8:对于关系r,获得关系的边缘参数M rel,公式如下:其中,R h,r是一个关系集合,R h,r={r 1,r 2,…,r n},表示对于实体h除了关系r外,涉及到其他关系的集合,||r i||-||r||表示给定的特定关系到R h,r集合中的关系的距离, 表示给定的关系和R h,r中的关系距离的最小差值,且当||r i||≥||r||情况不存在、或者R h,r为空时,M rel=0;步骤9:计算边缘参数随实体和关系进行变化的参数,公式如下:M opt=μM ent+(1-μ)M rel (6)其中,M ent表示实体的边缘参数,M rel表示关系的边缘参数,参数μ控制M ent和M rel对M opt所占的比例,且0≤μ≤1;步骤10:将新获得的M opt带入到损失函数中,得到新的基于传递关系的损失函数,即为:L=∑ (h,l,t)∈S∑ (h′,l,t′)∈S′(M opt+f r(h,t)-f r(h′,t′)) (7)其中,f r是基于关系r的距离函数,具体地,f r(h,t)为h+r与t之间的距离函数,f r(h′,t′)为h'+r与t'之间的距离函数;步骤11:判断若M opt+f r(h,t)>f r(h′,t′),输入三元组集合T batch,使用随机梯度下降函数SGD对每个实体或者关系向量进行优化,得到优化后的E和R向量集合,即完成知识图谱优化,若判断M opt+f r(h,t)≤f r(h′,t′),无需进行优化。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910154252.2 | 2019-03-01 | ||
| CN201910154252.2A CN109840283B (zh) | 2019-03-01 | 2019-03-01 | 一种基于传递关系的本地自适应知识图谱优化方法 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020177142A1 true WO2020177142A1 (zh) | 2020-09-10 |
Family
ID=66885267
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/077728 Ceased WO2020177142A1 (zh) | 2019-03-01 | 2019-03-12 | 一种基于传递关系的本地自适应知识图谱优化方法 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109840283B (zh) |
| WO (1) | WO2020177142A1 (zh) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114691896A (zh) * | 2022-05-31 | 2022-07-01 | 浙江大学 | 一种知识图谱数据清洗方法及装置 |
| CN117035070A (zh) * | 2023-08-09 | 2023-11-10 | 国网福建省电力有限公司超高压分公司 | 一种知识图谱嵌入表示方法及装置 |
| CN117443564A (zh) * | 2023-10-27 | 2024-01-26 | 鞍钢集团矿业有限公司 | 一种基于知识图谱的磁选优化控制方法 |
| CN121579702A (zh) * | 2025-11-27 | 2026-02-27 | 高科创芯(北京)科技有限公司 | 一种基于知识图谱的跨平台业务系统集成方法 |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110704634B (zh) * | 2019-09-06 | 2023-08-01 | 平安科技(深圳)有限公司 | 知识图谱链接错误的查修方法、装置及存储介质 |
| CN110598006B (zh) * | 2019-09-17 | 2022-04-01 | 南京医渡云医学技术有限公司 | 模型的训练方法、三元组的嵌入方法、装置、介质及设备 |
| CN110909172B (zh) * | 2019-10-22 | 2022-08-16 | 中国船舶重工集团公司第七0九研究所 | 一种基于实体距离的知识表示学习方法 |
| CN111460155B (zh) * | 2020-03-31 | 2023-07-18 | 北京邮电大学 | 一种基于知识图谱的信息可信度评估方法及装置 |
| CN113486161A (zh) * | 2021-05-27 | 2021-10-08 | 中国电子科技集团公司电子科学研究院 | 基于特殊领域知识图谱的智能语义检索系统 |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105824802A (zh) * | 2016-03-31 | 2016-08-03 | 清华大学 | 一种获取知识图谱向量化表示的方法以及装置 |
| CN107391677A (zh) * | 2017-07-21 | 2017-11-24 | 深圳狗尾草智能科技有限公司 | 携带实体关系属性的中文通用知识图谱的生成方法及装置 |
| CN107784088A (zh) * | 2017-09-30 | 2018-03-09 | 杭州博世数据网络有限公司 | 基于知识点连接关系的知识图谱构建方法 |
| CN108446769A (zh) * | 2018-01-23 | 2018-08-24 | 深圳市阿西莫夫科技有限公司 | 知识图谱关系推理方法、装置、计算机设备和存储介质 |
| CN108959328A (zh) * | 2017-05-27 | 2018-12-07 | 株式会社理光 | 知识图谱的处理方法、装置及电子设备 |
| CN109063021A (zh) * | 2018-07-12 | 2018-12-21 | 浙江大学 | 一种能够编码关系语义多样性结构的知识图谱分布式表示方法 |
| US20190057310A1 (en) * | 2017-08-16 | 2019-02-21 | Royal Bank Of Canada | Expert knowledge platform |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105787105B (zh) * | 2016-03-21 | 2019-04-19 | 浙江大学 | 一种基于迭代模型的中文百科知识图谱分类体系构建方法 |
| CN108986871A (zh) * | 2018-08-27 | 2018-12-11 | 东北大学 | 一种智慧医疗知识图谱的构建方法 |
| CN109213872A (zh) * | 2018-09-11 | 2019-01-15 | 中国电子科技集团公司第二十八研究所 | 基于知识表示学习的实体关系预测方法及预测系统 |
-
2019
- 2019-03-01 CN CN201910154252.2A patent/CN109840283B/zh active Active
- 2019-03-12 WO PCT/CN2019/077728 patent/WO2020177142A1/zh not_active Ceased
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105824802A (zh) * | 2016-03-31 | 2016-08-03 | 清华大学 | 一种获取知识图谱向量化表示的方法以及装置 |
| CN108959328A (zh) * | 2017-05-27 | 2018-12-07 | 株式会社理光 | 知识图谱的处理方法、装置及电子设备 |
| CN107391677A (zh) * | 2017-07-21 | 2017-11-24 | 深圳狗尾草智能科技有限公司 | 携带实体关系属性的中文通用知识图谱的生成方法及装置 |
| US20190057310A1 (en) * | 2017-08-16 | 2019-02-21 | Royal Bank Of Canada | Expert knowledge platform |
| CN107784088A (zh) * | 2017-09-30 | 2018-03-09 | 杭州博世数据网络有限公司 | 基于知识点连接关系的知识图谱构建方法 |
| CN108446769A (zh) * | 2018-01-23 | 2018-08-24 | 深圳市阿西莫夫科技有限公司 | 知识图谱关系推理方法、装置、计算机设备和存储介质 |
| CN109063021A (zh) * | 2018-07-12 | 2018-12-21 | 浙江大学 | 一种能够编码关系语义多样性结构的知识图谱分布式表示方法 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114691896A (zh) * | 2022-05-31 | 2022-07-01 | 浙江大学 | 一种知识图谱数据清洗方法及装置 |
| CN117035070A (zh) * | 2023-08-09 | 2023-11-10 | 国网福建省电力有限公司超高压分公司 | 一种知识图谱嵌入表示方法及装置 |
| CN117443564A (zh) * | 2023-10-27 | 2024-01-26 | 鞍钢集团矿业有限公司 | 一种基于知识图谱的磁选优化控制方法 |
| CN121579702A (zh) * | 2025-11-27 | 2026-02-27 | 高科创芯(北京)科技有限公司 | 一种基于知识图谱的跨平台业务系统集成方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109840283B (zh) | 2020-09-01 |
| CN109840283A (zh) | 2019-06-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020177142A1 (zh) | 一种基于传递关系的本地自适应知识图谱优化方法 | |
| CN104915448B (zh) | 一种基于层次卷积网络的实体与段落链接方法 | |
| WO2020119030A1 (zh) | 用于答复问题的模型训练方法、装置、设备及存储介质 | |
| WO2021000745A1 (zh) | 一种知识图谱的嵌入表示方法及相关设备 | |
| WO2021189830A1 (zh) | 样本数据优化方法、装置、设备及存储介质 | |
| CN108197643B (zh) | 一种基于无监督聚类和度量学习的迁移学习方法 | |
| CN113128671B (zh) | 一种基于多模态机器学习的服务需求动态预测方法及系统 | |
| CN109299263B (zh) | 文本分类方法、电子设备 | |
| US12614096B2 (en) | Anomaly score normalisation based on extreme value theory | |
| CN115391509B (zh) | 模型训练、智能客服问题聚类方法及相关装置 | |
| WO2022095379A1 (zh) | 数据降维处理方法、装置、计算机设备及存储介质 | |
| CN110929028A (zh) | 一种日志分类方法及装置 | |
| CN114330584A (zh) | 数据聚类方法、装置、存储介质以及电子设备 | |
| US12361288B2 (en) | Method, device and medium for diagnosing and optimizing data analysis system | |
| CN114118088A (zh) | 基于超图卷积神经网络的文档级实体关系抽取方法及装置 | |
| CN109284378A (zh) | 一种面向知识图谱的关系分类方法 | |
| CN118377905A (zh) | 一种获取病历文本对应标签的数据处理系统 | |
| CN112069318B (zh) | 基于lda的母婴问题聚类分析方法、装置、计算机存储介质 | |
| WO2024078299A1 (zh) | 发明名称:特征提取模型处理及特征提取方法、装置和计算机设备 | |
| EP4421655A1 (en) | Co-training method for models, and related apparatus | |
| CN116450870B (zh) | 图像处理模型的处理方法、装置、设备和存储介质 | |
| CN108256030A (zh) | 一种基于本体的密度自适应概念语义相似度计算方法 | |
| CN113361283B (zh) | 面向Web表格的成对实体联合消歧方法 | |
| WO2026040300A1 (zh) | 模型间的特征向后兼容学习方法、电子设备及存储介质 | |
| CN114513374B (zh) | 一种基于人工智能的网络安全威胁识别方法及系统 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19917668 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19917668 Country of ref document: EP Kind code of ref document: A1 |









