Link prediction is a core knowledge base completion (KBC) task that computes a probability score for a potential edge between a head and tail entity. It leverages the graph's existing topology and relation embeddings—such as those generated by TransE or graph neural networks (GNNs)—to determine if a missing or hypothetical triple represents a valid fact.
Glossary
Link Prediction

What is Link Prediction?
Link prediction is the machine learning task of estimating the likelihood that a relationship exists between two nodes in a graph, used to infer missing edges or forecast future connections.
The task is fundamental to knowledge graph population and recommender systems. By framing the problem as a scoring function over semantic triples, models can rank candidate relationships for triple classification. Advanced approaches use contrastive representation learning to ensure that valid connections receive higher scores than corrupted ones, enabling the discovery of latent relationships.
Key Characteristics of Link Prediction
Link prediction is the machine learning task of inferring the likelihood of a missing or future connection between two nodes in a graph. It is the core mechanism behind recommendation engines, knowledge base completion, and drug discovery.
Heuristic Scoring Methods
Classic approaches compute a similarity score between node pairs based on graph topology without learning. These methods serve as strong baselines.
- Common Neighbors: Counts shared neighbors between two nodes. A higher count suggests a higher probability of connection.
- Jaccard Coefficient: Normalizes common neighbors by the total number of unique neighbors, penalizing nodes with high degrees.
- Adamic-Adar Index: Weighs common neighbors inversely by their degree, giving more importance to rare shared connections.
- Preferential Attachment: Multiplies the degrees of the two nodes, based on the principle that popular nodes tend to connect to other popular nodes.
Knowledge Graph Embeddings
These models learn low-dimensional vector representations for entities and relations to score triples. They frame link prediction as a translation or tensor factorization problem.
- TransE: Models a relationship as a translation vector
h + r ≈ tin the embedding space. It is highly efficient but struggles with complex relation patterns like symmetry. - DistMult: Uses a bilinear diagonal tensor product. It captures symmetric relations well but cannot model asymmetric or inverse relations.
- ComplEx: Extends DistMult into the complex space, allowing it to model both symmetric and asymmetric relations by using the Hermitian dot product.
- RotatE: Defines each relation as a rotation in complex vector space, effectively modeling inversion and composition patterns.
Graph Neural Network Encoders
Instead of learning shallow embeddings, Graph Neural Networks (GNNs) generate node representations by aggregating information from a node's local neighborhood. This captures structural features that shallow methods miss.
- Graph Convolutional Networks (GCNs) apply a first-order approximation of spectral convolutions to aggregate neighbor features.
- GraphSAGE learns a function to sample and aggregate features from a node's local neighborhood, enabling inductive learning on unseen nodes.
- Graph Attention Networks (GATs) use a self-attention mechanism to assign different weights to different neighbors during aggregation, focusing on the most relevant connections.
- A standard GNN encoder for link prediction often uses a Siamese architecture to encode the head and tail nodes separately before scoring the pair.
Negative Sampling Strategies
Link prediction is often framed as a binary classification task. Since real graphs are sparse, generating high-quality negative samples (non-existent edges) is critical for training.
- Uniform Random Sampling: Randomly corrupts the head or tail entity of a true triple. This is fast but often generates easy negatives that don't help the model learn.
- Bernoulli Sampling: Replaces the head or tail entity with a probability based on the relation's mapping property (one-to-many, many-to-one) to reduce false negatives.
- Adversarial Sampling: Dynamically selects negative samples that the current model scores highly, forcing the model to learn from its hardest mistakes.
- Self-Adversarial Sampling: Weighs negative samples by their current model score during the loss calculation, avoiding the computational cost of full adversarial generation.
Decoder Scoring Functions
After encoding the source and target nodes, a decoder function computes the final likelihood score for the potential edge.
- Dot Product: Computes the inner product of the two node embeddings. Simple but effective for undirected graphs.
- DistMult Decoder: A bilinear diagonal product
<h, r, t>, whereris a relation-specific diagonal matrix. - ConvE: Uses a 2D convolutional layer over reshaped and concatenated embeddings, capturing rich feature interactions.
- InteractE: Improves upon ConvE by increasing the number of feature permutations and reshapes, capturing more heterogeneous interactions.
Evaluation Metrics
The performance of link prediction models is evaluated by ranking a true target entity against all other possible entities in the graph.
- Mean Reciprocal Rank (MRR): The average of the inverse of the rank assigned to the correct entity. It heavily penalizes low ranks.
- Hits@K (e.g., Hits@10): The fraction of test triples where the correct entity appears in the top K positions of the ranked list. This is the most common metric for knowledge base completion.
- Mean Rank (MR): The average rank of the correct entity. A lower value is better, but it is highly sensitive to outliers from a few very bad predictions.
- Evaluation is performed under a filtered setting, where all other known true triples are removed from the ranking list before calculating the rank to avoid penalizing the model for predicting other valid facts.
Link Prediction vs. Related Graph Tasks
Distinguishing link prediction from adjacent graph learning and knowledge base completion tasks.
| Feature | Link Prediction | Knowledge Base Completion | Triple Classification |
|---|---|---|---|
Primary Objective | Predict probability of an edge existing between two nodes | Infer and add entirely missing facts to an incomplete knowledge graph | Classify a given (h, r, t) triple as true or false |
Input Format | Graph structure (nodes, existing edges) and node features | Incomplete knowledge graph with existing triples | A single candidate triple (subject, predicate, object) |
Output | Ranked list of likely edges or a probability score | Set of new, high-confidence triples to add to the graph | Binary label (True/False) with confidence score |
Typical Models | TransE, RotatE, Graph Neural Networks (GCNs, GATs) | TransE, ComplEx, ConvE, HolE | BERT-based classifiers, KG-BERT, fine-tuned encoders |
Training Paradigm | Self-supervised via masking existing edges; negative sampling | Self-supervised via masking existing triples; negative sampling | Supervised binary classification on labeled triples |
Evaluation Metric | Mean Reciprocal Rank (MRR), Hits@K | Mean Reciprocal Rank (MRR), Hits@K | Accuracy, F1-Score, Area Under ROC Curve (AUC) |
Handles Unseen Entities | |||
Core Use Case | Recommender systems, drug-drug interaction prediction, social network analysis | Automated ontology population, knowledge graph curation | Fact verification, validating extracted relations against a knowledge base |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Clear, technical answers to the most common questions about the machine learning task of predicting missing or future relationships in graph-structured data.
Link prediction is the machine learning task of estimating the likelihood that a relationship (an edge) exists or will form between two nodes in a graph. It works by learning a scoring function $f(u, v)$ that quantifies the probability of a link between nodes $u$ and $v$. Heuristic methods compute this score based on local structural properties, such as the number of common neighbors or the Adamic-Adar index. Embedding-based methods, like TransE and RotatE, learn low-dimensional vector representations for each node and relation, defining the score via a geometric operation (e.g., translation distance). Graph Neural Network (GNN) methods, such as GraphSAGE and RGCN, generate node embeddings by aggregating features from multi-hop neighborhoods, capturing complex, non-linear structural patterns. The model is trained on positive edges from the graph and synthetically generated negative samples, optimizing a margin-based ranking loss or binary cross-entropy to rank true edges above false ones.
Related Terms
Link prediction is a core graph learning task that intersects with knowledge base completion, embedding models, and relation extraction. Explore these related concepts to build a complete understanding of the graph-based machine learning ecosystem.
Knowledge Base Completion (KBC)
The overarching task of inferring missing facts in a knowledge graph, often formulated as a link prediction problem. KBC systems predict whether a missing edge should exist between two existing nodes.
- Goal: Transform an incomplete graph into a denser, more useful one
- Common approach: Score all possible missing triples and select the highest-ranked ones
- Example: Predicting a person's nationality when the graph already contains their birthplace and employer
TransE
A foundational knowledge graph embedding model that represents relationships as translation vectors in a low-dimensional space. For a true triple (h, r, t), the embedding of the head entity plus the relation should approximately equal the embedding of the tail entity: h + r ≈ t.
- Scoring function: Negative L1 or L2 distance between h + r and t
- Strength: Simple, computationally efficient, and highly interpretable
- Limitation: Struggles with complex relation patterns like 1-to-N, N-to-1, and symmetric relations
Graph Neural Networks for RE
The application of graph neural networks to relation extraction, modeling entities and their surrounding context as a graph structure. GNNs capture inter-entity dependencies that sequential models miss.
- Architecture: Entities become nodes; syntactic dependencies become edges
- Key advantage: Message passing allows information to flow between related entity pairs
- Common variants: GCN, GAT, and R-GCN for multi-relational graphs
- Use case: Document-level RE where entities span multiple sentences
Relation Embedding
A low-dimensional vector representation of a semantic relationship, learned to capture its properties for downstream tasks like link prediction. Relation embeddings encode the latent semantics of how two entities connect.
- Properties captured: Transitivity, symmetry, compositionality
- Training: Often learned jointly with entity embeddings via contrastive objectives
- Example: The embedding for 'employed_by' should be close to the composition of 'works_at' and 'owned_by'
- Output: Used directly in scoring functions for triple plausibility
Triple Classification
A binary classification task that determines whether a given subject-predicate-object triple represents a true fact. Unlike ranking-based link prediction, triple classification provides a definitive yes/no decision.
- Input: A complete (head, relation, tail) triple
- Output: A confidence score thresholded to produce a binary label
- Evaluation metric: Accuracy, precision, recall, and F1 score
- Challenge: Requires both positive and high-quality negative examples for training
Joint Entity and Relation Extraction
A modeling paradigm that simultaneously identifies entities and their relationships in a single step rather than as a pipeline. This approach prevents error propagation where entity recognition mistakes cascade into relation extraction failures.
- Pipeline problem: If an entity is missed, its relationships are automatically lost
- Joint approach: Shared representations allow entity and relation signals to reinforce each other
- Architecture: Often uses span-based models or table-filling methods
- Benefit: Stronger performance on overlapping and nested entity-relation structures

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us