SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.15578 · EMNLP · 2022

GammaE: Gamma Embeddings for Logical Queries on Knowledge Graphs

Yang Li, Haonan Lu, Dong Yang, Xiaodong Lin, Peijun Qing

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-24; 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/2210.15578.json · badge: /api/ran/2210.15578.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
dyang67/GammaE marked official in Papers with Code
Papers with Code archive
4 ran · 1 no recorded run
FunctionStatusWhere it lives
GammaIntersection Ran
ran on a synthesized input
dyang67/GammaE/models.py
code served (permissive licence) · get_code("be136b3420dfedf6")
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 as nn
import torch.nn.functional as F

class GammaIntersection(nn.Module):

    def __init__(self, dim):
        super(GammaIntersection, self).__init__()
        self.dim = dim
        self.layer_alpha1 = nn.Linear(self.dim * 2, self.dim)
        self.layer_beta1 = nn.Linear(self.dim * 2, self.dim)
        self.layer_alpha2 = nn.Linear(self.dim, self.dim)
        self.layer_beta2 = nn.Linear(self.dim, self.dim)
        nn.init.xavier_uniform_(self.layer_alpha1.weight)
        nn.init.xavier_uniform_(self.layer_beta1.weight)
        nn.init.xavier_uniform_(self.layer_alpha2.weight)
        nn.init.xavier_uniform_(self.layer_beta2.weight)

    def forward(self, alpha_embeddings, beta_embeddings):
        all_embeddings = torch.cat([alpha_embeddings, beta_embeddings], dim=-1)
        layer1_alpha = F.relu(self.layer_alpha1(all_embeddings))
        attention1 = F.softmax(self.layer_alpha2(layer1_alpha), dim=0)
        layer1_beta = F.relu(self.layer_beta1(all_embeddings))
        attention2 = F.softmax(self.layer_beta2(layer1_beta), dim=0)
        alpha_embedding = torch.sum(attention1 * alpha_embeddings, dim=0)
        beta_embedding = torch.sum(attention2 * 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 = GammaIntersection(**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)
GammaProjection Ran
ran on a synthesized input · constructed an object; no result was computed
dyang67/GammaE/models.py
code served (permissive licence) · get_code("db17e234dc03cf4d")
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 an instance of its own class, GammaProjection: the run constructed the object and did not call it, so no result was computed. 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 as nn
import torch.nn.functional as F

torch.manual_seed(0)

# Define a simple projection regularizer that just returns the input
class SimpleProjectionRegularizer(nn.Module):
    def forward(self, x):
        return x

# Set up the arguments
entity_dim = 4
relation_dim = 3
hidden_dim = 5
num_layers = 2
projection_regularizer = SimpleProjectionRegularizer()

ARGS = {
    "entity_dim": entity_dim,
    "relation_dim": relation_dim,
    "hidden_dim": hidden_dim,
    "projection_regularizer": projection_regularizer,
    "num_layers": num_layers,
}
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 GammaProjection — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GammaProjection output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
GammaUnion Ran
ran on a synthesized input · constructed an object; no result was computed
dyang67/GammaE/models.py
code served (permissive licence) · get_code("dce12583ed028fa3")
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 an instance of its own class, GammaUnion: the run constructed the object and did not call it, so no result was computed. 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 as nn
import torch.nn.functional as F

torch.manual_seed(0)

class GammaUnion(nn.Module):

    def __init__(self, dim, projection_regularizer, drop):
        super(GammaUnion, self).__init__()
        self.dim = dim
        self.layer_alpha1 = nn.Linear(self.dim * 2, self.dim)
        self.layer_beta1 = nn.Linear(self.dim * 2, self.dim)
        self.layer_alpha2 = nn.Linear(self.dim, self.dim // 2)
        self.layer_beta2 = nn.Linear(self.dim, self.dim // 2)
        self.layer_alpha3 = nn.Linear(self.dim // 2, self.dim)
        self.layer_beta3 = nn.Linear(self.dim // 2, self.dim)
        self.projection_regularizer = projection_regularizer
        self.drop = nn.Dropout(p=drop)
        nn.init.xavier_uniform_(self.layer_alpha1.weight)
        nn.init.xavier_uniform_(self.layer_beta1.weight)
        nn.init.xavier_uniform_(self.layer_alpha2.weight)
        nn.init.xavier_uniform_(self.layer_beta2.weight)
        nn.init.xavier_uniform_(self.layer_alpha3.weight)
        nn.init.xavier_uniform_(self.layer_beta3.weight)

    def forward(self, alpha_embeddings, beta_embeddings):
        all_embeddings = torch.cat([alpha_embeddings, beta_embeddings], dim=-1)
        layer1_alpha = F.relu(self.layer_alpha1(all_embeddings))
        layer2_alpha = F.relu(self.layer_alpha2(layer1_alpha))
        attention1 = F.softmax(self.drop(self.layer_alpha3(layer2_alpha)), dim=0)
        layer1_beta = F.relu(self.layer_beta1(all_embeddings))
        layer2_beta = F.relu(self.layer_beta2(layer1_beta))
        attention2 = F.softmax(self.drop(self.layer_beta3(layer2_beta)), dim=0)
        k = alpha_embeddings * attention1
        o = 1 / (beta_embeddings * attention2)
        k_sum = torch.pow(torch.sum(k * o, dim=0), 2) / torch.sum(torch.pow(o, 2) * k, dim=0)
        o_sum = torch.sum(k * o, dim=0) / (k_sum * o.shape[0])
        alpha_embedding = k_sum
        beta_embedding = o_sum
        alpha_embedding[torch.abs(alpha_embedding) < 0.0001] = 0.0001
        beta_embedding[torch.abs(beta_embedding) < 0.0001] = 0.0001
        return (alpha_embedding, beta_embedding)


ARGS = {
    'dim': 4,
    'projection_regularizer': 0.01,
    'drop': 0.1
}
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 GammaUnion — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GammaUnion output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
Regularizer Ran
ran on a synthesized input · constructed an object; no result was computed
dyang67/GammaE/models.py
code served (permissive licence) · get_code("4dd767dfdd3cd11d")
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 an instance of its own class, Regularizer: the run constructed the object and did not call it, so no result was computed. 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)

# Construct arguments for Regularizer
base_add = torch.tensor(0.5)
min_val = torch.tensor(-1.0)
max_val = torch.tensor(1.0)

# Define ARGS dict mapping all parameters
ARGS = {
    'base_add': base_add,
    'min_val': min_val,
    'max_val': max_val
}
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 Regularizer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Regularizer output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
KGReasoning Not yet run
unverified (harvested, no recorded run)
dyang67/GammaE/models.py
code served (permissive licence) · get_code("c46caac6fd973482")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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
Regularizer
brick of this paper's assembly: helper
3 other papers
3 dated earlier · 3 only as an assembly brick
2002.05969 (2020-02)
Query2box: Reasoning over Knowledge Graphs in Vector Space using Box Embeddings
2010.11465 (2020-10)
Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs
2110.13522 (2021-10)
Probabilistic Entity Representation Model for Reasoning over Knowledge Graphs

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-24.

Repositories linked to this paper

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

Abstract

Embedding knowledge graphs (KGs) for multihop logical reasoning is a challenging problem due to massive and complicated structures in many KGs. Recently, many promising works projected entities and queries into a geometric space to efficiently find answers. However, it remains challenging to model the negation and union operator. The negation operator has no strict boundaries, which generates overlapped embeddings and leads to obtaining ambiguous answers. An additional limitation is that the union operator is non-closure, which undermines the model to handle a series of union operators. To address these problems, we propose a novel probabilistic embedding model, namely Gamma Embeddings (GammaE), for encoding entities and queries to answer different types of FOL queries on KGs. We utilize the linear property and strong boundary support of the Gamma distribution to capture more features of entities and queries, which dramatically reduces model uncertainty. Furthermore, Gam-maE implements the Gamma mixture method to design the closed union operator. The performance of GammaE is validated on three large logical query datasets. Experimental results show that GammaE significantly outperforms state-of-the-art models on public benchmarks.

For agents

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

get_harvested_code_for_paper("2210.15578")
get_code_for_paper("2210.15578")
have("2210.15578")

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

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

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

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

Connect an agent — have() is free.