In representation learning, knowledge graph embedding (KGE), also called knowledge representation learning (KRL), or multi-relation learning, is a machine learning task of learning a low-dimensional representation of a knowledge graph's entities and relations while preserving their meaning. Leveraging their embedded representation, knowledge graphs can be used for various applications such as link prediction, triple classification, entity recognition, clustering, and relation extraction.
Definition A knowledge graph 𝒢={E,R,F} is a collection of entities E, relations R, and facts F. A fact is a triple (h,r,t)∈F that denotes a link r∈R between the head h∈E and the tail t∈E of the triple. Another notation that is often used in the literature to represent a triple (or fact) is ⟨head,relation,tail⟩. This notation is called the Resource Description Framework (RDF). A knowledge graph represents the knowledge related to a specific domain; leveraging this structured representation, it is possible to infer a piece of new knowledge from it after some refinement steps. However, nowadays, people have to deal with the sparsity of data and the computational inefficiency to use them in a real-world application. The embedding of a knowledge graph is a function that translates each entity and each relation into a vector of a given dimension d, called embedding dimension. It is even possible to embed the entities and relations with different dimensions. The embedding vectors can then be used for other tasks. A knowledge graph embedding is characterized by four aspects:
Representation space: The low-dimensional space in which the entities and relations are represented. Scoring function: A measure of the goodness of a triple-embedded representation. Encoding models: The modality in which the embedded representation of the entities and relations interact with each other. Additional information: Any additional information coming from the knowledge graph that can enrich the embedded representation. Usually, an ad hoc scoring function is integrated into the general scoring function for each additional piece of information.
Embedding procedure All algorithms for creating a knowledge graph embedding follow the same approach. First, the embedding vectors are initialized to random values. Then, they are iteratively optimized using a training set of triples. In each iteration, a batch of size b triples is sampled from the training set, and a triple from it is sampled and corrupted—i.e., a triple that does not represent a true fact in the knowledge graph. The corruption of a triple involves substituting the head or the tail (or both) of the triple with another entity that makes the fact false. The original triple and the corrupted triple are added in the training batch, and then the embeddings are updated, optimizing a scoring function. Iteration stops when a stop condition is reached. Usually, the stop condition depends on the overfitting of the training set. At the end, the learned embeddings should have extracted semantic meaning from the training triples and should correctly predict unseen true facts in the knowledge graph.
Pseudocode The following is the pseudocode for the general embedding procedure.
algorithm Compute entity and relation embeddings input: The training set S={(h,r,t)}, entity set E, relation set R, embedding dimension k output: Entity and relation embeddings
initialization: the entities e and relations r embeddings (vectors) are randomly initialized
while stop condition do Sbatch←sample(S,b) // Sample a batch from the training set for each (h,r,t) in Sbatch do (h′,r,t′)←sample(S′) // Sample a corrupted fact Tbatch←Tbatch∪{((h,r,t),(h′,r,t′))} end for Update embeddings by minimizing the loss function end while
Performance indicators These indexes are often used to measure the embedding quality of a model. The simplicity of the indexes makes them very suitable for evaluating the performance of an embedding algorithm even on a large scale. Given Q as the set of all ranked predictions of a model, it is possible to define three different performance indexes: Hits@K, MR, and MRR.
Hits@K Hits@K or in short, H@K, is a performance index that measures the probability to find the correct prediction in the first top K model predictions. Usually, it is used k=10. Hits@K reflects the accuracy of an embedding model to predict the relation between two given triples correctly. Hits@K=|{q∈Q:q<k}||Q|∈[0,1] Larger values mean better predictive performances.
Mean rank (MR) Mean rank is the average ranking position of the items predicted by the model among all the possible items. MR=1|Q|∑q∈Qq The smaller the value, the better the model.
Mean reciprocal rank (MRR) Mean reciprocal rank measures the number of triples predicted correctly. If the first predicted triple is correct, then 1 is added, if the second is correct 12 is summed, and so on. Mean reciprocal rank is generally used to quantify the effect of search algorithms. MRR=1|Q|∑q∈Q1q∈[0,1] The larger the index, the better the model.
Applications
Machine learning tasks Knowledge graph completion (KGC) is a collection of techniques to infer knowledge from an embedded knowledge graph representation. In particular, this technique completes a triple inferring the missing entity or relation. The corresponding sub-tasks are named link or entity prediction (i.e., guessing an entity from the embedding given the other entity of the triple and the relation), and relation prediction (i.e., forecasting the most plausible relation that connects two entities). Triple Classification is a binary classification problem. Given a triple, the trained model evaluates the plausibility of the triple using the embedding to determine if a triple is true or false. The decision is made with the model score function and a given threshold. Clustering is another application that leverages the embedded representation of a sparse knowledge graph to condense the representation of similar semantic entities close in a 2D space.
… excerpt ends here. Continue reading the full article.


![Knowledge graph embedding: Publication timeline of some KGE models. Red: tensor decomposition models; blue: geometric models; green: deep learning models. RESCAL[16] (2011) was the first modern KGE approach. In[17] it was applied to the YAGO knowledge graph. This was the first application of KGE to a large scale knowledge graph.](https://thumb.wikimedia.org/wikipedia/commons/thumb/2/2b/KG-Embedding.svg/500px-KG-Embedding.svg.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
