intermediate extraction-knowledge-graphs 35 min read

Knowledge-Graph Embeddings: TransE and RotatE

Relations as translations or rotations of entity space: which patterns each geometry satisfies exactly, what neither abelian group can represent, and what training on an incomplete knowledge base actually learns.

Overview & Motivation

The relation extraction topic read the filings of six companies its classifiers had never seen and returned 4545 facts with scores above one half, every one of them true. It also returned facts below the threshold. One of them, scored 0.4010.401, says that Granite Basin Midstream is a subsidiary of Northgate Energy. The extractor did find the other direction, Northgate Energy is the parent of Granite Basin Midstream, above the threshold. Anyone who knows what “parent” and “subsidiary” mean can fill in the missing fact. A knowledge-graph embedding is a way for a model to do the same: learn, from the facts it has, a geometry in which the missing fact is near the top.

The idea is the one the GloVe topic ended on. Its finance case study asked whether co-occurrence vectors make a relation a constant offset, Texas minus Houston equal to Massachusetts minus Boston, and found that no offset is constant. A knowledge-graph embedding stops hoping. It puts every entity at a point, makes every relation a map of the space, and trains the map to carry each fact’s head to its tail. TransE makes the map a translation, RotatE a rotation. Which relations each geometry can represent, and what training on an incomplete knowledge base actually teaches it, is the subject of this page. In order:

  1. Link prediction. How a model is asked about a missing fact, and how its answers are scored.
  2. Translation and rotation. What each geometry represents exactly: inverses, compositions, and symmetric relations.
  3. Relations as group actions. What any isometric model must collapse, and what no abelian one can represent.
  4. The bilinear foil. DistMult and ComplEx, and RotatE as ComplEx on the unit circle.

Then the finance case study: patterns held out from the finance knowledge base, where the most expressive model learns the wrong thing for an instructive reason, and the extracted facts about the held-out companies, completed.


The corpus’s knowledge base, WORLD, has 114114 entities (4848 people, 3737 organizations, 2323 places, 66 sectors), ten relations, and 254254 facts. It was built so that its relations have the shapes embedding models are judged by. COMPETES_WITH is symmetric: if AA competes with BB, BB competes with AA. PARENT_OF and SUBSIDIARY_OF are inverses. BASED_IN is the composition of HQ_IN and LOCATED_IN: a company headquartered in Houston, which is in Texas, is based in Texas. IN_SECTOR is many-to-one: up to seven companies share a sector.

Definition 1 (Knowledge graph and link prediction).

A knowledge graph over entities E\mathcal E and relations R\mathcal R is a set K⊆E×R×E\mathcal K \subseteq \mathcal E \times \mathcal R \times \mathcal E of triples (h,r,t)(h, r, t), read ”rr holds from head hh to tail tt”. A scoring function f:E×R×E→Rf : \mathcal E \times \mathcal R \times \mathcal E \to \mathbb R ranks triples. A tail query (h,r,?)(h, r, ?) ranks every t∈Et \in \mathcal E by f(h,r,t)f(h, r, t); a head query (?,r,t)(?, r, t) ranks every hh by f(h,r,t)f(h, r, t).

A held-out fact (h,r,t)(h, r, t) is tested twice, once as each query. The tail query (Halvorsen Industrial, PARENT_OF, ?) has two right answers, since Halvorsen has two subsidiaries in the knowledge base; ranking one of them second behind the other is not an error. Bordes et al. (2013) therefore drop the other known answers before ranking, the filtered setting.

Definition 2 (Filtered rank, MRR, and Hits@k).

For a test triple’s tail query with answer tt, the candidates are tt and every t′t' with (h,r,t′)(h, r, t') not a known fact. Let aa be the number of candidates scoring above tt and bb the number of other candidates tied with it. The filtered rank of tt is the realistic rank

1+a+b2,1 + a + \tfrac{b}{2},

the mean of the optimistic rank 1+a1 + a and the pessimistic rank 1+a+b1 + a + b, which is also the expected rank when ties are broken uniformly at random. Head queries are ranked the same way. Over the two queries of every test triple, the mean reciprocal rank (MRR) is the mean of 1/rank1/\text{rank}, and Hits@kk is the share of ranks at most kk.

MRR here is the formalRAG reciprocal rank with exactly one relevant item per query. The tie rule is Berrendorf et al.’s (2020). It matters more than it looks: Sun, Vashishth, Sanyal, Talukdar, and Yang (2020) found published models whose scores were inflated by ranking the true answer first among many tied candidates. Ties will matter on this page too, for a different reason.


Translation: TransE

Give each entity xx a vector ex∈Rd\mathbf e_x \in \mathbb R^d and each relation a vector wr\mathbf w_r. A fact is true when the head, moved by the relation, lands on the tail.

Definition 3 (TransE).

Entity vectors have unit length, ∥ex∥=1\lVert \mathbf e_x \rVert = 1, relation vectors are unconstrained, and

f(h,r,t)=−∥eh+wr−et∥.f(h, r, t) = -\lVert \mathbf e_h + \mathbf w_r - \mathbf e_t \rVert .

Bordes et al. train the margin loss ∑[γ+d(h,r,t)−d(h′,r,t′)]+\sum \big[\gamma + d(h, r, t) - d(h', r, t')\big]_+ over facts and their corruptions, where d=−fd = -f, a corruption replaces the head or the tail by another entity, and [x]+=max⁡(x,0)[x]_+ = \max(x, 0).

Translations handle two of the four patterns at once.

Proposition 1 (What translations represent exactly).

(a) If et=eh+w1\mathbf e_t = \mathbf e_h + \mathbf w_1 on every fact of r1r_1, then w2=−w1\mathbf w_2 = -\mathbf w_1 makes every reversed pair a fact of r2r_2 exactly. (b) If r1r_1 holds exactly from hh to mm and r2r_2 from mm to tt, then w3=w1+w2\mathbf w_3 = \mathbf w_1 + \mathbf w_2 holds exactly from hh to tt. (c) Both (h,r,t)(h, r, t) and (t,r,h)(t, r, h) hold exactly only if wr=0\mathbf w_r = 0 and eh=et\mathbf e_h = \mathbf e_t.

Proof.

(a) et−w1=eh\mathbf e_t - \mathbf w_1 = \mathbf e_h. (b) et=em+w2=eh+w1+w2\mathbf e_t = \mathbf e_m + \mathbf w_2 = \mathbf e_h + \mathbf w_1 + \mathbf w_2. (c) Adding et=eh+w\mathbf e_t = \mathbf e_h + \mathbf w and eh=et+w\mathbf e_h = \mathbf e_t + \mathbf w gives 2w=02\mathbf w = 0, so w=0\mathbf w = 0 and eh=et\mathbf e_h = \mathbf e_t.

∎

Wang, Zhang, Feng, and Chen (2014) made the point of (c), for what they called reflexive relations, as the motivation for TransH. A symmetric relation is a translation by zero, and every pair it relates is a single point. The Translate or rotate tab of the lab below shows it in the plane: two entities aa and b=−ab = -a, each related to the other. No translation brings the larger of the two residuals below ∣b−a∣=2\lvert b - a \rvert = 2, because the two residual vectors add up to twice the translation and subtract to twice b−ab - a.

The unit-length constraint in Definition 3 looks like a detail. It is not.

Proposition 2 (The norm constraint is load-bearing).

Multiply every entity and relation vector by s>0s \gt 0. If an embedding separates every fact from its corruptions, so that Δ=d(h′,r,t′)−d(h,r,t)>0\Delta = d(h', r, t') - d(h, r, t) \gt 0 for every pair, then the margin loss is nonincreasing in ss and equals 00 for every s≥γ/min⁡Δs \ge \gamma / \min \Delta, while no rank changes.

Proof.

Every distance scales by ss, so each term becomes [γ−sΔ]+[\gamma - s\Delta]_+, which is nonincreasing in ss and vanishes once sΔ≥γs\Delta \ge \gamma. Ranks compare distances, and multiplying all of them by the same ss preserves every comparison.

∎

Without the constraint, the loss rewards making the space bigger, not making it better. Bordes et al. give this reason in one clause for renormalizing the entity vectors at every step; the proposition makes it exact. The harness checks it on a small knowledge graph read off a random embedding, where scaling by γ/min⁡Δ\gamma/\min\Delta takes the loss to zero with every ranking unchanged. The models on this page all train with Sun et al.’s logistic loss instead (below), and TransE keeps the unit sphere.


Rotation: RotatE

A symmetric relation needs a map that undoes itself without being the identity. A translation cannot do that. A rotation by half a turn can.

Lemma 1 (Multiplying by a unit complex number rotates).

For real a,b,θa, b, \theta,

(a+ib)(cos⁡θ+isin⁡θ)=(acos⁡θ−bsin⁡θ)+i(asin⁡θ+bcos⁡θ),(a + ib)(\cos\theta + i\sin\theta) = (a\cos\theta - b\sin\theta) + i(a\sin\theta + b\cos\theta),

which is the rotation matrix (cos⁡θ−sin⁡θsin⁡θcos⁡θ)\begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} applied to (a,b)(a, b). Writing eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta: ∣zeiθ∣=∣z∣\lvert z e^{i\theta} \rvert = \lvert z \rvert, and eiαeiβ=ei(α+β)e^{i\alpha} e^{i\beta} = e^{i(\alpha + \beta)}.

Proof.

Expand the product with i2=−1i^2 = -1 and collect real and imaginary parts. A rotation matrix is orthogonal, so it preserves length. The product eiαeiβe^{i\alpha}e^{i\beta} expands to cos⁡αcos⁡β−sin⁡αsin⁡β+i(sin⁡αcos⁡β+cos⁡αsin⁡β)\cos\alpha\cos\beta - \sin\alpha\sin\beta + i(\sin\alpha\cos\beta + \cos\alpha\sin\beta), which the angle-addition formulas turn into cos⁡(α+β)+isin⁡(α+β)\cos(\alpha+\beta) + i\sin(\alpha+\beta).

∎

This is the unit-modulus case of the formalCalculus reading of a complex eigenvalue as a rotation and scaling of a real plane.

Definition 4 (RotatE).

Entities are vectors h,t∈Ck\mathbf h, \mathbf t \in \mathbb C^k. A relation is a vector r∈Ck\mathbf r \in \mathbb C^k of unit-modulus coordinates, ri=eiθir_i = e^{i\theta_i}, and

f(h,r,t)=γ−∥h∘r−t∥,f(h, r, t) = \gamma - \lVert \mathbf h \circ \mathbf r - \mathbf t \rVert ,

where ∘\circ multiplies coordinate by coordinate and γ\gamma is a fixed margin.

Each relation turns each complex coordinate of the head by its own angle. Sun, Deng, Nie, and Tang (2019) measure the distance as the sum of the coordinates’ moduli; we use the Euclidean norm, which Proposition 5 below needs. Their Lemmas 1–3 state that RotatE can infer symmetric, inverse, and composed relations. Here is the exact statement, with both directions.

Theorem 1 (Relation patterns are phase equations).

Let h\mathbf h have every coordinate nonzero.

(a) Both (h,r,t)(h, r, t) and (t,r,h)(t, r, h) hold exactly if and only if r∘r=1\mathbf r \circ \mathbf r = \mathbf 1, that is, θi∈{0,π}\theta_i \in \{0, \pi\} for every ii. Then t=h∘r\mathbf t = \mathbf h \circ \mathbf r differs from h\mathbf h on every coordinate with θi=π\theta_i = \pi.

(b) r2r_2 holds exactly on the reversal of every fact of r1r_1 if and only if r2=rˉ1\mathbf r_2 = \bar{\mathbf r}_1, that is, θ2=−θ1\theta_2 = -\theta_1.

(c) r3r_3 holds exactly across every path that takes r1r_1 and then r2r_2 if and only if r3=r1∘r2\mathbf r_3 = \mathbf r_1 \circ \mathbf r_2, that is, θ3≡θ1+θ2(mod2π)\theta_3 \equiv \theta_1 + \theta_2 \pmod{2\pi}.

Proof.

(a) If t=h∘r\mathbf t = \mathbf h \circ \mathbf r and h=t∘r\mathbf h = \mathbf t \circ \mathbf r, then h=h∘r∘r\mathbf h = \mathbf h \circ \mathbf r \circ \mathbf r, so hi(ri2−1)=0h_i (r_i^2 - 1) = 0, and hi≠0h_i \ne 0 gives ri2=1r_i^2 = 1, which for a unit complex number means ri=±1r_i = \pm 1. Conversely, if r∘r=1\mathbf r \circ \mathbf r = \mathbf 1 and t=h∘r\mathbf t = \mathbf h \circ \mathbf r, then t∘r=h\mathbf t \circ \mathbf r = \mathbf h. On a coordinate with ri=−1r_i = -1, ti=−hi≠hit_i = -h_i \ne h_i.

(b) With t=h∘r1\mathbf t = \mathbf h \circ \mathbf r_1, the reversed fact holds when t∘r2=h\mathbf t \circ \mathbf r_2 = \mathbf h, that is, h∘r1∘r2=h\mathbf h \circ \mathbf r_1 \circ \mathbf r_2 = \mathbf h, which for nonzero coordinates means r1∘r2=1\mathbf r_1 \circ \mathbf r_2 = \mathbf 1. For unit complex numbers the inverse is the conjugate.

(c) With m=h∘r1\mathbf m = \mathbf h \circ \mathbf r_1 and t=m∘r2=h∘(r1∘r2)\mathbf t = \mathbf m \circ \mathbf r_2 = \mathbf h \circ (\mathbf r_1 \circ \mathbf r_2), the triple (h,r3,t)(h, r_3, t) holds when h∘r3=h∘(r1∘r2)\mathbf h \circ \mathbf r_3 = \mathbf h \circ (\mathbf r_1 \circ \mathbf r_2), which for nonzero coordinates means r3=r1∘r2\mathbf r_3 = \mathbf r_1 \circ \mathbf r_2. By Lemma 1 the phases add.

∎

Part (a) is the point of rotation. A phase of π\pi turns a coordinate half way round, and twice that is the identity, so the pair stays apart: in the lab’s toy, rotating aa by 180°180° lands exactly on b=−ab = -a, and rotating bb lands back on aa.

Trained on the whole finance knowledge base, RotatE with k=16k = 16 complex coordinates solves the three equations almost exactly. The median distance of COMPETES_WITH’s sixteen phases from {0,π}\{0, \pi\} is 0.0000.000; the median of ∣θPARENT_OF+θSUBSIDIARY_OF∣\lvert \theta_{\text{PARENT\_OF}} + \theta_{\text{SUBSIDIARY\_OF}} \rvert is 0.0000.000; the median of ∣θBASED_IN−θHQ_IN−θLOCATED_IN∣\lvert \theta_{\text{BASED\_IN}} - \theta_{\text{HQ\_IN}} - \theta_{\text{LOCATED\_IN}} \rvert (wrapped to [−π,π)[-\pi, \pi)) is 0.0230.023. Random phases would give 0.7850.785, 1.5711.571, and 1.5711.571. Even the implication ACQUIRED ⇒\Rightarrow PARENT_OF shows: ACQUIRED holds on six of PARENT_OF’s thirteen pairs, and the two relations’ phases agree to a median of 0.0560.056. The Relation phases tab draws them on the unit circle.


Relations as group actions

Translations and rotations have more in common than either has with the other models. Both move the whole space rigidly, and both compose the way numbers add. That is enough to prove things about every such model at once.

Definition 5 (A relation model as a group action).

A group GG acts on entity space XX by isometries (maps preserving the distance dd). Each relation is an element gr∈Gg_r \in G, and

f(h,r,t)=γ−d(gr⋅eh,et).f(h, r, t) = \gamma - d(g_r \cdot \mathbf e_h, \mathbf e_t).

TransE is the translation group (Rd,+)(\mathbb R^d, +) acting by w⋅e=e+w\mathbf w \cdot \mathbf e = \mathbf e + \mathbf w. RotatE is the torus U(1)kU(1)^k, the vectors of unit complex numbers under coordinatewise multiplication, acting by r⋅h=h∘r\mathbf r \cdot \mathbf h = \mathbf h \circ \mathbf r. Both groups are abelian: gg′=g′gg g' = g' g.

Cai (2019) framed knowledge-graph embeddings this way, with a symmetric relation as an element of order two. A trained model never satisfies a fact exactly; the most one can say is that every fact of a relation sits within some distance ε\varepsilon. Isometry alone then forces three kinds of collapse.

Theorem 2 (Isometries collapse what they cannot separate).

Suppose every fact of rr satisfies d(greh,et)≤εd(g_r \mathbf e_h, \mathbf e_t) \le \varepsilon, and write g=grg = g_r.

(a) Two heads with a common tail satisfy d(eh,eh′)≤2εd(\mathbf e_h, \mathbf e_{h'}) \le 2\varepsilon, and two tails of a common head satisfy d(et,et′)≤2εd(\mathbf e_t, \mathbf e_{t'}) \le 2\varepsilon.

(b) If (h,r,t)(h, r, t) and (t,r,h)(t, r, h) are both facts, then d(g2eh,eh)≤2εd(g^2 \mathbf e_h, \mathbf e_h) \le 2\varepsilon. For TransE this says ∥wr∥≤ε\lVert \mathbf w_r \rVert \le \varepsilon and ∥eh−et∥≤2ε\lVert \mathbf e_h - \mathbf e_t \rVert \le 2\varepsilon.

(c) If entities x0,x1,…,xL−1x_0, x_1, \ldots, x_{L-1} form a cycle of odd length LL in which each consecutive pair (including xL−1,x0x_{L-1}, x_0) is related both ways, then consecutive entities satisfy d(exi,exi+1)≤2Lεd(\mathbf e_{x_i}, \mathbf e_{x_{i+1}}) \le 2L\varepsilon.

At ε=0\varepsilon = 0 each statement says the entities coincide.

Proof.

Every step uses that gg preserves distance, so d(gu,gv)=d(u,v)d(g\mathbf u, g\mathbf v) = d(\mathbf u, \mathbf v), and the triangle inequality.

(a) d(eh,eh′)=d(geh,geh′)≤d(geh,et)+d(et,geh′)≤2εd(\mathbf e_h, \mathbf e_{h'}) = d(g\mathbf e_h, g\mathbf e_{h'}) \le d(g\mathbf e_h, \mathbf e_t) + d(\mathbf e_t, g\mathbf e_{h'}) \le 2\varepsilon. For two tails, d(et,et′)≤d(et,geh)+d(geh,et′)d(\mathbf e_t, \mathbf e_{t'}) \le d(\mathbf e_t, g\mathbf e_h) + d(g\mathbf e_h, \mathbf e_{t'}).

(b) d(g2eh,eh)≤d(g2eh,get)+d(get,eh)=d(geh,et)+d(get,eh)≤2εd(g^2\mathbf e_h, \mathbf e_h) \le d(g^2\mathbf e_h, g\mathbf e_t) + d(g\mathbf e_t, \mathbf e_h) = d(g\mathbf e_h, \mathbf e_t) + d(g\mathbf e_t, \mathbf e_h) \le 2\varepsilon. For TransE, g2e=e+2wg^2\mathbf e = \mathbf e + 2\mathbf w, so ∥2w∥≤2ε\lVert 2\mathbf w \rVert \le 2\varepsilon, and ∥eh−et∥≤∥eh+w−et∥+∥w∥≤2ε\lVert \mathbf e_h - \mathbf e_t \rVert \le \lVert \mathbf e_h + \mathbf w - \mathbf e_t \rVert + \lVert \mathbf w \rVert \le 2\varepsilon.

(c) Write ei\mathbf e_i for exi\mathbf e_{x_i}, with indices mod LL. By induction on jj, d(gje0,ej)≤jεd(g^j\mathbf e_0, \mathbf e_j) \le j\varepsilon, since d(gj+1e0,ej+1)≤d(gj+1e0,gej)+d(gej,ej+1)=d(gje0,ej)+d(gej,ej+1)d(g^{j+1}\mathbf e_0, \mathbf e_{j+1}) \le d(g^{j+1}\mathbf e_0, g\mathbf e_j) + d(g\mathbf e_j, \mathbf e_{j+1}) = d(g^j\mathbf e_0, \mathbf e_j) + d(g\mathbf e_j, \mathbf e_{j+1}). Going all the way round, d(gLe0,e0)≤Lεd(g^L\mathbf e_0, \mathbf e_0) \le L\varepsilon. Write L=2m+1L = 2m + 1. By (b), d(g2e0,e0)≤2εd(g^2\mathbf e_0, \mathbf e_0) \le 2\varepsilon, so

d(g2me0,e0)≤∑j=0m−1d(g2j+2e0,g2je0)=m d(g2e0,e0)≤2mε.d(g^{2m}\mathbf e_0, \mathbf e_0) \le \sum_{j=0}^{m-1} d(g^{2j+2}\mathbf e_0, g^{2j}\mathbf e_0) = m\, d(g^2\mathbf e_0, \mathbf e_0) \le 2m\varepsilon .

Then d(ge0,e0)≤d(ge0,gLe0)+d(gLe0,e0)=d(e0,g2me0)+d(gLe0,e0)≤(2L−1)εd(g\mathbf e_0, \mathbf e_0) \le d(g\mathbf e_0, g^L\mathbf e_0) + d(g^L\mathbf e_0, \mathbf e_0) = d(\mathbf e_0, g^{2m}\mathbf e_0) + d(g^L\mathbf e_0, \mathbf e_0) \le (2L - 1)\varepsilon, and d(e0,e1)≤d(e0,ge0)+d(ge0,e1)≤2Lεd(\mathbf e_0, \mathbf e_1) \le d(\mathbf e_0, g\mathbf e_0) + d(g\mathbf e_0, \mathbf e_1) \le 2L\varepsilon. Relabeling the cycle gives every consecutive pair.

∎

Part (b) at ε=0\varepsilon = 0 says that gr2g_r^2 fixes eh\mathbf e_h. A nonzero translation fixes no point, so TransE needs gr2g_r^2 to be the identity, and (Rd,+)(\mathbb R^d, +) has no element of order two besides zero: that is Proposition 1(c) again. The torus U(1)kU(1)^k has 2k−12^k - 1 of them, the phase vectors in {0,π}k\{0, \pi\}^k other than zero, which is Theorem 1(a). Parts (a) and (c) are where rotation runs out. A rotation is an isometry, so RotatE collapses a many-to-one relation’s heads exactly as TransE does. And an odd cycle cannot alternate: on a coordinate with θi=π\theta_i = \pi the entities around a triangle would have to be u,−u,uu, -u, u, and the third must also equal −u-u, so u=0u = 0. “RotatE models symmetry” is exact only for a symmetric relation whose pairs are disjoint. The finance knowledge base’s COMPETES_WITH relation is not one: its companies have one, two, or three competitors (66, 1010, and 88 companies), and the competitor graph contains 88 triangles. The lab’s toy has a triangle too, and no angle zeroes its six residuals. The harness checks all three bounds on the trained full-KB TransE and RotatE, and part (c) on random odd cycles of lengths 33, 55, and 77.

Both groups are abelian, and that has a consequence of its own. In a family, a mother’s father and a father’s mother are different people (Yang, Sha, and Hong 2020 use the example). The smallest group in which order matters is S3S_3, the six permutations of three objects. Let aa swap the first two and bb cycle all three; then ab≠baab \ne ba.

Theorem 3 (Abelian models cannot tell ab from ba).

Make the Cayley graph of S3S_3 a knowledge graph: the six permutations are the entities, and relation AA takes xx to xaxa, relation BB takes xx to xbxb (1212 facts). If GG is abelian and every fact holds within ε\varepsilon, then for every xx the false triple (xa,B,xba)(xa, B, xba) satisfies

d(gBexa,exba)≤5ε.d(g_B \mathbf e_{xa}, \mathbf e_{xba}) \le 5\varepsilon .

So a model that keeps every corruption at distance at least γmin⁡\gamma_{\min} from its query has γmin⁡≤5ε\gamma_{\min} \le 5\varepsilon.

Proof.

The BB fact at xaxa gives d(gBexa,exab)≤εd(g_B\mathbf e_{xa}, \mathbf e_{xab}) \le \varepsilon, and by isometry d(gBexa,gBgAex)=d(exa,gAex)≤εd(g_B\mathbf e_{xa}, g_Bg_A\mathbf e_x) = d(\mathbf e_{xa}, g_A\mathbf e_x) \le \varepsilon (the AA fact at xx), so d(exab,gBgAex)≤2εd(\mathbf e_{xab}, g_Bg_A\mathbf e_x) \le 2\varepsilon. In the same way, from the BB fact at xx and the AA fact at xbxb, d(exba,gAgBex)≤2εd(\mathbf e_{xba}, g_Ag_B\mathbf e_x) \le 2\varepsilon. Since gAgB=gBgAg_Ag_B = g_Bg_A, d(exab,exba)≤4εd(\mathbf e_{xab}, \mathbf e_{xba}) \le 4\varepsilon, and d(gBexa,exba)≤d(gBexa,exab)+4ε≤5εd(g_B\mathbf e_{xa}, \mathbf e_{xba}) \le d(g_B\mathbf e_{xa}, \mathbf e_{xab}) + 4\varepsilon \le 5\varepsilon. The triple is false because BB takes xaxa only to xabxab, and xab≠xbaxab \ne xba because ab≠baab \ne ba.

∎

However the margin is set, an abelian model keeps some false triple within five times its worst true one. Trained on the twelve facts, the best ratio γmin⁡/ε\gamma_{\min}/\varepsilon TransE reaches is 1.0001.000 in the plane, by collapsing all six entities to one point so that every fact and every corruption sits at the length of its relation vector, 22; with 22 and 88 complex dimensions it reaches 0.8990.899 and 0.9070.907. RotatE reaches 0.5190.519, 0.9950.995, and 2.0412.041. Breaking the bound takes a group in which order matters.

Corollary 1 (A non-abelian action fits the graph exactly).

Let MM send each permutation of S3S_3 to the symmetry of an equilateral triangle that permutes its vertices the same way: transpositions become reflections and 3-cycles rotations by ±2π/3\pm 2\pi/3, so MM is an isomorphism onto the dihedral group D3⊂O(2)D_3 \subset O(2). For a point p\mathbf p on none of the triangle’s three mirror lines, the embedding ex=M(x−1)p\mathbf e_x = M(x^{-1})\mathbf p with gA=M(a)−1g_A = M(a)^{-1} and gB=M(b)−1g_B = M(b)^{-1} satisfies all twelve facts exactly, with six distinct entities.

Proof.

exg=M((xg)−1)p=M(g−1)M(x−1)p=M(g)−1ex\mathbf e_{xg} = M\big((xg)^{-1}\big)\mathbf p = M(g^{-1})M(x^{-1})\mathbf p = M(g)^{-1}\mathbf e_x for g∈{a,b}g \in \{a, b\}, which is the fact. Orthogonal matrices are isometries. The six points are distinct because the only element of D3D_3 that fixes p\mathbf p is the identity: each reflection fixes only its mirror line, and each nontrivial rotation only the center.

∎

With p=(0.9,0.3)\mathbf p = (0.9, 0.3) the twelve facts hold to 4⋅10−164 \cdot 10^{-16}, the nearest two entities are 0.6000.600 apart, and so is the nearest corruption: the ratio is unbounded. The Non-commuting tab draws the hexagon beside the trained abelian layouts. QuatE (Zhang et al. 2019), Rotate3D (Gao et al. 2020), and NagE (Yang, Sha, and Hong 2020) replace the torus with non-abelian rotation groups for exactly this reason.


The bilinear foil

A different family scores a triple by a product rather than a distance.

Definition 6 (DistMult and ComplEx).

DistMult (Yang et al. 2015) scores f(h,r,t)=⟨eh,wr,et⟩=∑ihiritif(h, r, t) = \langle \mathbf e_h, \mathbf w_r, \mathbf e_t \rangle = \sum_i h_i r_i t_i with real vectors. ComplEx (Trouillon et al. 2016) scores f(h,r,t)=Re∑ihiritˉif(h, r, t) = \mathrm{Re} \sum_i h_i r_i \bar t_i with complex vectors.

DistMult is a CP decomposition of the knowledge base’s 0/10/1 tensor (formalML: tensor decompositions, Definition 4) in which the head factor matrix and the tail factor matrix are the same matrix. That tie costs it every asymmetric relation.

Proposition 3 (DistMult is symmetric in every relation).

f(h,r,t)=f(t,r,h)f(h, r, t) = f(t, r, h) for every relation and every pair of entities. On every fact of an antisymmetric relation, DistMult ties the reversal.

Proof.

Multiplication of real numbers is commutative, so hiriti=tirihih_i r_i t_i = t_i r_i h_i for every ii.

∎

Kazemi and Poole (2018) state this in one sentence. ComplEx keeps the product and breaks the tie with a conjugate.

Proposition 4 (The antisymmetric part of ComplEx).

With zi=hitˉiz_i = h_i \bar t_i,

f(h,r,t)−f(t,r,h)=−2∑iIm ri  Im zi.f(h, r, t) - f(t, r, h) = -2 \sum_i \mathrm{Im}\, r_i \; \mathrm{Im}\, z_i .

So a ComplEx relation is symmetric for all entities if and only if every rir_i is real, and antisymmetric if and only if every rir_i is imaginary.

Proof.

f(t,r,h)=Re∑iritihˉi=Re∑irizˉif(t, r, h) = \mathrm{Re}\sum_i r_i t_i \bar h_i = \mathrm{Re}\sum_i r_i \bar z_i. For each ii, Re(rz)−Re(rzˉ)=Re(r(z−zˉ))=Re(2i r Im z)=−2 Im r Im z\mathrm{Re}(r z) - \mathrm{Re}(r \bar z) = \mathrm{Re}\big(r (z - \bar z)\big) = \mathrm{Re}(2i\, r\, \mathrm{Im}\, z) = -2\, \mathrm{Im}\, r\, \mathrm{Im}\, z, since z−zˉ=2i Im zz - \bar z = 2i\,\mathrm{Im}\, z and Re(ir)=−Im r\mathrm{Re}(i r) = -\mathrm{Im}\, r. The difference vanishes for all entities exactly when every Im ri=0\mathrm{Im}\, r_i = 0. The sum f(h,r,t)+f(t,r,h)=2∑iRe ri Re zif(h, r, t) + f(t, r, h) = 2\sum_i \mathrm{Re}\, r_i\, \mathrm{Re}\, z_i vanishes for all entities exactly when every Re ri=0\mathrm{Re}\, r_i = 0.

∎

The two families meet at the unit circle.

Proposition 5 (RotatE is ComplEx on the unit torus).

If every ∣ri∣=1\lvert r_i \rvert = 1, then

∥h∘r−t∥2=∥h∥2+∥t∥2−2 Re∑ihiritˉi.\lVert \mathbf h \circ \mathbf r - \mathbf t \rVert^2 = \lVert \mathbf h \rVert^2 + \lVert \mathbf t \rVert^2 - 2\, \mathrm{Re} \sum_i h_i r_i \bar t_i .
Proof.

For complex numbers, ∣u−v∣2=∣u∣2+∣v∣2−2 Re(uvˉ)\lvert u - v \rvert^2 = \lvert u \rvert^2 + \lvert v \rvert^2 - 2\,\mathrm{Re}(u \bar v). Apply it with u=hiriu = h_i r_i and v=tiv = t_i, use ∣hiri∣=∣hi∣\lvert h_i r_i \rvert = \lvert h_i \rvert (Lemma 1), and sum over ii.

∎

RotatE’s squared distance is ComplEx’s score with the relation pinned to the unit torus, minus a term for each entity’s length. Restricting the relation to unit modulus is what turns a product into an isometric action, with everything Theorems 2 and 3 say about one.

patternTransERotatEDistMultComplEx
symmetricby collapseθ∈{0,π}\theta \in \{0, \pi\}, disjoint pairsalwaysreal rr
antisymmetricyesyesnoyes
inverse−w-\mathbf wrˉ\bar{\mathbf r}only as symmetricrˉ\bar{\mathbf r}
compositionw1+w2\mathbf w_1 + \mathbf w_2r1∘r2\mathbf r_1 \circ \mathbf r_2nono
order-dependentnononono
many-to-oneby collapseby collapseyesyes

Read the table as exact satisfaction. Whether training finds these solutions is a separate question, and the case study answers it.


Finance case study

A relation as a map of the plane: does it carry each head onto its tail?
relation holds both ways on
map
ab
entityhead moved by the relationresidual to the tail
θθ = 90°
largest residual
1.414
a → b
1.414
b → a
1.414

With b = −a, rotating by 180° carries a to b and b back to a (Theorem 1(a)). A translation moves both the same way, so the two residuals add to twice the shift and subtract to twice b − a: the larger is never below |b − a| = 2 (Proposition 1(c)).


Where this sits

The relation extraction topic turned sentences into scored facts. This page turns facts into geometry and asks what the geometry can and cannot hold. Translations and rotations satisfy inverses and compositions exactly, and rotations also satisfy symmetric relations, but only when their pairs are disjoint (Theorems 1 and 2). Both are actions of abelian groups by isometries, which collapses many-to-one relations and odd symmetric cycles and makes order-dependent composition impossible (Theorems 2 and 3), while the symmetries of a triangle fit what neither can (Corollary 1). DistMult is symmetric by construction, and RotatE is ComplEx with unit-modulus relations (Propositions 3–5). The capstone runs the whole thread on earnings-call text: tokenize, classify tone, extract entities and relations, and embed the knowledge base this page completes.


Honest caveats


Implementation

The companion notebook (notebookPath) imports the topic’s Python module, which owns every number on this page. It imports the relation extraction topic’s module for its rules and its extracted knowledge base, and through it the finance corpus and its knowledge base. All four models are written in NumPy with one backward pass: every query becomes a point, scored against every entity by a distance or an inner product. Its harness checks:

  • every gradient against central differences, and Definition 2’s rank against brute force;
  • Propositions 1 and 2, Lemma 1, and Theorem 1 on exact constructions, and Theorem 1 on the trained phases, full and with facts hidden;
  • Theorem 2’s three bounds on the trained models, Theorem 3 on random and trained abelian embeddings, and Corollary 1’s exact fit;
  • Propositions 3–5 on random draws, and every comparison this page states.

The laboratory reads its data from a JSON file that one of the harness’s tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.

Connections

  • Every model here trains like skip-gram with negative sampling, a logistic loss on true pairs against corrupted ones; with every corruption scored, it is that topic's expected negative-sampling objective computed exactly. word2vec-implicit-factorization

References & Further Reading

  • paper Translating Embeddings for Modeling Multi-relational Data — Antoine Bordes, Nicolas Usunier, Alberto Garcia-Duran, Jason Weston, and Oksana Yakhnenko (2013) Advances in Neural Information Processing Systems 26, 2787–95. TransE. Section 2, Eq. 1: the margin loss over corrupted heads or tails; entity embeddings renormalized to unit L2 norm every iteration, since otherwise training could minimize the loss by inflating their norms; Section 4.2: the raw and filtered settings; Section 4.3: relations sorted into 1-to-1, 1-to-many, many-to-1, and many-to-many at an average of 1.5
  • paper RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space — Zhiqing Sun, Zhi-Hong Deng, Jian-Yun Nie, and Jian Tang (2019) ICLR 2019. Definitions 1–3 (the patterns); Lemmas 1–3 state that RotatE can infer symmetry, inversion, and composition, proved in one direction in Appendices B–D; Eq. 3 and footnote 2: the distance is an L1 norm over complex moduli; Eqs. 4–6: the logistic loss with a fixed margin and self-adversarial weights; Table 2: which models support which patterns
  • paper Embedding Entities and Relations for Learning and Inference in Knowledge Bases — Bishan Yang, Wen-tau Yih, Xiaodong He, Jianfeng Gao, and Li Deng (2015) ICLR 2015. Section 3.2: the bilinear score with a diagonal relation matrix (DistMult)
  • paper Complex Embeddings for Simple Link Prediction — Théo Trouillon, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume Bouchard (2016) Proceedings of ICML 2016, PMLR 48: 2071–80. ComplEx, Eq. 9: the real part of a trilinear product with the object conjugated
  • paper Knowledge Graph Completion via Complex Tensor Factorization — Théo Trouillon, Christopher R. Dance, Éric Gaussier, Johannes Welbl, Sebastian Riedel, and Guillaume Bouchard (2017) Journal of Machine Learning Research 18, no. 130: 1–38. Theorem 2 and Corollary 1: every real square matrix is the real part of a normal one, E W E* with E unitary and W diagonal; Corollary 3: a sign-rank bound on the dimension; Theorem 4: the multi-relational version
  • paper Knowledge Graph Embedding by Translating on Hyperplanes — Zhen Wang, Jianwen Zhang, Jianlin Feng, and Zheng Chen (2014) Proceedings of AAAI 2014, 1112–19. TransH. TransE's flaws on reflexive (in today's terms, symmetric), one-to-many, many-to-one, and many-to-many relations: a reflexive relation forces r = 0 and h = t, and a many-to-one relation forces its heads to coincide
  • paper SimplE Embedding for Link Prediction in Knowledge Graphs — Seyed Mehran Kazemi and David Poole (2018) Advances in Neural Information Processing Systems 31. Sections 2 and 5.1: DistMult forces every relation to be symmetric; Proposition 2 and Corollary 1: translational models are not fully expressive
  • paper A Three-Way Model for Collective Learning on Multi-Relational Data — Maximilian Nickel, Volker Tresp, and Hans-Peter Kriegel (2011) Proceedings of ICML 2011, 809–16. RESCAL, the full bilinear model that DistMult restricts to diagonal matrices
  • paper Group Representation Theory for Knowledge Graph Embedding — Chen Cai (2019) arXiv preprint 1909.05100, version 1; withdrawn in version 2. Section 4.3: relations as elements of a group acting on entity space, TransE as translations and RotatE as unit-modulus diagonal matrices, a symmetric relation as an element of order 2
  • paper NagE: Non-Abelian Group Embedding for Knowledge Graphs — Tong Yang, Long Sha, and Pengyu Hong (2020) Proceedings of CIKM 2020, 1735–42. Section 3.2: composition can be non-commutative (a mother's father is not a father's mother), so the group should in general be non-abelian
  • paper Quaternion Knowledge Graph Embeddings — Shuai Zhang, Yi Tay, Lina Yao, and Qi Liu (2019) Advances in Neural Information Processing Systems 32. QuatE: relations as rotations by unit quaternions
  • paper Rotate3D: Representing Relations as Rotations in Three-Dimensional Space for Knowledge Graph Embedding — Chang Gao, Chengjie Sun, Lili Shan, Lei Lin, and Mingjiang Wang (2020) Proceedings of CIKM 2020, 385–94. The abstract: most existing methods fail to model non-commutative composition; three-dimensional rotations do (cited from the abstract; the publisher's page refused our request)
  • paper Interpretable and Fair Comparison of Link Prediction or Entity Alignment Methods — Max Berrendorf, Evgeniy Faerman, Laurent Vermue, and Volker Tresp (2020) Proceedings of IEEE/WIC/ACM WI-IAT 2020, 371–74. The optimistic, pessimistic, and realistic ranks; we read their definitions in Section 2.2, Eqs. 1–3, of the longer arXiv version (2002.06914, retitled 'On the Ambiguity of Rank-Based Evaluation of Entity Alignment or Link Prediction Methods')
  • paper A Re-evaluation of Knowledge Graph Completion Methods — Zhiqing Sun, Shikhar Vashishth, Soumya Sanyal, Partha Talukdar, and Yiming Yang (2020) Proceedings of ACL 2020, 5516–22. Section 4: placing the true answer at the top, bottom, or a random position among tied candidates; models that tie many candidates look better under the first
  • paper You CAN Teach an Old Dog New Tricks! On Training Knowledge Graph Embeddings — Daniel Ruffinelli, Samuel Broscheit, and Rainer Gemulla (2020) ICLR 2020. With appropriate training, the performance differences between models often shrink and sometimes reverse