SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.01915 · 2022

Generalized Knowledge Distillation via Relationship Matching

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 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 3 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2205.01915.json · badge: /api/ran/2205.01915.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
njulus/gkd canonical (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
FunctionStatusWhere it lives
generate_data_loader Ran
ran on a synthesized input
njulus/gkd/dataloaders/CIFAR-100.py
code served (permissive licence) · get_code("12613d226cd56110")
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 DataLoader. 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 pickle
import numpy as np
import tempfile
import os
from PIL import Image

# Create a temporary directory for mock data
temp_dir = tempfile.mkdtemp()
data_path = temp_dir + '/'

# Create mock train and test pickle files
def create_mock_cifar_file(filepath, num_samples=10):
    """Create a mock CIFAR-like pickle file"""
    # Each image is 32x32 with 3 channels = 3072 bytes
    data = np.random.randint(0, 256, (num_samples, 3072), dtype=np.uint8)
    labels = np.random.randint(0, 5, num_samples, dtype=np.uint8)
    
    pickle_data = {
        b'data': data,
        b'fine_labels': labels
    }
    
    with open(filepath, 'wb') as f:
        pickle.dump(pickle_data, f)

# Create train and test files
create_mock_cifar_file(os.path.join(temp_dir, 'train'), num_samples=20)
create_mock_cifar_file(os.path.join(temp_dir, 'test'), num_samples=10)

# Create a mock label_q.npy file
# This maps original class indices to positions
label_q = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.int64)
np.save(os.path.join(temp_dir, 'label_q.npy'), label_q)

ARGS = {
    'data_path': data_path,
    'flag_mode': 'train',
    'n_classes': 3,
    'n_new_classes': 2,
    'batch_size': 2,
    'n_workers': 0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
generate_data_loader Ran
ran on a synthesized input
njulus/gkd/dataloaders/CUB-200.py
code served (permissive licence) · get_code("63db6fc998ee2920")
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 DataLoader. 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 pickle
import numpy as np
import tempfile
import os
from PIL import Image

# Create a temporary directory and mock data files
temp_dir = tempfile.mkdtemp()
data_path = temp_dir + '/'

# Create mock train data file
train_data = {
    'features': np.random.randint(0, 255, (20, 224, 224, 3), dtype=np.uint8),
    'labels': np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3])
}
with open(data_path + 'train', 'wb') as f:
    pickle.dump(train_data, f)

# Create mock test data file
test_data = {
    'features': np.random.randint(0, 255, (10, 224, 224, 3), dtype=np.uint8),
    'labels': np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1])
}
with open(data_path + 'test', 'wb') as f:
    pickle.dump(test_data, f)

# Create mock label_q.npy file
# This should map to indices that allow filtering in read_data
# We need positions >= n_new_classes and < n_classes + n_new_classes
# With n_new_classes=2 and n_classes=4, we need positions in [2, 6)
label_q = np.array([10, 11, 0, 1, 2, 3])  # 6 unique labels, indices 2-5 map to labels 0-3
np.save(data_path + 'label_q.npy', label_q)

# Update train_data labels to match the label_q indices
train_data = {
    'features': np.random.randint(0, 255, (20, 224, 224, 3), dtype=np.uint8),
    'labels': np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3])
}
with open(data_path + 'train', 'wb') as f:
    pickle.dump(train_data, f)

test_data = {
    'features': np.random.randint(0, 255, (10, 224, 224, 3), dtype=np.uint8),
    'labels': np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1])
}
with open(data_path + 'test', 'wb') as f:
    pickle.dump(test_data, f)

ARGS = {
    'data_path': data_path,
    'flag_mode': 'train',
    'n_classes': 4,
    'n_new_classes': 2,
    'batch_size': 2,
    'n_workers': 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
merge Ran
ran on a synthesized input
njulus/gkd/utils/triplet.py
code served (permissive licence) · get_code("8fa985d609627f85")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)

class Args:
    def __init__(self):
        self.batch_size = 2
        self.devices = [0]

# Create small tensors with distinct dimensions
batch_size = 2
n_anchors = 3
n_positives = 4
n_negatives_total = 6

anchor_id = torch.randint(0, n_anchors, (5,))
positive_id = torch.randint(0, n_positives, (5,))
negative_id = torch.randint(0, 10, (5,))

args = Args()

ARGS = {
    "args": args,
    "anchor_id": anchor_id,
    "positive_id": positive_id,
    "negative_id": negative_id,
}
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 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

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 2 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 2 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

The knowledge of a well-trained deep neural network (a.k.a. the "teacher") is valuable for learning similar tasks. Knowledge distillation extracts knowledge from the teacher and integrates it with the target model (a.k.a. the "student"), which expands the student's knowledge and improves its learning efficacy. Instead of enforcing the teacher to work on the same task as the student, we borrow the knowledge from a teacher trained from a general label space -- in this "Generalized Knowledge Distillation (GKD)", the classes of the teacher and the student may be the same, completely different, or partially overlapped. We claim that the comparison ability between instances acts as an essential factor threading knowledge across tasks, and propose the RElationship FacIlitated Local cLassifiEr Distillation (REFILLED) approach, which decouples the GKD flow of the embedding and the top-layer classifier. In particular, different from reconciling the instance-label confidence between models, REFILLED requires the teacher to reweight the hard tuples pushed forward by the student and then matches the similarity comparison levels between instances. An embedding-induced classifier based on the teacher model supervises the student's classification confidence and adaptively emphasizes the most related supervision from the teacher. REFILLED demonstrates strong discriminative ability when the classes of the teacher vary from the same to a fully non-overlapped set w.r.t. the student. It also achieves state-of-the-art performance on standard knowledge distillation, one-step incremental learning, and few-shot learning tasks.

For agents

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

get_harvested_code_for_paper("2205.01915")
get_code_for_paper("2205.01915")
have("2205.01915")

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

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

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

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

Connect an agent — have() is free.