SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2307.02759 · 2023

Knowledge Graph Self-Supervised Rationalization for Recommendation

arXiv · PDF · Open in the Atlas

Code that ran

3 of 8 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 0 have no contract verdict; 2 failures of our instrument; 5 no recorded run), measured 2026-11-22; 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/2307.02759.json · badge: /api/ran/2307.02759.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
hkuds/kgrec canonical (classifier label)
classifier basis: census
3 ran · 5 no recorded run
FunctionStatusWhere it lives
build_graph Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hkuds/kgrec/utils/data_loader.py
code served (permissive licence) · get_code("44c2871f40d5a80b")
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 networkx as nx
from collections import defaultdict

# Create small train_data as list of (u_id, i_id) tuples
train_data = [
    (0, 10),
    (1, 11),
    (2, 12),
]

# Create small triplets as list of (h_id, r_id, t_id) tuples for knowledge graph
triplets = [
    (10, 0, 20),
    (11, 1, 21),
    (12, 2, 22),
    (20, 3, 30),
]

ARGS = {
    'train_data': train_data,
    'triplets': triplets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx, torch, tqdm — 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
build_graph Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hkuds/kgrec/utils/data_loader_kgcl.py
code served (permissive licence) · get_code("a6bc535edeabcd18")
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 networkx as nx
from collections import defaultdict

# Construct train_data: list of (user_id, item_id) tuples
train_data = [
    (0, 10),
    (1, 11),
    (2, 12),
    (3, 13),
]

# Construct triplets: list of (head_id, relation_id, tail_id) tuples
triplets = [
    (10, 0, 20),
    (10, 1, 21),
    (11, 0, 22),
    (12, 1, 23),
    (20, 2, 30),
]

ARGS = {
    "train_data": train_data,
    "triplets": triplets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx, torch, tqdm — 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
read_cf Ran
ran, honoured the contract we drafted
hkuds/kgrec/utils/data_loader.py
code served (permissive licence) · get_code("a943eb44a36720f5")
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 (10, 2) 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
import tempfile
import os

# Create a temporary file with valid input data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("0 1 2 3\n")
temp_file.write("1 4 5 2\n")
temp_file.write("2 6 7 8 9\n")
temp_file.close()

ARGS = {
    'file_name': temp_file.name
}
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 (10, 2) — shape (10, 2) 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_auc Not yet run
unverified (harvested, no recorded run)
hkuds/kgrec/utils/evaluate.py
code served (permissive licence) · get_code("0671d5a4cbb1c2ac")
How it ran

no invocation recorded.

get_feed_dict Not yet run
unverified (harvested, no recorded run)
hkuds/kgrec/run_kgrec.py
code served (permissive licence) · get_code("21b932e40a1ee1c5")
How it ran

no invocation recorded.

get_feed_dict Not yet run
unverified (harvested, no recorded run)
hkuds/kgrec/run_kgin.py
code served (permissive licence) · get_code("aa1574c6d12e18d2")
How it ran

no invocation recorded.

neg_sampling_cpp Not yet run
unverified (harvested, no recorded run)
hkuds/kgrec/run_kgrec.py
code served (permissive licence) · get_code("cb052aef6a869c15")
How it ran

no invocation recorded.

read_triplets Not yet run
unverified (harvested, no recorded run)
hkuds/kgrec/utils/data_loader.py
code served (permissive licence) · get_code("a62b98b0ef1ddefd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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
get_auc 1 other paper
1 dated earlier
1905.07854 (2019-05)
KGAT: Knowledge Graph Attention Network for Recommendation
read_cf 1 other paper
1 dated earlier
1905.07854 (2019-05)
KGAT: Knowledge Graph Attention Network for Recommendation
read_triplets 1 other paper
1 dated earlier
1905.07854 (2019-05)
KGAT: Knowledge Graph Attention Network for Recommendation

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

Repositories linked to this paper

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

Abstract

In this paper, we introduce a new self-supervised rationalization method, called KGRec, for knowledge-aware recommender systems. To effectively identify informative knowledge connections, we propose an attentive knowledge rationalization mechanism that generates rational scores for knowledge triplets. With these scores, KGRec integrates generative and contrastive self-supervised tasks for recommendation through rational masking. To highlight rationales in the knowledge graph, we design a novel generative task in the form of masking-reconstructing. By masking important knowledge with high rational scores, KGRec is trained to rebuild and highlight useful knowledge connections that serve as rationales. To further rationalize the effect of collaborative interactions on knowledge graph learning, we introduce a contrastive learning task that aligns signals from knowledge and user-item interaction views. To ensure noise-resistant contrasting, potential noisy edges in both graphs judged by the rational scores are masked. Extensive experiments on three real-world datasets demonstrate that KGRec outperforms state-of-the-art methods. We also provide the implementation codes for our approach at https://github.com/HKUDS/KGRec.

For agents

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

get_harvested_code_for_paper("2307.02759")
get_code_for_paper("2307.02759")
have("2307.02759")

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

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

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

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

Connect an agent — have() is free.