SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2023.findings-emnlp.761 · EMNLP Findings · 2023

Query2Triple: Unified Query Encoding for Answering Diverse Complex Queries over Knowledge Graphs

Yao Xu, Shizhu He, Kang Liu, Jun Zhao, Li Cai, Cunguang Wang

Open in the Atlas

Code that ran

16 of 18 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; 1 honoured the contract we drafted, 0 violated it and 12 have no contract verdict; 3 failures of our instrument; 2 no recorded run), measured 2026-11-24; 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/2023.findings-emnlp.761.json · badge: /api/ran/2023.findings-emnlp.761.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
YaooXu/Q2T canonical (classifier label)
classifier basis: census
16 ran · 2 no recorded run
FunctionStatusWhere it lives
avg_both Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/utils.py
code served (permissive licence) · get_code("9a7392f1429a28c1")
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 dict. 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 expects:
# - mrrs: a dict with keys 'lhs' and/or 'rhs', values are torch tensors (supports addition and division)
# - hits: a dict with keys 'lhs' and/or 'rhs', values are torch tensors (supports addition, division, and .tolist())

# Case 1: Both 'lhs' and 'rhs' present
mrrs = {
    'lhs': torch.tensor([0.5, 0.6, 0.7, 0.8]),
    'rhs': torch.tensor([0.4, 0.65, 0.75, 0.85])
}

hits = {
    'lhs': torch.tensor([10, 20, 30, 40]),
    'rhs': torch.tensor([15, 25, 35, 45])
}

ARGS = {
    'mrrs': mrrs,
    'hits': hits
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
eval_tuple Ran
ran, honoured the contract we drafted
YaooXu/Q2T/utils/util.py
code served (permissive licence) · get_code("200c8d976faf4263")
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 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 torch
import numpy as np
from typing import List, Dict

torch.manual_seed(0)

# Test cases for eval_tuple function
# The function can accept:
# 1. A tuple (already a tuple, just return it)
# 2. A string representation of a simple value like "5" or "'hello'"
# 3. A string representation of a tuple/list like "(1,2,3)" or "[1,2,3]"

test_cases = [
    # Case 1: Already a tuple
    (1, 2, 3),
    # Case 2: String representation of a number
    "42",
    # Case 3: String representation of a tuple
    "(1, 2, 3)",
    # Case 4: String representation of a list (converts to tuple)
    "[4, 5, 6]",
    # Case 5: String with empty elements that should be skipped
    "(1, , 2)",
    # Case 6: String representation of mixed types
    "(1, 'hello', 3.14)",
]

# We'll test with one representative case
ARGS = {
    "arg_return": "(1, 2, 3)"
}
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 int — 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
filtering Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
YaooXu/Q2T/ssl-relation-prediction/src/models.py
pointer only (licence: MIT); the stored copy get_code serves, from bys0318/qto, is pointer only (licence: NONE) · get_code("f4ec06f37defd643")
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 bys0318/qto, and GitHub detected no licence in that repository 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.

flatten_query Ran
ran on a synthesized input
YaooXu/Q2T/dataset.py
code served (permissive licence) · get_code("f9fde74d211e17c2")
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
import numpy as np

# Define the query_structure_to_type mapping (provided in the function)
query_structure_to_type = {
    ('e', ('r',)): '1p',
    ('e', ('r', 'r')): '2p',
    ('e', ('r', 'r', 'r')): '3p',
    (('e', ('r',)), ('e', ('r',))): '2i',
    (('e', ('r',)), ('e', ('r',)), ('e', ('r',))): '3i',
    ((('e', ('r',)), ('e', ('r',))), ('r',)): 'ip',
    (('e', ('r', 'r')), ('e', ('r',))): 'pi',
    (('e', ('r',)), ('e', ('r', 'n'))): '2in',
    (('e', ('r',)), ('e', ('r',)), ('e', ('r', 'n'))): '3in',
    ((('e', ('r',)), ('e', ('r', 'n'))), ('r',)): 'inp',
    (('e', ('r', 'r')), ('e', ('r', 'n'))): 'pin',
    (('e', ('r', 'r', 'n')), ('e', ('r',))): 'pni',
    (('e', ('r',)), ('e', ('r',)), ('u',)): '2u-DNF',
    ((('e', ('r',)), ('e', ('r',)), ('u',)), ('r',)): 'up-DNF',
    ((('e', ('r', 'n')), ('e', ('r', 'n'))), ('n',)): '2u-DM',
    ((('e', ('r', 'n')), ('e', ('r', 'n'))), ('n', 'r')): 'up-DM'
}

# Create sample queries dict
# Each key is a query_structure, and the value is a collection of queries
# For this function, queries is a dict mapping query_structure -> iterable of queries

queries_dict = {
    ('e', ('r',)): [
        (1, 0, 2),
        (3, 1, 4)
    ],
    ('e', ('r', 'r')): [
        (5, 0, 2, 1),
        (6, 1, 3, 2)
    ],
    (('e', ('r',)), ('e', ('r',))): [
        ((1, 0, 2), (3, 1, 4)),
        ((5, 0, 1), (6, 1, 2))
    ]
}

ARGS = {
    'queries': queries_dict
}
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 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
floyd Ran
ran on a synthesized input
YaooXu/Q2T/query_format_converter.py
code served (permissive licence) · get_code("bf078c423f6997de")
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 ndarray, ndim 2, dtype family int, shape (5, 5) 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 numpy as np

# Create a small adjacency matrix
# 5 nodes, sparse connections
adj_mat = np.array([
    [0, 1, 0, 0, 0],
    [1, 0, 1, 0, 0],
    [0, 1, 0, 1, 0],
    [0, 0, 1, 0, 1],
    [0, 0, 0, 1, 0]
], dtype=np.float32)

# layers: array indicating layer assignment for each node
layers = np.array([0, 1, 1, 2, 2], dtype=np.int32)

# seq_num_nodes: number of sequential nodes
seq_num_nodes = 5

# node_types: type identifier for each node
node_types = np.array([0, 0, 1, 2, 1], dtype=np.int32)

# query_type: string identifier for the query type
query_type = "test_query_1"

# enc_dist: encoding distance mode - 'd' for directed, otherwise undirected
enc_dist = "d"

ARGS = {
    "adj_mat": adj_mat,
    "layers": layers,
    "seq_num_nodes": seq_num_nodes,
    "node_types": node_types,
    "query_type": query_type,
    "enc_dist": enc_dist
}
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 ndarray, ndim 2, dtype family int, shape (5, 5) — shape (5, 5) 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: none by the harness; any seed is in the setup block
get_avg_param Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/utils.py
code served (permissive licence) · get_code("9c67afb06e8f3344")
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 Tensor, ndim 0, dtype family float, shape () 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 numpy as np

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 Tensor, ndim 0, dtype family float, shape () — shape () 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: none by the harness; any seed is in the setup block
get_inv_rel Ran
ran on a synthesized input
YaooXu/Q2T/query_format_converter.py
code served (permissive licence) · get_code("a2ceb3355584c23f")
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 int, ndim 0, dtype family int, shape () 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

torch.manual_seed(0)

def get_inv_rel(rel):
    return rel ^ 1

ARGS = {
    "rel": 5
}
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 int, ndim 0, dtype family int, shape () — shape () 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: none by the harness; any seed is in the setup block
invert Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/datasets.py
code served (permissive licence) · get_code("81fe3c0217dde15d")
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 ndarray, ndim 2, dtype family int, shape (4, 7) 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 numpy as np

# Create a small triples array with shape (2, 7)
# Columns: h, r, t, h_neg, t_neg, h_type, t_type
triples = np.array([
    [0, 1, 2, 3, 4, 5, 6],
    [1, 0, 3, 2, 5, 4, 7]
], dtype=np.int64)

n_rel = 4
stack = True
include_type = True

ARGS = {
    "triples": triples,
    "n_rel": n_rel,
    "stack": stack,
    "include_type": include_type
}
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 ndarray, ndim 2, dtype family int, shape (4, 7) — shape (4, 7) 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: none by the harness; any seed is in the setup block
invert_torch Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/datasets.py
code served (permissive licence) · get_code("ad62824bbe42ecba")
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 Tensor, ndim 2, dtype family int, shape (2, 7) 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

torch.manual_seed(0)

# The function expects:
# - triples: a tensor with shape (batch_size, num_columns)
#   The columns are: [h, r, t, h_neg_1, ..., h_neg_n, t_neg_1, ..., t_neg_n, h_type, t_type]
#   or without types: [h, r, t, h_neg_1, ..., h_neg_n, t_neg_1, ..., t_neg_n]
# - n_rel: an integer representing number of original relations

# Create a small tensor with structure: h, r, t, h_neg, t_neg, h_type, t_type
# That's 7 columns minimum when include_type=True
# Let's use: batch_size=2, and 7 columns (h=0, r=1, t=2, h_neg=3, t_neg=4, h_type=5, t_type=6)
triples = torch.tensor([
    [0, 5, 1, 10, 11, 2, 3],
    [2, 6, 3, 12, 13, 4, 5]
], dtype=torch.int64)

n_rel = 10
include_type = True

ARGS = {
    "triples": triples,
    "n_rel": n_rel,
    "include_type": include_type,
}
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 Tensor, ndim 2, dtype family int, shape (2, 7) — shape (2, 7) 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: none by the harness; any seed is in the setup block
list2tuple Ran
ran; our contract draft was wrong, not the code
YaooXu/Q2T/utils/util.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
load_data Ran
ran on a synthesized input
YaooXu/Q2T/dataset.py
code served (permissive licence) · get_code("50a8af8e9eb8a600")
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 pickle
import tempfile
from pathlib import Path

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

# Create minimal pickle files with the expected structure
train_queries = {
    ('e', ('r',)): [(0, 1), (1, 2)],
    ('e', ('r', 'r')): [(0, 2), (1, 3)],
}
train_answers = {
    ('e', ('r',)): {0: {10, 11}, 1: {20, 21}},
    ('e', ('r', 'r')): {0: {100, 101}, 1: {200, 201}},
}
valid_queries = {
    ('e', ('r',)): [(2, 3)],
    ('e', ('r', 'r')): [(2, 4)],
}
valid_hard_answers = {
    ('e', ('r',)): {2: {30, 31}},
    ('e', ('r', 'r')): {2: {300, 301}},
}
valid_easy_answers = {
    ('e', ('r',)): {2: {32, 33}},
    ('e', ('r', 'r')): {2: {302, 303}},
}
test_queries = {
    ('e', ('r',)): [(3, 4)],
    ('e', ('r', 'r')): [(3, 5)],
}
test_hard_answers = {
    ('e', ('r',)): {3: {40, 41}},
    ('e', ('r', 'r')): {3: {400, 401}},
}
test_easy_answers = {
    ('e', ('r',)): {3: {42, 43}},
    ('e', ('r', 'r')): {3: {402, 403}},
}

# Write pickle files to temp directory
pickle.dump(train_queries, open(os.path.join(temp_dir, 'train-queries.pkl'), 'wb'))
pickle.dump(train_answers, open(os.path.join(temp_dir, 'train-answers.pkl'), 'wb'))
pickle.dump(valid_queries, open(os.path.join(temp_dir, 'valid-queries.pkl'), 'wb'))
pickle.dump(valid_hard_answers, open(os.path.join(temp_dir, 'valid-hard-answers.pkl'), 'wb'))
pickle.dump(valid_easy_answers, open(os.path.join(temp_dir, 'valid-easy-answers.pkl'), 'wb'))
pickle.dump(test_queries, open(os.path.join(temp_dir, 'test-queries.pkl'), 'wb'))
pickle.dump(test_hard_answers, open(os.path.join(temp_dir, 'test-hard-answers.pkl'), 'wb'))
pickle.dump(test_easy_answers, open(os.path.join(temp_dir, 'test-easy-answers.pkl'), 'wb'))

# Create a minimal args object
class Args:
    def __init__(self):
        self.data_path = temp_dir
        self.evaluate_union = 'DNF'

ARGS = {
    'args': Args(),
    'tasks': ['1p', '2p', '2i']
}
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
setup_loss Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/engines.py
code served (permissive licence) · get_code("ad7386deb3ce9232")
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 BCEWithLogitsLoss. 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
from torch import nn

torch.manual_seed(0)

# The function only reads opt['world'] to decide which loss to instantiate
# Valid values are 'sLCWA+bpr', 'sLCWA+set', or 'LCWA'
ARGS = {
    'opt': {'world': 'sLCWA+bpr'}
}
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 BCEWithLogitsLoss — a BCEWithLogitsLoss output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a BCEWithLogitsLoss 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
setup_optimizer Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/utils.py
code served (permissive licence) · get_code("65723913a33ffde3")
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 SparseAdam. 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
from torch import optim

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = SimpleModel()

ARGS = {
    'model': model,
    'type': 'Adam',
    'learning_rate': 0.001,
    'decay1': 0.9,
    'decay2': 0.999,
    'momentum': 0.9
}
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 SparseAdam — a SparseAdam output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SparseAdam 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
subsample Ran
ran on a synthesized input
YaooXu/Q2T/ssl-relation-prediction/src/datasets.py
code served (permissive licence) · get_code("531b7da64b0bf034")
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 Tensor, ndim 2, dtype family float, shape (2, 3) 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

torch.manual_seed(0)

# Create a small tensor of triples
# triples should support indexing with a tensor (perm)
# Shape: (batch_size, triple_elements) - using 6 triples with 3 elements each
triples = torch.randn(6, 3)

# n is the number of entries to subsample
n = 2

ARGS = {
    "triples": triples,
    "n": n,
}
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 Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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: none by the harness; any seed is in the setup block
topoSort Ran
ran on a synthesized input
YaooXu/Q2T/query_format_converter.py
code served (permissive licence) · get_code("4705f0708c3fca0f")
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 numpy as np

# Construct valid arguments for topoSort function
# The function expects edges as a list or numpy array of [source, relation, target] triplets

# Create a simple directed acyclic graph (DAG) as edges
# Each edge is [source_node, relation, target_node]
edges = [
    [0, "rel1", 1],
    [0, "rel2", 2],
    [1, "rel3", 3],
    [2, "rel4", 3]
]

ARGS = {
    "edges": edges
}
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 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
tuple2list Ran
ran; our contract draft was wrong, not the code
YaooXu/Q2T/utils/util.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
merge_graph Not yet run
unverified (harvested, no recorded run)
YaooXu/Q2T/dataset.py
code served (permissive licence) · get_code("c6e1f2d6d394d159")
How it ran

no invocation recorded.

setup_ds Not yet run
unverified (harvested, no recorded run)
YaooXu/Q2T/ssl-relation-prediction/src/engines.py
code served (permissive licence) · get_code("9dd3bbf562083421")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 14 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
eval_tuple 4 other papers
4 dated earlier
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2010.11465 (2020-10)
Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
and 1 more not named here
list2tuple 4 other papers
4 dated earlier
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2010.11465 (2020-10)
Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
and 1 more not named here
tuple2list 4 other papers
4 dated earlier
1806.01445 (2018-06)
Embedding Logical Queries on Knowledge Graphs
2010.11465 (2020-10)
Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs
2204.12847 (2022-04)
Query2Particles: Knowledge Graph Reasoning with Particle Embeddings
and 1 more not named here
filtering 1 other paper
1 dated earlier
2212.09567 (2022-12)
Answering Complex Logical Queries on Knowledge Graphs via Query Computation Tree Optimization

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

Complex Query Answering (CQA) is a challenge task of Knowledge Graph (KG). Due to the incompleteness of KGs, query embedding (QE) methods have been proposed to encode queries and entities into the same embedding space, and treat logical operators as neural set operators to obtain answers. However, these methods train KG embeddings and neural set operators concurrently on both simple (one-hop) and complex (multi-hop and logical) queries, which causes performance degradation on simple queries and low training efficiency. In this paper, we propose Query to Triple (Q2T), a novel approach that decouples the training for simple and complex queries. Q2T divides the training into two stages: (1) Pre-training a neural link predictor on simple queries to predict tail entities based on the head entity and relation. ( 2) Training a query encoder on complex queries to encode diverse complex queries into a unified triple form that can be efficiently solved by the pretrained neural link predictor. Our proposed Q2T is not only efficient to train, but also modular, thus easily adaptable to various neural link predictors that have been studied well. Extensive experiments demonstrate that, even without explicit modeling for neural set operators, Q2T still achieves state-of-the-art performance on diverse complex queries over three public benchmarks.

For agents

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

get_harvested_code_for_paper("2023.findings-emnlp.761")
get_code_for_paper("2023.findings-emnlp.761")
have("2023.findings-emnlp.761")

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

curl https://syntology.ai/api/ran/2023.findings-emnlp.761.json

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

[![Syntology run record](https://syntology.ai/api/ran/2023.findings-emnlp.761.svg)](https://syntology.ai/paper/2023.findings-emnlp.761)

Connect an agent — have() is free.