SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.11465 · NeurIPS · 2020

Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs

Hongyu Ren, Jure Leskovec

arXiv · PDF · Open in the Atlas

Code that ran

9 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 3 failures of our instrument; 5 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2010.11465.json · badge: /api/ran/2010.11465.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
snap-stanford/KGReasoning community (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
Jacfger/simple-stuffs community
Papers with Code archive
2 ran · 1 no recorded run
uclnlp/cqd community
Papers with Code archive
1 ran · 4 no recorded run
LHY-24/KG-Compilation community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
BetaIntersection Ran
ran on a synthesized input
LHY-24/KG-Compilation/src/models.py
pointer only (licence: NONE) · get_code("15f1515d95ce51d1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, LHY-24/KG-Compilation when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BetaIntersection Ran
ran on a synthesized input
Jacfger/simple-stuffs/fol/estimator_beta.py
code served (permissive licence) · get_code("65d51f93f096ca1a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F
from torch import nn

class BetaIntersection(nn.Module):

    def __init__(self, dim):
        super(BetaIntersection, self).__init__()
        self.dim = dim
        self.layer1 = nn.Linear(2 * self.dim, 2 * self.dim)
        self.layer2 = nn.Linear(2 * self.dim, self.dim)
        nn.init.xavier_uniform_(self.layer1.weight)
        nn.init.xavier_uniform_(self.layer2.weight)

    def forward(self, alpha_embeddings, beta_embeddings):
        all_embeddings = torch.cat([alpha_embeddings, beta_embeddings], dim=-1)
        layer1_act = F.relu(self.layer1(all_embeddings))
        attention = F.softmax(self.layer2(layer1_act), dim=0)
        alpha_embedding = torch.sum(attention * alpha_embeddings, dim=0)
        beta_embedding = torch.sum(attention * beta_embeddings, dim=0)
        return (alpha_embedding, beta_embedding)


INIT_ARGS = {
    'dim': 4
}

ARGS = {
    'alpha_embeddings': torch.randn(2, 4),
    'beta_embeddings': torch.randn(2, 4)
}

if __name__ == '__main__':
    model = BetaIntersection(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:", output[0].shape, output[1].shape)
    print("Output:", output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
BetaProjection Ran
ran on a synthesized input
Jacfger/simple-stuffs/fol/estimator_beta.py
code served (permissive licence) · get_code("bc022c5d939d4dff")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F

class BetaProjection(nn.Module):

    def __init__(self, entity_dim, relation_dim, hidden_dim, projection_regularizer, num_layers):
        super(BetaProjection, self).__init__()
        self.entity_dim = entity_dim
        self.relation_dim = relation_dim
        self.hidden_dim = hidden_dim
        self.num_layers = num_layers
        self.layer1 = nn.Linear(self.entity_dim + self.relation_dim, self.hidden_dim)
        self.layer0 = nn.Linear(self.hidden_dim, self.entity_dim)
        for nl in range(2, num_layers + 1):
            setattr(self, 'layer{}'.format(nl), nn.Linear(self.hidden_dim, self.hidden_dim))
        for nl in range(num_layers + 1):
            nn.init.xavier_uniform_(getattr(self, 'layer{}'.format(nl)).weight)
        self.projection_regularizer = projection_regularizer

    def forward(self, e_embedding, r_embedding):
        x = torch.cat([e_embedding, r_embedding], dim=-1)
        for nl in range(1, self.num_layers + 1):
            x = F.relu(getattr(self, 'layer{}'.format(nl))(x))
        x = self.layer0(x)
        x = self.projection_regularizer(x)
        return x


def identity_regularizer(x):
    return x


INIT_ARGS = {
    'entity_dim': 4,
    'relation_dim': 3,
    'hidden_dim': 8,
    'projection_regularizer': identity_regularizer,
    'num_layers': 2,
}

ARGS = {
    'e_embedding': torch.randn(2, 4),
    'r_embedding': torch.randn(2, 3),
}

model = BetaProjection(**INIT_ARGS)
output = model(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Identity Ran
ran, honoured the contract we drafted
snap-stanford/KGReasoning/models.py
pointer only (licence: MIT); the stored copy get_code serves, from akirato/perm-gaussiankg, is pointer only (licence: GPL-3.0) · get_code("f44985272d18127a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from akirato/perm-gaussiankg, and GPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

construct_graph Ran
ran on a synthesized input
snap-stanford/KGReasoning/create_queries.py
code served (permissive licence) · get_code("75304c63d0f3ce0c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import os.path as osp
from collections import defaultdict

# Create a temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create sample indexified files with triple data (e1, rel, e2)
indexified_file_1 = "triples_1.txt"
indexified_file_1_path = osp.join(temp_dir, indexified_file_1)
with open(indexified_file_1_path, 'w') as f:
    f.write("0\t1\t2\n")
    f.write("1\t0\t3\n")
    f.write("2\t1\t0\n")

indexified_file_2 = "triples_2.txt"
indexified_file_2_path = osp.join(temp_dir, indexified_file_2)
with open(indexified_file_2_path, 'w') as f:
    f.write("3\t2\t1\n")
    f.write("0\t1\t1\n")

ARGS = {
    "base_path": temp_dir,
    "indexified_files": [indexified_file_1, indexified_file_2]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_tuple Ran
ran; our contract draft was wrong, not the code
snap-stanford/KGReasoning/util.py
code served (permissive licence) · get_code("08bc9653c017dfb5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

def eval_tuple(arg_return):
    """Evaluate a tuple string into a tuple."""
    if type(arg_return) == tuple:
        return arg_return
    if arg_return[0] not in ['(', '[']:
        arg_return = eval(arg_return)
    else:
        splitted = arg_return[1:-1].split(',')
        List = []
        for item in splitted:
            try:
                item = eval(item)
            except:
                pass
            if item == '':
                continue
            List.append(item)
        arg_return = tuple(List)
    return arg_return


# Test case 1: arg_return is already a tuple
test_tuple = (1, 2, 3)

# Test case 2: arg_return is a string representation of a simple value
test_string_simple = "42"

# Test case 3: arg_return is a string representation of a tuple with parentheses
test_string_tuple = "(1, 2, 3)"

# Test case 4: arg_return is a string representation of a list with brackets
test_string_list = "[1, 2, 3]"

# For ARGS, we need to pick one representative test case
# The function takes one parameter: arg_return
ARGS = {
    "arg_return": "(1, 2, 'hello')"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
list2tuple Ran
ran; our contract draft was wrong, not the code
snap-stanford/KGReasoning/create_queries.py
code served (permissive licence) · get_code("8c314b5b308ab1ad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function list2tuple recursively converts lists to tuples
# It takes a single parameter 'l' which should be a list (possibly nested)

# Create test data with nested lists
test_list = [
    1,
    [2, 3],
    [[4, 5], 6],
    "string",
    [7, [8, [9, 10]]]
]

ARGS = {
    "l": test_list
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_batches Ran
ran, honoured the contract we drafted
uclnlp/cqd/kbc/models.py
code served (permissive licence) · get_code("b602fff455d94358")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

ARGS = {
    "size": 100,
    "batch_size": 32,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tuple2list Ran
ran; our contract draft was wrong, not the code
snap-stanford/KGReasoning/create_queries.py
code served (permissive licence) · get_code("bbd072fbd86e1541")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

def tuple2list(t):
    return list((tuple2list(x) if type(x) == tuple else x for x in t))

# The function recursively converts nested tuples to lists
# It takes a single parameter 't' which should be a tuple (possibly containing nested tuples)

ARGS = {
    't': (1, 2, (3, 4, (5, 6)), 7)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BetaEstimator Not yet run
unverified (harvested, no recorded run)
Jacfger/simple-stuffs/fol/estimator_beta.py
code served (permissive licence) · get_code("83454511701e3bdd")
How it ran

no invocation recorded.

DynKBCSingleton Not yet run
unverified (harvested, no recorded run)
uclnlp/cqd/kbc/models.py
code served (permissive licence) · get_code("c1c62def2f1c5499")
How it ran

no invocation recorded.

KBCModel Not yet run
unverified (harvested, no recorded run)
uclnlp/cqd/kbc/models.py
code served (permissive licence) · get_code("a3016c183214fb5a")
How it ran

no invocation recorded.

QuerDAG Not yet run
unverified (harvested, no recorded run)
uclnlp/cqd/kbc/models.py
code served (permissive licence) · get_code("ccc626ec21ffdcfb")
How it ran

no invocation recorded.

Regularizer Not yet run
unverified (harvested, no recorded run)
uclnlp/cqd/kbc/models.py
code served (permissive licence) · get_code("dfce66d833684f59")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 7 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 7 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
Identity 7 other papers
4 dated earlier, 3 later
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
1909.05311 (2019-09)
Graph-Based Reasoning over Heterogeneous External Knowledge for Commonsense Question Answering
2002.05969 (2020-02)
Query2box: Reasoning over Knowledge Graphs in Vector Space using Box Embeddings
and 4 more not named here
eval_tuple 4 other papers
1 dated earlier, 3 later
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
2209.14464 (2022-09)
Neural Methods for Logical Reasoning Over Knowledge Graphs
and 1 more not named here
list2tuple 4 other papers
1 dated earlier, 3 later
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
2209.14464 (2022-09)
Neural Methods for Logical Reasoning Over Knowledge Graphs
and 1 more not named here
tuple2list 4 other papers
1 dated earlier, 3 later
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
2209.14464 (2022-09)
Neural Methods for Logical Reasoning Over Knowledge Graphs
and 1 more not named here
BetaIntersection
brick of this paper's assembly: entry, model
2 other papers
1 dated earlier, 1 later · 2 only as an assembly brick
2002.05969 (2020-02)
Query2box: Reasoning over Knowledge Graphs in Vector Space using Box Embeddings
2110.13522 (2021-10)
Probabilistic Entity Representation Model for Reasoning over Knowledge Graphs
BetaProjection
brick of this paper's assembly: model
2 other papers
1 dated earlier, 1 later · 1 only as an assembly brick
2002.05969 (2020-02)
Query2box: Reasoning over Knowledge Graphs in Vector Space using Box Embeddings
2110.13522 (2021-10)
Probabilistic Entity Representation Model for Reasoning over Knowledge Graphs
Regularizer
brick of this paper's assembly: helper
1 other paper
1 later
2011.05816 (2020-11)
Duality-Induced Regularizer for Tensor Factorization Based Knowledge Graph Completion

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

One of the fundamental problems in Artificial Intelligence is to perform complex multi-hop logical reasoning over the facts captured by a knowledge graph (KG). This problem is challenging, because KGs can be massive and incomplete. Recent approaches embed KG entities in a low dimensional space and then use these embeddings to find the answer entities. However, it has been an outstanding challenge of how to handle arbitrary first-order logic (FOL) queries as present methods are limited to only a subset of FOL operators. In particular, the negation operator is not supported. An additional limitation of present methods is also that they cannot naturally model uncertainty. Here, we present BETAE, a probabilistic embedding framework for answering arbitrary FOL queries over KGs. BETAE is the first method that can handle a complete set of first-order logical operations: conjunction (∧), disjunction (∨), and negation (¬). A key insight of BETAE is to use probabilistic distributions with bounded support, specifically the Beta distribution, and embed queries/entities as distributions, which as a consequence allows us to also faithfully model uncertainty. Logical operations are performed in the embedding space by neural operators over the probabilistic embeddings. We demonstrate the performance of BETAE on answering arbitrary FOL queries on three large, incomplete KGs. While being more general, BETAE also increases relative performance by up to 25.4% over the current state-of-the-art KG reasoning methods that can only handle conjunctive queries without negation.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2010.11465")
get_code_for_paper("2010.11465")
have("2010.11465")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2010.11465.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2010.11465.svg)](https://syntology.ai/paper/2010.11465)

Connect an agent — have() is free.