Predicting Missing Links with Knowledge Graph Embeddings

Artificial intelligence relies heavily on knowledge graphs to structure human knowledge, yet these massive databases are notoriously incomplete. This article provides a clear overview of how Knowledge Graph Embedding (KGE) models address this issue through automated link prediction. By translating complex entities and relationships into low-dimensional mathematical vectors, algorithms like TransE, RotatE, and ComplEx can geometrically and algebraically infer missing connections. Below, we examine the specific mathematical mechanics of these three foundational models and how they successfully predict unseen relational links across incomplete datasets.

A knowledge graph stores information in the form of triples: (head, relation, tail), often abbreviated as (h, r, t). For example, (Paris, is_capital_of, France) is a single triple.

Real-world knowledge graphs contain millions of entities and billions of relations, making manual completion impossible. KGE models solve this by mapping every entity and relation into a continuous vector space. Once mapped, the model uses a scoring function to measure the plausibility of a potential triple. If a missing link is queried—such as (Paris, is_capital_of, ?)—the model tests candidate tail entities and ranks them by their mathematical scores to predict the most likely match.

TransE: Relations as Simple Translations

TransE (Translating Embeddings) is one of the earliest and most intuitive KGE models. It treats relationships as simple geometric translations in a vector space.

  • The Core Mechanism: TransE assumes that if a triple (h, r, t) holds true, the embedding of the tail entity t should be close to the embedding of the head entity h plus the relation vector r.
  • The Formula: h + r ≈ t
  • Scoring: The model calculates the distance between (h + r) and t. A smaller distance indicates a higher probability that the link exists.
  • Strengths and Limits: TransE is computationally efficient and excels at modeling 1-to-1 relationships. However, it struggles with complex patterns. For example, it cannot properly model symmetric relations (e.g., is_married_to, where h + r = t and t + r = h would force r to be zero) or 1-to-many relationships.

RotatE: Relations as Complex Rotations

To overcome the geometric limitations of TransE, RotatE maps entities and relations into a complex vector space (using both real and imaginary numbers) and defines relations as rotations rather than translations.

  • The Core Mechanism: Motivated by Euler's identity, RotatE treats the relation r as a rotation from the head entity h to the tail entity t in a complex plane.
  • The Formula: t ≈ h ∘ r (where ∘ denotes the Hadamard, or element-wise, product, and the modulus of each element in r is constrained to 1).
  • Strengths and Limits: By using rotation, RotatE can simultaneously model symmetry, antisymmetry, inversion, and composition. For instance, a symmetric relation is easily modeled as a 180-degree rotation; rotating twice brings you back to the starting entity. This allows RotatE to predict missing links in highly complex relational structures where TransE fails.

ComplEx: Capturing Asymmetry with Tensor Factorization

While TransE and RotatE are distance-based models, ComplEx is a semantic matching model. It uses tensor factorization in the complex space to measure the plausibility of a link based on latent semantics rather than geometric distance.

  • The Core Mechanism: Standard dot-product models fail at asymmetric relations (e.g., is_parent_of) because the dot product is commutative (h · t = t · h). ComplEx solves this by using complex vectors and incorporating the complex conjugate of the tail entity.
  • The Scoring Function: ComplEx calculates the score by taking the real part of the Hermitian dot product of h, r, and the conjugate of t.
  • Strengths and Limits: Because the product involves a complex conjugate, the operation is no longer commutative. The score for (h, r, t) becomes fundamentally different from (t, r, h). This enables ComplEx to accurately predict missing links in both symmetric and asymmetric relations while maintaining low computational complexity.

How the Prediction Pipeline Works

Regardless of the specific architecture, TransE, RotatE, and ComplEx follow the same fundamental pipeline to predict missing links in an incomplete database:

  1. Initialization: Entities and relations are assigned random vector values.
  2. Negative Sampling: Because databases only store true facts, the system generates false triples (negative samples) by corrupting true triples—such as replacing France with Germany in (Paris, is_capital_of, France).
  3. Training: The model is trained via gradient descent to maximize the plausibility scores of true triples and minimize the scores of negative samples.
  4. Inference: To find a missing link, the trained model substitutes every possible entity into the unknown position of an incomplete triple, calculates the score using its specific formula (TransE, RotatE, or ComplEx), and outputs the highest-scoring entity as the predicted link.