Search

Search papers and lessons

Modeling Relational Data with Graph Convolutional Networks

Michael Schlichtkrull, Thomas N. Kipf, Peter Bloem et al. · 2017

Schlichtkrull and colleagues extend graph convolutional networks to knowledge graphs with many relation types, and use them to fill in missing facts and missing entity labels.

On this page

  • Colour = topic mix
  • Discrete math
  • Linear algebra
  • Calculus
  • Neural network basics
  • Probability
  • Applied ML
  • ReadReady to readNot yet

TL;DR

A knowledge base stores facts as triples, such as (Mikhail Baryshnikov, educated at, Vaganova Academy), and even the largest ones are incomplete. Schlichtkrull and colleagues introduce the relational graph convolutional network (R-GCN), a graph encoder that keeps a separate transformation for each relation type, and they apply it to two tasks: predicting missing facts and predicting missing entity labels. Their key result is that an R-GCN encoder paired with the DistMult scoring function beats DistMult alone on the standard link prediction benchmarks, especially on the harder FB15k-237 dataset.

Builds on: Graph Convolutional Network, DistMult · Leads to: Knowledge Graph, Link Prediction

Why it mattered

Knowledge graphs power question answering and search, and their gaps matter for every system that reads from them. Before this paper, the usual way to fill those gaps was a factorisation model that scored each candidate fact on its own, using only learned vectors for the two entities and the relation. The paper showed that letting each entity's vector be shaped by its neighbourhood, with the neighbourhood kept separate by relation type, gives a stronger encoder for the same scoring function.

The paper claims to be the first to carry the graph convolution idea over to multi-relational data. The same encoder-decoder pattern, a graph network that produces node vectors and a simple scorer on top, became a common template for link prediction on graphs with many edge types. Its two regularisation schemes, basis decomposition and block decomposition, answer a practical problem that appears whenever a graph has many relation types: the parameter count grows with the number of relations, and rare relations overfit.

The problem

A knowledge base has entities, relations and triples. Each triple has a subject, a relation and an object. Two tasks matter in practice. In link prediction the question is whether a missing triple belongs to the graph, and the system ranks candidate triples by how likely they are. In entity classification the question is what type or category an entity has, such as whether a company is a company or a person is a person.

Both tasks depend on the neighbourhood. Knowing that a person was educated at a particular academy makes it likely that the person is a person and lived in the same country as the academy. A model that scores each fact in isolation throws this information away. A graph convolutional network can use it, but the standard version treats all edges the same, while a knowledge base has hundreds of relation types with different directions and meanings. The paper's question is how to keep the neighbourhood information and still handle that many relation types.

How it works

The model has two parts: an encoder that turns each entity into a vector by looking at its neighbours, and a decoder that scores candidate triples from those vectors. The diagram shows the pipeline for link prediction.

flowchart LR
  G[Incomplete knowledge graph] --> E[R-GCN encoder: one layer per hop, one matrix per relation]
  E --> V[Entity vectors]
  V --> D[DistMult decoder scores each candidate triple]
  D --> L[Loss: real triples up, corrupted triples down]

Here is a toy instance with three entities, invented for illustration, from start to finish. The graph has one fact in it, that Baryshnikov was educated at the Vaganova Academy, and the question is whether the same relation also holds for Russia.

  1. Input. The graph has entities B (Baryshnikov), V (Vaganova Academy) and R (Russia), and the relation educated at. The fact (B, educated at, V) is in the graph. The fact (B, educated at, R) is a candidate that the model must score. Check: the two candidates share the subject and the relation, so only the object differs.
  2. Encoder. One R-GCN layer updates each entity by summing messages from its neighbours. Each message is transformed by a matrix chosen for its relation and direction, and the sums are normalised. Because B has an educated at edge to V, V's vector flows into B's update through the educated at matrix. R has no such edge, so it receives nothing from V. Check: the neighbourhood of each entity changes its vector, but only through the relation-specific matrices.
  3. Entity vectors. Suppose the encoder ends with these two-number vectors: B is (1, 0), V is (1, 1), and R is (0, 1). These are toy values, chosen so the arithmetic is easy. Check: each entity now has one vector that the decoder can use.
  4. Decoder. DistMult scores a triple as the sum over the vector positions of the subject entry, times the relation weight, times the object entry. Take the relation weights for educated at to be (1, 2). The score for (B, educated at, V) is 1⋅1⋅1+0⋅2⋅1=11 \cdot 1 \cdot 1 + 0 \cdot 2 \cdot 1 = 1. The score for (B, educated at, R) is 1⋅1⋅0+0⋅2⋅1=01 \cdot 1 \cdot 0 + 0 \cdot 2 \cdot 1 = 0. Check: the true-looking candidate scores higher than the false-looking one.
  5. Loss. The paper trains with negative sampling. Each real triple is paired with corrupted copies in which the subject or object is replaced at random, and a logistic loss pushes real triples up and corrupted ones down. Check: after training, the scores of real triples are high relative to corrupted ones, which is what the ranking needs.

The main point of step 2 is that the encoder adds the neighbourhood to each entity's vector, and the decoder then needs only one simple score. The paper's experiments test whether that addition helps on real benchmarks.

The math

The paper's notation uses a directed, labelled multigraph G=(V,E,R)G = (\mathcal{V}, \mathcal{E}, \mathcal{R}), where V\mathcal{V} is the set of entities, E\mathcal{E} the set of labelled edges and R\mathcal{R} the set of relation types. The set R\mathcal{R} includes each relation in both directions, so an edge from j to i of relation r also appears as an inverse relation.

Step 2 in symbols: the R-GCN update

The layer update for entity ii at layer l+1l+1 is

hi(l+1)=σ(∑r∈R∑j∈Nir1ci,rWr(l)hj(l)+W0(l)hi(l))h_i^{(l+1)} = \sigma\left( \sum_{r \in \mathcal{R}} \sum_{j \in \mathcal{N}_i^r} \frac{1}{c_{i,r}} W_r^{(l)} h_j^{(l)} + W_0^{(l)} h_i^{(l)} \right)

Here hi(l)h_i^{(l)} is the vector for entity ii at layer ll, Nir\mathcal{N}_i^r is the set of neighbours of ii under relation rr, ci,rc_{i,r} is a normalisation constant (the paper gives ci,r=∣Nir∣c_{i,r} = |\mathcal{N}_i^r| as one choice), Wr(l)W_r^{(l)} is a matrix for relation rr, W0(l)W_0^{(l)} is a self-connection matrix, and σ\sigma is an activation such as ReLU. In the toy example, WrW_r for educated at is the matrix that transforms V's vector before it is added into B's.

Step 2 in symbols: keeping the parameter count small

With one matrix per relation, the layer has ∣R∣|\mathcal{R}| matrices, which becomes too many when there are hundreds of relations and rare ones have little data. The paper gives two fixes.

The basis decomposition writes each relation matrix as a weighted sum of BB shared matrices:

Wr(l)=∑b=1Barb(l)Vb(l)W_r^{(l)} = \sum_{b=1}^{B} a_{rb}^{(l)} V_b^{(l)}

Only the coefficients arba_{rb} depend on the relation, so rare relations share their matrices with common ones.

The block decomposition makes each relation matrix block-diagonal, with BB small blocks QbrQ_{br} on the diagonal, which the paper reads as a sparsity constraint.

Step 3 in symbols: the vectors and the classification loss

For entity classification, the last layer's output goes through a softmax, and the loss is the cross-entropy over the labelled entities:

L=−∑i∈Y∑k=1Ktikln⁡hik(L)\mathcal{L} = - \sum_{i \in \mathcal{Y}} \sum_{k=1}^{K} t_{ik} \ln h_{ik}^{(L)}

Here Y\mathcal{Y} is the set of labelled entities, KK is the number of classes, tikt_{ik} is 1 when entity ii has class kk and 0 otherwise, and hik(L)h_{ik}^{(L)} is the network's predicted probability for that class.

Step 4 in symbols: the DistMult score and the loss

DistMult gives each relation rr a diagonal matrix RrR_r, and scores a triple by

f(s,r,o)=esTRreof(s, r, o) = e_s^T R_r e_o

where ese_s and eoe_o are the encoder's vectors for the subject and the object. The toy example uses the same formula with RrR_r written as a list of two weights.

Training uses negative sampling. For each real triple, ω\omega corrupted triples are made by replacing the subject or the object, and the loss is the logistic cross-entropy on all of them:

L=−1(1+ω)∣E^∣∑(s,r,o,y)∈T[ylog⁡ℓ(f(s,r,o))+(1−y)log⁡(1−ℓ(f(s,r,o)))]\mathcal{L} = - \frac{1}{(1 + \omega)|\hat{\mathcal{E}}|} \sum_{(s,r,o,y) \in \mathcal{T}} \left[ y \log \ell(f(s,r,o)) + (1 - y) \log(1 - \ell(f(s,r,o))) \right]

Here ℓ\ell is the logistic sigmoid, y=1y = 1 for real triples and y=0y = 0 for corrupted ones, and T\mathcal{T} is the full set of real and corrupted triples.

Step 5 in symbols: the size saving

Take one layer with d=16d = 16 dimensions, ∣R∣=100|\mathcal{R}| = 100 relations and B=2B = 2 bases, and ignore the self-connection. Full relation matrices need ∣R∣d2=100⋅256=25,600|\mathcal{R}| d^2 = 100 \cdot 256 = 25{,}600 numbers. The basis version needs Bd2+∣R∣B=2⋅256+200=712B d^2 + |\mathcal{R}| B = 2 \cdot 256 + 200 = 712 numbers. That is about 36 times fewer.

Results

The paper reports entity classification on four knowledge-base datasets, with accuracy averaged over 10 runs. The R-GCN is best on two of the four: AIFB at 95.83 percent against 88.88 for RDF2Vec, and AM at 89.29 against 88.33. On MUTAG and BGS it is behind: 73.23 against 80.88 for Weisfeiler-Lehman kernels on MUTAG, and 83.10 against 87.24 for RDF2Vec on BGS. The authors suspect the fixed normalisation constant is partly to blame, since it can be particularly problematic for nodes of high degree.

For link prediction the paper uses mean reciprocal rank (MRR) and Hits at n. The filtered setting removes other true triples from the ranking. On FB15k, the filtered numbers are:

ModelMRR (filtered)Hits at 10
DistMult0.6340.814
R-GCN0.6510.825
R-GCN+ (ensemble with DistMult)0.6960.842

On WN18, the simple LinkFeat baseline reaches 0.938 filtered MRR, the same score HolE reports, and above R-GCN. The authors explain this by inverse relation pairs in the benchmark, which let a memorising baseline do well.

On FB15k-237, where the inverse pairs were removed, the gap is clearer. Filtered MRR is 0.248 for R-GCN and 0.191 for DistMult, and filtered Hits at 10 is 0.414 against 0.376.

Limits. The entity classification results are on small benchmark splits. The R-GCN in those experiments uses a fixed normalisation and no attention, which the authors name as the likely cause of the weak results on hub-heavy datasets. The link prediction gains are measured against the DistMult baseline, and the strongest results depend on an ensemble. The featureless setting uses one-hot inputs, so the paper does not show how the model performs when entities carry text or other features.

Reading guide

The paper has seven numbered sections, plus a supplement on the classification details. Each one needs these lessons.

Check yourself

QuestionIn the toy example, the score for (B, educated at, V) is 1 and for (B, educated at, R) it is 0. Why is the second score zero?Show answer
Because R's vector is (0, 1), and the subject B has the vector (1, 0). Their coordinatewise product is zero in both positions, since the first coordinate of R is 0 and the second coordinate of B is 0. The DistMult sum is therefore 0.
QuestionA model has 16-dimensional relation matrices, 100 relation types and two bases. How many numbers does the basis decomposition save, compared with full matrices, in one layer?Show answer
The full matrices need 100 times 256, which is 25,600 numbers. The basis version needs 2 times 256 plus 100 times 2, which is 712 numbers. The saving is 25,600 minus 712, which is 24,888 numbers.
QuestionWhy does the basis decomposition help with rare relations?Show answer
Only the coefficients depend on the relation, while the basis matrices are shared across all relations. A rare relation therefore learns a small set of coefficients, and its updates also move the shared matrices that common relations use, so it does not have to learn a full matrix from few examples.
QuestionOn WN18, LinkFeat beats the learned models. What does the paper say explains this, and what does it imply for the benchmark?Show answer
The paper says WN18 contains inverse triple pairs, where a fact in the training set has its reverse in the test set. A baseline that memorises such pairs does well without learning much about the graph, so the benchmark rewards memorisation. This is why the paper also reports FB15k-237, where the inverse pairs were removed.

Sources

Read the full paper

Michael Schlichtkrull, Thomas N. Kipf, Peter Bloem et al., 2017. arXiv:1703.06103