Few-shot Knowledge Graph Representation Learning Method and System Based on Context Data Augmentation
By using a variational autoencoder in knowledge graph representation learning for context data enhancement, new triple samples are generated, which solves the problem of poor learning of knowledge graph representation in the case of few samples, and achieves better expression ability and knowledge reasoning performance.
Patent Information
- Application Number
- CN202211202263.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2042-09-29
AI Technical Summary
Existing knowledge graphs represent learning methods that perform poorly with few samples and cannot effectively learn and reason about missing information in the graph.
A variational autoencoder (VAE) method based on context data augmentation is adopted to learn the characteristics of head and tail entity pairs to generate a new triple-enlarge training set to improve the model's expression ability and knowledge inference performance in the case of few samples.
Extending the training sample set through data augmentation technology improves the accuracy and generalization ability of knowledge graph representation learning, especially under the condition of few samples, which significantly improves the performance of knowledge inference.
Smart Images

Figure CN115525771B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of knowledge graph representation learning and reasoning, and particularly relates to a few-shot knowledge graph representation learning method and system based on context data augmentation. Background Art
[0002] A knowledge graph is a data structure that reflects the relationships between entities in the real world through a graph and is one of the most popular knowledge storage structures currently. Current representative knowledge graphs include Freebase, YAGO, WordNet, etc. However, there is a common situation of data missing in these databases, which limits their effects in downstream applications such as intelligent search, recommendation systems, and intelligent question answering. Inspired by Word2VEC, knowledge graph representation learning uses vectors to reflect the structure of the knowledge graph and can effectively help complete and infer the missing information in the graph. Typical methods such as TransE, TransH, RotatE, ConvE, etc. mainly focus on the triple structure information of the knowledge graph and obtain vector representations of entities and relationships by constructing appropriate scoring functions in the vector space. The above-mentioned representation learning methods usually rely on the premise that there are sufficient entities and relationships in the graph. However, in reality, most knowledge graphs have a common long-tail distribution situation, that is, only a few relationships have sufficient triples, while most relationships have a limited number of triples, which is also called the few-shot situation, resulting in poor vector representation effects of existing representation learning models. In order to be able to learn reliable entity and relationship representations under the condition of limited samples, researchers have proposed the concept of few-shot knowledge representation learning. The existing few-shot knowledge representation learning methods can be roughly divided into two categories: meta-learning-based methods and metric-based methods. The former realizes the rapid learning and update of specific relationship representations through a relationship learner that can be shared in different reasoning tasks, and the latter mainly measures the similarity between the triples to be inferred and the known triples by designing neighbor node encoders and matching processors.
[0003] In the face of the situation of insufficient training sample quantity, the use of data augmentation technology can increase the sample quantity and thus improve the model performance. Data augmentation was initially mainly applied in the field of computer vision, expanding one picture into multiple pictures through methods such as rotation, translation, and scaling. Currently, the natural language processing field also attempts to increase the diversity of training data and improve the generalization ability of the model through data augmentation, such as data augmentation methods based on sampling like Variational auto encoder (VAE), etc. However, limited by the discreteness of natural language machine representations, the actual application difficulty is relatively large and it has not been widely applied in knowledge graph representation learning. Summary of the Invention
[0004] To this end, the present invention provides a few-shot knowledge graph representation learning method and system based on context data augmentation, which learns the features of head and tail entity pairs in the vector representation space through a variational autoencoder, decodes and generates new triples to augment the training set for auxiliary learning, and improves the expression ability and knowledge reasoning performance of the model in the few-shot case.
[0005] According to the design scheme provided by the present invention, a few-shot knowledge graph representation learning method based on context data augmentation is provided, which includes the following contents:
[0006] Select entities in the background knowledge graph, encode the context information of the neighbor nodes around the entities, and construct the representation of triple entity pairs;
[0007] Use the variational autoencoder VAE to learn the hidden features of the original entity pair representation from the probability distribution in the latent variable space, and decode and generate a new entity pair representation; regard the triple reasoning task as a sequence reasoning task, and encode the original entity pair representation and the new entity pair representation to obtain the few-shot relationship vector representation of the reasoning sequence;
[0008] Construct the triple entity pair to be inferred and its few-shot relationship representation according to the candidate entity pair, and use the pre-set similarity metric function to obtain the similarity score between the few-shot relationship vector representation of the reasoning sequence and the few-shot relationship representation of the triple entity pair to be inferred;
[0009] Construct negative samples for the training and optimization of the knowledge graph representation learning model, and use the variational autoencoder and the similarity score to construct a loss function, and optimize the few-shot relationship vector representation according to the loss function.
[0010] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, aggregate and encode the context information of the neighbor nodes around the entities in each entity pair to obtain the original entity pair representation, which includes the following contents: First, obtain the relationship representation through the pre-trained entity vector representation, and calculate the similarity between the relationship representation and the context relationships of each neighbor node; Then, use the similarity value as the weight for aggregating the context entity representation, and obtain the aggregated representation of the entity context information through the softmax function; Then, obtain the corresponding original entity pair representation based on the aggregated representation of the entity context information and the entity representation.
[0011] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, the calculation process of the similarity between the relationship representation and the context relationships of each neighbor node is expressed as: where r is the obtained relationship representation, and r = h - t, h and t are the pre-trained entity vector representations respectively, W is the transformation matrix, b is the bias, and r i is the context relationship of neighbor node i.
[0012] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, the original entity pair is represented as head and tail entities f(h) and f(t), where f(e) = σ(W 1 e + W 2 e aggr ), e is the entity representation of the head and tail entities themselves, e aggr is the aggregated representation of entity context information, W 1 and W 2 are two transformation matrices, and σ is the Sigmoid activation function.
[0013] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, use the variational autoencoder VAE to learn the hidden features of the original entity pair representation and decode to generate a new entity pair representation, which includes the following: First, for each original entity pair, use a fully connected network to extract the entity pair features, and map the entity pair features to a posterior probability distribution through the encoder; then, according to the posterior probability distribution, the decoder decodes and reconstructs the entity pair features to obtain a new entity pair representation, and controls the similarity degree between the input original entity pair representation and the output new entity pair representation through the penalty term and hyperparameters of the variational autoencoder VAE loss function.
[0014] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, when using the encoder to encode the original entity pair representation and the new entity pair representation, use Transformer as the encoder, regard the reasoning task of the entity pair of the triple to be inferred as a sequence prediction task, and combine the original entity pair representation and the new entity pair representation of the entity node to perform encoding processing through the Transformer encoder to obtain the few-shot relationship representation of the entity pair corresponding to the inference sequence.
[0015] As the few-shot knowledge graph representation learning method based on context data augmentation in the present invention, further, in constructing the similarity metric function, first, use the dot product method to calculate the similarity score between the few-shot relationship of the entity pair of the triple to be inferred and the few-shot relationship representation in the inference sequence, and calculate the attention weight in the attention distribution through the softmax function; then, use the similarity metric function φ(q r , s aggr ) to calculate the score of each candidate tail entity, where q r represents the few-shot relationship of the entity pair of the triple to be inferred, and s aggr represents the attention weight in the attention distribution.
[0016] As the few-shot knowledge graph representation learning method based on context data augmentation of the present invention, further, in the training and optimization of the knowledge graph representation learning model, the triple entity pairs of each relationship are regarded as a task. In each task, several triple entity pairs are selected from the triple entity pairs to be inferred to form a support set, and the remaining triple entity pairs constitute a query set. Negative samples are constructed by replacing the tail entities in the triple entity pairs in the query set.
[0017] As the few-shot knowledge graph representation learning method based on context data augmentation of the present invention, further, the loss function constructed by using the variational autoencoder and the similarity score is expressed as: Among them, represents the hinge loss part for optimizing the triple representation of negative samples, represents the loss part for optimizing the variational autoencoder, and λ represents the ratio adjustment parameter.
[0018] Further, the present invention also provides a few-shot knowledge graph representation learning system based on context data augmentation, including: an inference sequence construction module, a similarity acquisition module, and an optimization learning module. Among them,
[0019] The inference sequence construction module is used to encode by selecting the context information of the neighbor nodes around the entity pair in the background knowledge graph to construct the triple entity pair representation; and use the variational autoencoder VAE to learn the hidden features of the original entity pair representation constructed from the probability distribution in the latent variable space, and decode to generate a new entity pair representation of the candidate entity pair; regard the triple inference task as a sequence inference task, and obtain the few-shot relationship vector representation of the inference sequence by encoding the original entity pair representation and the new entity pair representation;
[0020] The similarity acquisition module is used to construct the triple entity pair to be inferred and its few-shot relationship representation according to the candidate entity pair, and use the pre-set similarity measurement function to obtain the similarity score between the few-shot relationship vector representation of the inference sequence and the few-shot relationship representation of the triple entity pair to be inferred;
[0021] The optimization learning module is used to construct negative samples for the training and optimization of the knowledge graph representation learning model, and use the variational autoencoder and the similarity score to construct a loss function, and optimize the few-shot relationship vector representation according to the loss function.
[0022] The beneficial effects of the present invention:
[0023] Considering that the specific relationships widely existing in knowledge graphs in reality have too low frequencies, and traditional knowledge graph representation learning methods cannot adapt to the few-shot situation, this invention adopts data augmentation to expand the training sample set while ensuring the quality of training samples, so as to better support knowledge graph representation learning and knowledge reasoning under few-shot conditions. When aggregating entity context and relationship context, the different roles of different information in different triple reasoning tasks are considered. By assigning weights during aggregation, the influence brought by noise and irrelevant information can be reduced, effectively improving the accuracy of the aggregated representation information, so that the knowledge graph representation learning has better semantic expression ability. Brief Description of the Drawings
[0024] Figure 1 It is a schematic diagram of the few-shot knowledge graph representation learning process in the embodiment;
[0025] Figure 2 It is a schematic illustration of the encoding of entity node context information in the embodiment;
[0026] Figure 3 It is a schematic illustration of data augmentation based on VAE in the embodiment;
[0027] Figure 4 It is a schematic illustration of the principle of the entity pair encoder based on Transformer in the embodiment;
[0028] Figure 5 It is a schematic illustration of the metric matching module based on multi-task aggregation in the embodiment. Detailed Embodiment
[0029] To make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the drawings and technical solutions.
[0030] Considering that knowledge graphs in reality often face the problem that the triple training samples are insufficient, which seriously affects the training effect and accuracy of traditional methods, the embodiments of the present invention, referring to Figure 1 as shown, provide a few-shot knowledge graph representation learning method based on context data augmentation, including:
[0031] S101. Select entities in the background knowledge graph, encode the context information of the neighbor nodes around the entities, and construct a triple entity pair representation;
[0032] S102. Use the variational autoencoder (VAE) to learn the hidden features of the constructed original entity pair representation from the probability distribution in the latent variable space, and decode to generate a new entity pair representation of the candidate entity pair; regard the triple reasoning task as a sequence reasoning task, and obtain the few-shot relationship vector representation of the reasoning sequence by encoding the original entity pair representation and the new entity pair representation;
[0033] S103. Construct the triple entity pairs to be inferred and their few-shot relation representations according to the candidate entity pairs, and use the pre-set similarity measurement function to obtain the similarity score between the few-shot relation vector representation of the inference sequence and the few-shot relation representation of the triple entity pairs to be inferred;
[0034] S104. Construct negative samples for training and optimizing the knowledge graph representation learning model, and use the variational autoencoder and the similarity score to construct a loss function, and optimize the few-shot relation vector representation according to the loss function.
[0035] The variational autoencoder is a common model for extracting latent sample features and generating samples, which has a high consistency with the purpose of few-shot representation learning in the knowledge graph. In the embodiments of this case, see Figure 2 As shown, the semantic information of the content described by the entity text is extended to the knowledge graph in the form of a text graph. At the same time, the variational autoencoder is used to learn the features of the head and tail entity pairs in the vector representation space, and decode and generate new triples to expand the training set to assist learning, so as to improve the expression ability of the model in the few-shot case and the knowledge reasoning performance, and meet the high accuracy and reliability requirements of the knowledge graph representation learning and reasoning methods in practical research and field applications.
[0036] As a preferred embodiment, further, aggregate and encode the context information of the neighbor nodes around the entities in each candidate entity pair to obtain the original entity pair representation, which includes the following content: First, obtain the relation representation through the pre-trained entity vector representation, and calculate the similarity between the relation representation and the context relations of each neighbor node; Then, use the similarity value as the weight for aggregating the context entity representation, and obtain the aggregated representation of the entity context information through the softmax function; Then, obtain the corresponding original entity pair representation based on the aggregated representation of the entity context information and the entity representation.
[0037] Encoding the context information of the neighbor nodes around the entity can capture the latent semantic and structural information of the entity while retaining the characteristics of the entity itself. In the case of limited training samples, these latent semantic and structural information can help the effective extraction of entity features, and thus assist in representation learning. At the same time, when performing different inference tasks, the context information of the neighbor nodes should also have different weights.
[0038] Measure the weight of the context entity through the correlation degree between the few-shot relation r and the entity context relation r i directly trained by traditional methods (such as TransE, etc.) to obtain r and r i, under few-shot conditions, due to the lack of sufficient triple samples with corresponding relationships, this relationship representation is often inaccurate. Entities appear relatively more frequently, and the obtained representations usually have higher reliability. Therefore, in the embodiments of this case, the relationship representation r = h - t can be obtained through the pre-trained entity vector representations h and t. Subsequently, the following formula is used to calculate the similarity between a specific few-shot relationship r and each context relationship r i :
[0039]
[0040] where W is a transformation matrix and b is a bias.
[0041] On the basis of calculating the similarity between all context relationships r i and r, the similarity value is used as the weight of the aggregated context entity representation e i , and the entity representations are added through the Softmax function to obtain the aggregated representation of the entity context information.
[0042]
[0043] To retain the features of the entity itself while aggregating the context information, the final representation of the entity consists of two parts, namely the representation e of the entity itself and the aggregated representation e aggr of the entity context information. Where W 1 and W 2 are two transformation matrices, σ is the Sigmoid activation function, and the head and tail entity representations can be denoted as f(h) and f(t) respectively.
[0044] f(e) = σ(W 1 e + W 2 e aggr )#(3)
[0045] As a preferred embodiment, further, a variational autoencoder VAE is used to learn the hidden features of the original entity pair representation and decode to generate a new entity pair representation, including the following content: First, for each original entity pair, a fully connected network is used to extract the entity pair features, and the entity pair features are mapped to a posterior probability distribution through an encoder; then, according to the posterior probability distribution, the decoder decodes and reconstructs the entity pair features to obtain a new entity pair representation, and the penalty term and hyperparameters of the VAE loss function of the variational autoencoder are used to control the similarity between the input original entity pair representation and the output new entity pair representation.
[0046] The variational autoencoder can learn latent attributes from the probability distribution in the latent variable space and construct new samples. VAE is used to learn the hidden layer features of the existing data and generate the representation of a new entity pair. See Figure 3The basic structure of the VAE model shown has an input of multiple sets of entity pair representations (f(h), f(t)) given by the node context information encoding module. For each (f(h), f(t)) i , first, a fully connected network consisting of two transformation matrices is used to extract entity pair features and compress the dimensions, i.e., P i = (W h f(h) + W t f(t)) i . Subsequently, the encoder part maps it to a posterior probability distribution p(z i |P i ), where z i is a vector representation of a hidden variable, i.e., a hidden feature. VAE assumes that this variational posterior distribution follows a multivariate normal distribution, i.e.:
[0047]
[0048] where μ i is the mean, is the covariance matrix;
[0049] The purpose of the VAE decoder is to decode and obtain the reconstructed sample representation P' i . VAE optimizes to make the P' i generated by the decoder as close as possible to the original input P i , thereby minimizing the reconstruction loss However, if only is in the loss function, the model will tend to generate samples exactly the same as the original samples, thus reducing the generalization ability of the model and restricting the application range. Therefore, VAE adds a term of Kullback-Leibler divergence as a penalty term in the loss function, making the model have a certain degree of randomness when generating samples. Through a set of hyperparameters λ 1 and λ 2 to control the proportion of the two parts in the loss function, and thus control the similarity between the samples generated by VAE and the original samples. After decoding and generating P' i through the VAE decoder, the new sample representation is also converted into a set of entity pair representations through a fully connected network consisting of two transformation matrices
[0050] f(h)' = W h 'P ' i #(5)
[0051] f(t)' = W t 'P' i #(6)
[0052] The loss function of VAE can be fully expressed as:
[0053]
[0054] As a preferred embodiment, further, in encoding the original entity pair representation and the new entity pair representation using an encoder, a Transformer is used as the encoder, and the inference task of the triple entity pair to be inferred is regarded as a sequence prediction task. The original entity pair representation and the new entity pair representation of the entity nodes are combined and encoded through the Transformer encoder to obtain the few-shot relationship representation of the entity pair corresponding to the inference sequence.
[0055] For the representations of multiple head and tail entity pairs in the original entity pair and the new entity pair, where k are obtained from the original training samples in the support set (the set of relationship triples obtained from the original knowledge graph), and q are the new entity pair representations obtained by using VAE data augmentation, these representations also contain features suitable for the inference task T r and can better assist in training the model.
[0056] The representation of the few-shot relationship r is obtained through the entity pair representation, and the general process is as Figure 4 shown. In some existing studies, the triple inference task is regarded as a sequence prediction task. In fact, for the few-shot task T r , when the head and tail entity pairs are known, the relationship between the two is inferred. Therefore, this task can also be regarded as a sequence inference task, that is, given the sequence X=(x 1 ,?, x 3 ), the process of inferring x 2 .
[0057] Transformer is one of the typical models for sequence inference. The [MASK] is used to mask the few-shot relationship r to be inferred, and the head and tail entities are respectively represented as:
[0058] x 1 =X 1 +X pos1 #(8)
[0059] x 3 =X 3 +X pos3 #(9)
[0060] where X i is the representation f(h)', f(t)' obtained after encoding the entity nodes in the support set through the context information f(h), f(t) or VAE data augmentation, and X posi is the position encoding. After the sequence is constructed, it is calculated through the Transformer, and the last hidden layer x 2The output of the position is the representation of the few-shot relation r generated by the entity pair, denoted as s, that is
[0061] s = Transformer((x 1 , [MASK], x 3 ))#(10)
[0062] As a preferred embodiment, further, in constructing the similarity metric function, first, the dot product method is used to calculate the similarity score between the few-shot relation of the entity pair of the triple to be inferred and the representation of the few-shot relation in the inference sequence, and the softmax function is used to calculate the attention weights in the attention distribution; then, the similarity metric function φ(q r , s aggr ) is used to calculate the score of each candidate tail entity, where q r represents the few-shot relation of the entity pair of the triple to be inferred, and s aggr represents the attention weights in the attention distribution.
[0063] Calculate the similarity between the few-shot relation representation of the triple to be inferred and the relation representation of the training samples, as the weight of the aggregated relation representation. Substitute the candidate tail entities into the triple to be inferred in turn, define a metric function to score all the constructed triples, and select the tail entity with the highest score as the inference result. The general process is as Figure 5 shown.
[0064] Based on the context information aggregation representation, obtain k few-shot relation representations in the support set, denoted as sup = {s 1 , …, s k}, obtain q enhanced few-shot relation representations based on VAE, denoted as sup VAE = {s 1 , …, s q}, at the same time, construct the entity pair of the triple to be inferred according to the candidate tail entity and obtain its few-shot relation representation, denoted as q r . Although the representations of sup and sup VAE both represent the few-shot relation r, even for the same r, it has different meanings under different triples. For example, for the same relation "subpartof", it can be used to describe that a mountain river is located in a certain geographical location, or it can be used to describe that a team is located in a certain league, and the semantics of the two are significantly different. Therefore, for different q r , the representations in sup and sup vAE should also have different importance.
[0065] Similar to the node context information encoding module, the dot product method is used to calculate the similarity score, that is:
[0066] δ(qr , s i ) = q r ·s i , s i ∈(sup ∩ sup VAE )#(11)
[0067] The attention is distributed through the Softmax function, i.e.:
[0068]
[0069] Define a similarity metric function φ(q i , s r , s aggr ) for evaluating the rationality, which can be implemented by methods such as dot product, cosine distance, or Euclidean distance. Calculate the scores of each candidate tail entity in turn using the defined metric function, and the one with the highest score is the result obtained by the model in this few-shot relation reasoning task.
[0070] As a preferred embodiment of the present invention, further, in the training and optimization of the knowledge graph representation learning model, the triple entity pairs of each relation are regarded as a task. In each task, several triple entity pairs are selected from the triple entity pairs to be inferred to form a support set, and the remaining triple entity pairs constitute a query set, and negative samples are constructed by replacing the tail entity in the triple entity pairs in the query set.
[0071] In the content of the knowledge graph representation learning model training and optimization algorithm, the parameters in the model can be initialized first, including the parameters of transformation matrix, bias, VAE, Transformer, etc.; the triple of each relation is regarded as a task, that is, the training set can be divided into a set of multiple tasks Learn and optimize the above parameters. According to the specific value of the training sample k in each task, for each task T in the training set r Select k triples to form a support set Support r , and the remaining triples constitute a query set Query r . For each triple in the query set, negative samples are constructed by replacing the tail entity, i.e. On this basis, the triple representation is optimized through the hinge loss function, i.e.:
[0072]
[0073] Combined with the loss function of the VAE module, the overall loss function can be shown as the following formula, where λ is a parameter for adjusting the proportion of the two parts.
[0074]
[0075] When training the model, optimizers such as Adam can be used to optimize the parameters, and L2 regularization is adopted to avoid overfitting of the model and improve the generalization ability of the model.
[0076]
[0077]
[0078] Furthermore, based on the above method, the embodiments of the present invention further provide a few-shot knowledge graph representation learning system based on context data augmentation, including: an inference sequence construction module, a similarity acquisition module, and an optimization learning module, where,
[0079] The inference sequence construction module is used to encode the context information of the neighbor nodes around the entity pair in the background knowledge graph to construct a triple entity pair representation; and use the variational autoencoder (VAE) to learn the hidden features of the constructed original entity pair representation from the probability distribution in the latent variable space, and decode to generate a new entity pair representation of the candidate entity pair; regard the triple inference task as a sequence inference task, and encode the original entity pair representation and the new entity pair representation to obtain a few-shot relationship vector representation of the inference sequence;
[0080] The similarity acquisition module is used to construct a triple entity pair to be inferred and its few-shot relationship representation according to the candidate entity pair, and use a pre-set similarity metric function to obtain the similarity score between the few-shot relationship vector representation of the inference sequence and the few-shot relationship representation of the triple entity pair to be inferred;
[0081] The optimization learning module is used to construct negative samples for the training and optimization of the knowledge graph representation learning model, and use the variational autoencoder and the similarity score to construct a loss function, and optimize the few-shot relationship vector representation according to the loss function.
[0082] Unless otherwise specifically stated, the relative steps, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0083] Based on the above system, the embodiments of the present invention further provide a server, including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the above system.
[0084] Based on the above system, the embodiments of the present invention further provide a computer-readable medium, on which a computer program is stored, where the program implements the above system when executed by a processor.
[0085] The device provided by the embodiments of the present invention has the same implementation principle and technical effects as those of the foregoing system embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding contents in the foregoing system embodiments.
[0086] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described system and device can refer to the corresponding processes in the foregoing system embodiments and will not be elaborated herein.
[0087] In all the examples shown and described here, any specific value should be construed as merely exemplary, not as a limitation. Therefore, other examples of the exemplary embodiments may have different values.
[0088] It should be noted that like reference numerals and letters denote like items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0089] The flowcharts and block diagrams in the figures illustrate the possible architectures, functions, and operations of systems, devices, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions denoted by the blocks may occur in a different order than that marked in the figures. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0090] In several embodiments provided in the present application, it should be understood that the disclosed system, device, and system can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0091] In addition, in each embodiment of the present invention, each functional unit can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0092] If the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the system described in each embodiment of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0093] Finally, it should be noted that the above-described embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, and are not intended to limit them. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions recorded in the foregoing embodiments or easily conceive of changes, or perform equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A few-shot knowledge graph representation learning method based on context data augmentation, characterized in that, it includes the following contents: Select entities in the background knowledge graph, encode the context information of the neighbor nodes around the entities, and construct a triple entity pair representation; For each original entity pair, use the variational autoencoder (VAE) to learn the entity pair features of the constructed original entity pair representation from the probability distribution in the latent variable space, and map the entity pair features to the posterior probability distribution; According to the posterior probability distribution, the decoder decodes and reconstructs the entity pair features to obtain a new entity pair representation, and controls the similarity between the input original entity pair representation and the output new entity pair representation through the penalty term and hyperparameters of the VAE loss function; Take the triple inference task as a sequence inference task, and encode the original entity pair representation and the new entity pair representation to obtain the few-shot relationship vector representation of the inference sequence; Construct the triple entity pair to be inferred and its few-shot relationship representation according to the candidate entity pair, and use the pre-set similarity metric function to obtain the similarity score between the few-shot relationship vector representation of the inference sequence and the few-shot relationship representation of the triple entity pair to be inferred; Construct negative samples for training and optimizing the knowledge graph representation learning model, and use the variational autoencoder and the similarity score to construct a loss function, and optimize the few-shot relationship vector representation according to the loss function.
2. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1, characterized in that, Aggregate and encode the context information of the neighbor nodes around the entities in each entity pair to obtain the original entity pair representation, including the following contents: First, obtain the relationship representation through the pre-trained entity vector representation, and calculate the similarity between the relationship representation and the context relationships of each neighbor node; Then, use the similarity value as the weight for aggregating the context entity representation, and obtain the aggregated representation of the entity context information through the softmax function; Then, obtain the corresponding original entity pair representation based on the aggregated representation of the entity context information and the entity representation.
3. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 2, characterized in that, The calculation process of the similarity between the relation representation and the context relations of each neighbor node is expressed as: where r is the obtained relation representation, and r = h - t, h and t are respectively the pre-trained entity vector representations, W is the transformation matrix, b is the bias, and r i is the context relation of neighbor node i.
4. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1 or 2, characterized in that, The original entity pair is represented as head and tail entities f(h) and f(t), where f(e) = σ(W 1 e + W 2 e aggr ), e is the entity representation of the head and tail entities themselves, and e aggr is the aggregated representation of the entity context information. W 1 and W 2 are two transformation matrices, and σ is the Sigmoid activation function.
5. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1, characterized in that, In encoding the original entity pair representation and the new entity pair representation using the encoder, use Transformer as the encoder, take the inference task of the triple entity pair to be inferred as a sequence prediction task, and combine the original entity pair representation and the new entity pair representation of the entity node to perform encoding processing through the Transformer encoder to obtain the few-shot relationship representation of the corresponding entity pair in the inference sequence.
6. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1, characterized in that, In constructing the similarity metric function, first, the dot product method is used to calculate the similarity score between the few-shot relation of the entity pair of the triple to be inferred and the few-shot relation representation in the inference sequence, and the softmax function is used to calculate the attention weights in the attention distribution; then, the similarity metric function φ(q r ,s aggr ) is used to calculate the score of each candidate tail entity, where q r represents the few-shot relation of the entity pair of the triple to be inferred, and s aggr represents the attention weights in the attention distribution.
7. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1, wherein, in the training and optimization of the knowledge graph representation learning model, the triple entity pairs of each relationship are regarded as a task. In each task, several triple entity pairs are selected from the triple entity pairs to be inferred to form a support set, and the remaining triple entity pairs constitute a query set. Negative samples are constructed by replacing the tail entities in the triple entity pairs in the query set.
8. The few-shot knowledge graph representation learning method based on context data augmentation according to claim 1 or 7, wherein, The loss function constructed using the variational autoencoder and similarity score is expressed as: where represents the hinge loss part for optimizing the triplet representation of negative samples, represents the loss part for optimizing the variational autoencoder, and λ represents the weight adjustment parameter.
9. A few-shot knowledge graph representation learning system based on context data augmentation, wherein, it includes: an inference sequence construction module, a similarity acquisition module, and an optimization learning module. Among them, the inference sequence construction module is used to encode by selecting the context information of the neighbor nodes around the entity pair in the background knowledge graph to construct the triple entity pair representation; and for each original entity pair, the variational autoencoder (VAE) is used to learn the entity pair features of the constructed original entity pair representation from the probability distribution in the latent variable space, and map the entity pair features to the posterior probability distribution; according to the posterior probability distribution, the decoder decodes and reconstructs the entity pair features to obtain a new entity pair representation, and controls the similarity degree between the input original entity pair representation and the output new entity pair representation through the penalty term and hyperparameters of the VAE loss function; regarding the triple inference task as a sequence inference task, encoding the original entity pair representation and the new entity pair representation to obtain the inference sequence few-shot relationship vector representation; the similarity acquisition module is used to construct the triple entity pair to be inferred and its few-shot relationship representation with the candidate entity pair, and use the pre-set similarity measurement function to obtain the similarity score between the inference sequence few-shot relationship vector representation and the triple entity pair to be inferred few-shot relationship representation; the optimization learning module is used to construct negative samples for the training and optimization of the knowledge graph representation learning model, and construct a loss function by using the variational autoencoder and the similarity score, and optimize the few-shot relationship vector representation according to the loss function.