SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.21649 · 2026

GS-Quant: Granular Semantic and Generative Structural Quantization for Knowledge Graph Completion

Yunhui Liu, Qizhuo Xie, Tao Zheng, Tieke He, Yu Xing, Qianzi Hou, Xudong Jin

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 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; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2604.21649.json · badge: /api/ran/2604.21649.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
mikumifa/GS-Quant community
Papers with Code archive
10 ran · 3 no recorded run
FunctionStatusWhere it lives
LlamaAttention Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("de06c2e189aa7a3f")
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 3, dtype family float, shape (2, 3, 8) 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 math

# Copy the classes from the problem
class RotaryEmbedding(nn.Module):

    def __init__(self, dim, base=10000, max_position_embeddings=4096):
        super().__init__()
        self.inv_freq = 1.0 / base ** (torch.arange(0, dim, 2).float() / dim)
        self.max_seq_len_cached = max_position_embeddings
        t = torch.arange(self.max_seq_len_cached, dtype=torch.float32)
        freqs = torch.einsum('i,j->ij', t, self.inv_freq)
        emb = torch.cat((freqs, freqs), dim=-1)
        self.register_buffer('cos_cached', emb.cos()[None, :, None, :], persistent=False)
        self.register_buffer('sin_cached', emb.sin()[None, :, None, :], persistent=False)

    def forward(self, x, seq_len):
        if seq_len > self.max_seq_len_cached:
            t = torch.arange(seq_len, device=x.device, dtype=torch.float32)
            freqs = torch.einsum('i,j->ij', t, self.inv_freq.to(x.device))
            emb = torch.cat((freqs, freqs), dim=-1)
            cos = emb.cos()[None, :, None, :]
            sin = emb.sin()[None, :, None, :]
        else:
            cos = self.cos_cached[:, :seq_len, :, :]
            sin = self.sin_cached[:, :seq_len, :, :]
        return (cos, sin)

def apply_rotary_pos_emb(q, k, cos, sin):

    def rotate_half(x):
        x1, x2 = (x[..., :x.shape[-1] // 2], x[..., x.shape[-1] // 2:])
        return torch.cat((-x2, x1), dim=-1)
    q_embed = q * cos + rotate_half(q) * sin
    k_embed = k * cos + rotate_half(k) * sin
    return (q_embed, k_embed)

class LlamaAttention(nn.Module):

    def __init__(self, hidden_size, num_heads, dropout=0.0, max_position_embeddings=4096):
        super().__init__()
        if hidden_size % num_heads != 0:
            raise ValueError(f'hidden_size ({hidden_size}) must be divisible by num_heads ({num_heads})')
        self.hidden_size = hidden_size
        self.num_heads = num_heads
        self.head_dim = hidden_size // num_heads
        self.scale = 1.0 / math.sqrt(self.head_dim)
        self.q_proj = nn.Linear(hidden_size, hidden_size, bias=False)
        self.k_proj = nn.Linear(hidden_size, hidden_size, bias=False)
        self.v_proj = nn.Linear(hidden_size, hidden_size, bias=False)
        self.o_proj = nn.Linear(hidden_size, hidden_size, bias=False)
        self.rotary_emb = RotaryEmbedding(self.head_dim, max_position_embeddings=max_position_embeddings)
        self.attn_dropout = nn.Dropout(dropout)

    def forward(self, x, attention_mask=None):
        bsz, seq_len, _ = x.size()
        q = self.q_proj(x).view(bsz, seq_len, self.num_heads, self.head_dim)
        k = self.k_proj(x).view(bsz, seq_len, self.num_heads, self.head_dim)
        v = self.v_proj(x).view(bsz, seq_len, self.num_heads, self.head_dim)
        cos, sin = self.rotary_emb(x, seq_len)
        q, k = apply_rotary_pos_emb(q, k, cos, sin)
        q = q.transpose(1, 2)
        k = k.transpose(1, 2)
        v = v.transpose(1, 2)
        attn_scores = torch.matmul(q, k.transpose(-2, -1)) * self.scale
        if attention_mask is not None:
            attn_scores = attn_scores + attention_mask
        attn_probs = torch.softmax(attn_scores, dim=-1)
        attn_probs = self.attn_dropout(attn_probs)
        attn_output = torch.matmul(attn_probs, v)
        attn_output = attn_output.transpose(1, 2).contiguous().view(bsz, seq_len, -1)
        return self.o_proj(attn_output)


INIT_ARGS = {
    'hidden_size': 8,
    'num_heads': 2,
    'dropout': 0.1,
    'max_position_embeddings': 512,
}

ARGS = {
    'x': torch.randn(2, 3, 8),
    'attention_mask': None,
}
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 3, dtype family float, shape (2, 3, 8) — shape (2, 3, 8) 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)
LlamaMLP Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("2e7742a87c2d56e9")
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 3, dtype family float, shape (2, 3, 64) 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
from torch import nn
from torch.nn import functional as F

class LlamaMLP(nn.Module):

    def __init__(self, hidden_size, multiple_of=256, dropout=0.0):
        super().__init__()
        inner_size = int(2 * hidden_size * 4 / 3)
        inner_size = multiple_of * ((inner_size + multiple_of - 1) // multiple_of)
        self.gate_proj = nn.Linear(hidden_size, inner_size, bias=False)
        self.up_proj = nn.Linear(hidden_size, inner_size, bias=False)
        self.down_proj = nn.Linear(inner_size, hidden_size, bias=False)
        self.dropout = nn.Dropout(dropout)

    def forward(self, x):
        x = F.silu(self.gate_proj(x)) * self.up_proj(x)
        x = self.down_proj(x)
        return self.dropout(x)


INIT_ARGS = {
    'hidden_size': 64,
    'multiple_of': 256,
    'dropout': 0.1,
}

ARGS = {
    'x': torch.randn(2, 3, 64),
}

if __name__ == '__main__':
    model = LlamaMLP(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: {ARGS['x'].shape}")
    assert output.shape == ARGS['x'].shape, f"Shape mismatch: {output.shape} vs {ARGS['x'].shape}"
    print("Success!")
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 3, dtype family float, shape (2, 3, 64) — shape (2, 3, 64) 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)
MLPLayers Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("35d1051c6c69ed36")
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, 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 torch
from torch import nn
from torch.nn.init import xavier_normal_

def activation_layer(activation_name='relu', emb_dim=None):
    if activation_name is None:
        activation = None
    elif isinstance(activation_name, str):
        if activation_name.lower() == 'sigmoid':
            activation = nn.Sigmoid()
        elif activation_name.lower() == 'tanh':
            activation = nn.Tanh()
        elif activation_name.lower() == 'relu':
            activation = nn.ReLU()
        elif activation_name.lower() == 'leakyrelu':
            activation = nn.LeakyReLU()
        elif activation_name.lower() == 'none':
            activation = None
    elif issubclass(activation_name, nn.Module):
        activation = activation_name()
    else:
        raise NotImplementedError('activation function {} is not implemented'.format(activation_name))
    return activation

class MLPLayers(nn.Module):

    def __init__(self, layers, dropout=0.0, activation='relu', bn=False):
        super(MLPLayers, self).__init__()
        self.layers = layers
        self.dropout = dropout
        self.activation = activation
        self.use_bn = bn
        mlp_modules = []
        for idx, (input_size, output_size) in enumerate(zip(self.layers[:-1], self.layers[1:])):
            mlp_modules.append(nn.Dropout(p=self.dropout))
            mlp_modules.append(nn.Linear(input_size, output_size))
            if self.use_bn:
                mlp_modules.append(nn.BatchNorm1d(num_features=output_size))
            activation_func = activation_layer(self.activation, output_size)
            if activation_func is not None and idx != len(self.layers) - 2:
                mlp_modules.append(activation_func)
        self.mlp_layers = nn.Sequential(*mlp_modules)
        self.apply(self.init_weights)

    def init_weights(self, module):
        if isinstance(module, nn.Linear):
            xavier_normal_(module.weight.data)
            if module.bias is not None:
                module.bias.data.fill_(0.0)

    def forward(self, input_feature):
        return self.mlp_layers(input_feature)


INIT_ARGS = {
    'layers': [4, 3, 2],
    'dropout': 0.1,
    'activation': 'relu',
    'bn': False
}

ARGS = {
    'input_feature': torch.randn(2, 4)
}
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, 2) — shape (2, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RMSNorm Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("e90fe98be09c54bd")
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 3, dtype family float, shape (2, 3, 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
from torch import nn

class RMSNorm(nn.Module):

    def __init__(self, dim, eps=1e-06):
        super().__init__()
        self.weight = nn.Parameter(torch.ones(dim))
        self.eps = eps

    def forward(self, x):
        norm = x.norm(keepdim=True, dim=-1, p=2)
        rms = norm * norm / x.size(-1)
        return x * torch.rsqrt(rms + self.eps) * self.weight


INIT_ARGS = {
    'dim': 4,
    'eps': 1e-06
}

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

if __name__ == '__main__':
    model = RMSNorm(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Input shape: {ARGS['x'].shape}")
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{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 Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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)
ResidualVectorQuantizer Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("1dfac00b106cf47f")
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 numpy as np

# INIT_ARGS for ResidualVectorQuantizer.__init__
INIT_ARGS = {
    'codebook_num': 3,      # number of residual quantization layers
    'codebook_size': 8,     # number of embeddings per codebook
    'hidden_dim': 6,        # embedding dimension
    'mu': 0.25              # commitment loss weight
}

# ARGS for ResidualVectorQuantizer.forward
# Input shape: (batch_size, seq_len, hidden_dim)
# Must match hidden_dim=6 from INIT_ARGS
ARGS = {
    'x': torch.randn(2, 5, 6)  # batch=2, seq_len=5, hidden_dim=6
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RotaryEmbedding Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("0affb407d05e5940")
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, ndim 5, 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
from torch import nn

class RotaryEmbedding(nn.Module):

    def __init__(self, dim, base=10000, max_position_embeddings=4096):
        super().__init__()
        self.inv_freq = 1.0 / base ** (torch.arange(0, dim, 2).float() / dim)
        self.max_seq_len_cached = max_position_embeddings
        t = torch.arange(self.max_seq_len_cached, dtype=torch.float32)
        freqs = torch.einsum('i,j->ij', t, self.inv_freq)
        emb = torch.cat((freqs, freqs), dim=-1)
        self.register_buffer('cos_cached', emb.cos()[None, :, None, :], persistent=False)
        self.register_buffer('sin_cached', emb.sin()[None, :, None, :], persistent=False)

    def forward(self, x, seq_len):
        if seq_len > self.max_seq_len_cached:
            t = torch.arange(seq_len, device=x.device, dtype=torch.float32)
            freqs = torch.einsum('i,j->ij', t, self.inv_freq.to(x.device))
            emb = torch.cat((freqs, freqs), dim=-1)
            cos = emb.cos()[None, :, None, :]
            sin = emb.sin()[None, :, None, :]
        else:
            cos = self.cos_cached[:, :seq_len, :, :]
            sin = self.sin_cached[:, :seq_len, :, :]
        return (cos, sin)


INIT_ARGS = {
    'dim': 8,
    'base': 10000,
    'max_position_embeddings': 64
}

ARGS = {
    'x': torch.randn(2, 16, 3, 8),
    'seq_len': 32
}

if __name__ == '__main__':
    model = RotaryEmbedding(**INIT_ARGS)
    cos, sin = model(**ARGS)
    print(f"cos shape: {cos.shape}, sin shape: {sin.shape}")
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, ndim 5, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
VectorQuantizer Ran
ran on a synthesized input
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("26dc0a05c9ee3ead")
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
from torch import nn
from torch.nn import functional as F

class VectorQuantizer(nn.Module):

    def __init__(self, n_e, e_dim, mu=0.25):
        super().__init__()
        self.n_e = n_e
        self.e_dim = e_dim
        self.mu = mu
        self.embedding = nn.Embedding(self.n_e, self.e_dim)
        self.embedding.weight.data.uniform_(-1.0 / self.n_e, 1.0 / self.n_e)

    def get_codebook(self):
        return self.embedding.weight

    def vq_initialization(self, x):
        latent = x.view(-1, self.e_dim)
        d = torch.sum(latent ** 2, dim=1, keepdim=True) + torch.sum(self.embedding.weight ** 2, dim=1, keepdim=True).t() - 2 * torch.matmul(latent, self.embedding.weight.t())
        indices = torch.argmin(d, dim=-1)
        x_q = self.embedding(indices).view(x.shape)
        return x_q

    def forward(self, x):
        latent = x.view(-1, self.e_dim)
        d = torch.sum(latent ** 2, dim=1, keepdim=True) + torch.sum(self.embedding.weight ** 2, dim=1, keepdim=True).t() - 2 * torch.matmul(latent, self.embedding.weight.t())
        indices = torch.argmin(d, dim=-1)
        x_q = self.embedding(indices).view(x.shape)
        commitment_loss = F.mse_loss(x_q.detach(), x)
        codebook_loss = F.mse_loss(x_q, x.detach())
        loss = codebook_loss + self.mu * commitment_loss
        x_q = x + (x_q - x).detach()
        indices = indices.view(x.shape[:-1])
        return (x_q, loss, indices)


INIT_ARGS = {
    'n_e': 8,
    'e_dim': 4,
    'mu': 0.25
}

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

if __name__ == '__main__':
    vq = VectorQuantizer(**INIT_ARGS)
    x_q, loss, indices = vq(**ARGS)
    print(f"x_q shape: {x_q.shape}")
    print(f"loss: {loss}")
    print(f"indices shape: {indices.shape}")
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)
apply_rotary_pos_emb Ran
ran; our contract draft was wrong, not the code
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("b0bb9cd4b9fd6357")
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) and returned tuple, ndim 4, 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

torch.manual_seed(0)

# Create small tensors for q and k
# Shape: (batch=2, seq_len=3, dim=4)
q = torch.randn(2, 3, 4)
k = torch.randn(2, 3, 4)

# Create cos and sin tensors for rotary embeddings
# Shape: (batch=2, seq_len=3, dim=4)
cos = torch.randn(2, 3, 4)
sin = torch.randn(2, 3, 4)

ARGS = {
    "q": q,
    "k": k,
    "cos": cos,
    "sin": sin,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 4, 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
contrastive_cluster_loss Ran
ran; our contract draft was wrong, not the code
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("9e4e85620100bded")
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) 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.functional as F

torch.manual_seed(0)

# Construct arguments for contrastive_cluster_loss
# The function expects:
# - token_embed: tensor of shape (batch_size, embedding_dim)
# - cluster_emb: tensor of shape (num_clusters, embedding_dim)
# - temperature: float (default 0.1)

batch_size = 2
embedding_dim = 4
num_clusters = 3

token_embed = torch.randn(batch_size, embedding_dim)
cluster_emb = torch.randn(num_clusters, embedding_dim)
temperature = 0.1

ARGS = {
    "token_embed": token_embed,
    "cluster_emb": cluster_emb,
    "temperature": temperature,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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
exponential_decay_sum Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("2a2508ee30f69cc4")
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) and returned Tensor, ndim 1, dtype family float, shape (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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - x: iterable that supports reversed() and len(), contains numeric values
# - base_lambda: numeric scalar for exponential decay
# - reverse: boolean flag
# The function iterates through x, applies exponential weights, and returns weighted average

# Create a small tensor as x (batch of 2, dimension 4)
x = torch.randn(2, 4)

# base_lambda: a numeric scalar for the exponential decay
base_lambda = 0.9

# reverse: boolean flag
reverse = False

ARGS = {
    "x": x,
    "base_lambda": base_lambda,
    "reverse": reverse,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 1, dtype family float, shape (4,) — shape (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: none by the harness; any seed is in the setup block
LlamaDecoder Not yet run
unverified (harvested, no recorded run)
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("b716a4a0e4c81707")
How it ran

no invocation recorded.

LlamaDecoderLayer Not yet run
unverified (harvested, no recorded run)
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("cf440bb46ec93bf7")
How it ran

no invocation recorded.

RQVAE Not yet run
unverified (harvested, no recorded run)
mikumifa/GS-Quant/codebook/rqvae.py
code served (permissive licence) · get_code("5f26ee937c2837ba")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 13 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.

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

Large Language Models (LLMs) have shown immense potential in Knowledge Graph Completion (KGC), yet bridging the modality gap between continuous graph embeddings and discrete LLM tokens remains a critical challenge. While recent quantization-based approaches attempt to align these modalities, they typically treat quantization as flat numerical compression, resulting in semantically entangled codes that fail to mirror the hierarchical nature of human reasoning. In this paper, we propose GS-Quant, a novel framework that generates semantically coherent and structurally stratified discrete codes for KG entities. Unlike prior methods, GS-Quant is grounded in the insight that entity representations should follow a linguistic coarse-to-fine logic. We introduce a Granular Semantic Enhancement module that injects hierarchical knowledge into the codebook, ensuring that earlier codes capture global semantic categories while later codes refine specific attributes. Furthermore, a Generative Structural Reconstruction module imposes causal dependencies on the code sequence, transforming independent discrete units into structured semantic descriptors. By expanding the LLM vocabulary with these learned codes, we enable the model to reason over graph structures isomorphically to natural language generation. Experimental results demonstrate that GS-Quant significantly outperforms existing text-based and embedding-based baselines. Our code is publicly available at https: //github.com/mikumifa/GS-Quant.

For agents

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

get_harvested_code_for_paper("2604.21649")
get_code_for_paper("2604.21649")
have("2604.21649")

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

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

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

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

Connect an agent — have() is free.