SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.05328 · 2023

Invariant Collaborative Filtering to Popularity Distribution Shift

arXiv · PDF · Open in the Atlas

Code that ran

8 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; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 5 failures of our instrument; 0 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/2302.05328.json · badge: /api/ran/2302.05328.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
anzhang314/invcf canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
clean Ran
ran on a synthesized input
anzhang314/invcf/local_compile_setup.py
code served (permissive licence) · get_code("92cd1d2e73d2a51b")
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 function. 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 os
import shutil
import tempfile
from functools import wraps

def clean(func):
    """clean intermediate file
    """

    @wraps(func)
    def wrapper(*args, **kwargs):

        def _clean_file():
            new_dirs = set()
            new_files = set()
            for root, dirs, files in os.walk('.'):
                new_dirs.update([os.path.join(root, d) for d in dirs])
                new_files.update([os.path.join(root, f) for f in files])
            for new_dir in new_dirs:
                if os.path.exists(new_dir) and new_dir not in old_dirs and ('dist' not in new_dir.split(os.path.sep)):
                    shutil.rmtree(new_dir)
            for new_file in new_files:
                if os.path.exists(new_file) and new_file not in old_files and (not new_file.endswith('so')) and (not new_file.endswith('pyd')):
                    os.remove(new_file)
        old_dirs = set()
        old_files = set()
        for root, dirs, files in os.walk('.'):
            old_dirs.update([os.path.join(root, d) for d in dirs])
            old_files.update([os.path.join(root, f) for f in files])
        try:
            result = func(*args, **kwargs)
        except Exception as e:
            _clean_file()
            raise e
        _clean_file()
        return result
    return wrapper

# Create a simple test function to decorate
@clean
def sample_function(x, y=10):
    """A simple function to test the clean decorator"""
    return x + y

ARGS = {
    'func': sample_function
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
get_extensions Ran
ran on a synthesized input
anzhang314/invcf/local_compile_setup.py
code served (permissive licence) · get_code("b870a0c9899a893a")
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, 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 tempfile
import shutil

# Create a temporary workspace directory with a sample .pyx file
workspace = tempfile.mkdtemp()

# Create a subdirectory structure
subdir = os.path.join(workspace, 'mypackage', 'submodule')
os.makedirs(subdir, exist_ok=True)

# Create sample .pyx files
pyx_file_1 = os.path.join(workspace, 'mypackage', 'module1.pyx')
with open(pyx_file_1, 'w') as f:
    f.write('# cython code\n')

pyx_file_2 = os.path.join(subdir, 'module2.pyx')
with open(pyx_file_2, 'w') as f:
    f.write('# cython code\n')

ARGS = {
    'workspace': workspace
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
distutils — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
get_include_dirs Ran
ran on a synthesized input
anzhang314/invcf/local_compile_setup.py
code served (permissive licence) · get_code("4443f98d2547d286")
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, 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 tempfile
import numpy as np

# Create a temporary directory with some header files
temp_workspace = tempfile.mkdtemp()

# Create a subdirectory structure with header files
os.makedirs(os.path.join(temp_workspace, "include"), exist_ok=True)
os.makedirs(os.path.join(temp_workspace, "src", "headers"), exist_ok=True)

# Create some dummy header files
with open(os.path.join(temp_workspace, "include", "header1.h"), "w") as f:
    f.write("// dummy header\n")

with open(os.path.join(temp_workspace, "include", "header2.hpp"), "w") as f:
    f.write("// dummy header\n")

with open(os.path.join(temp_workspace, "src", "headers", "header3.h"), "w") as f:
    f.write("// dummy header\n")

# Create a non-header file that should be ignored
with open(os.path.join(temp_workspace, "src", "source.cpp"), "w") as f:
    f.write("// dummy source\n")

ARGS = {
    "workspace": temp_workspace
}
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 list, ndim 1, dtype family float — a list 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
helper_load Ran
ran; our contract draft was wrong, not the code
anzhang314/invcf/data.py
pointer only (licence: MIT); the stored copy get_code serves, from lehengthu/alpharec, is pointer only (licence: NONE) · get_code("029327c4f6fb55d0")
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 lehengthu/alpharec, 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.

helper_load_train Ran
ran; our contract draft was wrong, not the code
anzhang314/invcf/data.py
pointer only (licence: MIT); the stored copy get_code serves, from lehengthu/alpharec, is pointer only (licence: NONE) · get_code("f1fe817c737b6fed")
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 lehengthu/alpharec, 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.

merge_user_list Ran
ran; our contract draft was wrong, not the code
anzhang314/invcf/main_synthetic.py
code served (permissive licence) · get_code("7513663e5a710c16")
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 defaultdict. 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 collections

# Analyze the function: merge_user_list takes user_lists parameter
# It iterates over user_lists, and for each user_list:
#   - iterates over items() (so each element is dict-like)
#   - accesses key and item from the dict
#   - concatenates item to out[key] using + operator (so items are lists)

# Create sample user_lists - a list of dicts where values are lists
user_list_1 = {
    'user_a': [1, 2, 3],
    'user_b': [4, 5]
}

user_list_2 = {
    'user_a': [6, 7],
    'user_c': [8, 9, 10]
}

user_list_3 = {
    'user_b': [11],
    'user_c': [12]
}

user_lists = [user_list_1, user_list_2, user_list_3]

ARGS = {
    'user_lists': user_lists
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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_user_list_no_dup Ran
ran; our contract draft was wrong, not the code
anzhang314/invcf/main_synthetic.py
code served (permissive licence) · get_code("63bb511f56afa437")
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 defaultdict. 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 collections

# Analyze the function:
# - Takes user_lists as parameter
# - Iterates over user_lists (so it's iterable)
# - Each element (user_list) is a dict with .items()
# - Each item is (key, item) where item is something that can be added to a list
# - The values are converted to sets and back to lists (so they should be hashable)

# Create sample data matching the function's usage
user_list_1 = {
    'user_a': [1, 2, 3],
    'user_b': [4, 5],
}

user_list_2 = {
    'user_a': [2, 3, 6],
    'user_c': [7, 8],
}

user_list_3 = {
    'user_b': [5, 9],
    'user_a': [1],
}

user_lists = [user_list_1, user_list_2, user_list_3]

ARGS = {
    'user_lists': user_lists,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
save_checkpoint Ran
ran; our contract draft was wrong, not the code
anzhang314/invcf/main_synthetic.py
code served (permissive licence) · get_code("380a5cea5655f733")
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 list, 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 torch
import torch.nn as nn
import tempfile
import os

torch.manual_seed(0)

# Create a minimal model that has state_dict() method
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create temporary directory for checkpoints
checkpoint_dir = tempfile.mkdtemp()

# Create model instance
model = MinimalModel()

# Create buffer list to track checkpoint filenames
buffer = []

# Define arguments
ARGS = {
    'model': model,
    'epoch': 1,
    'checkpoint_dir': checkpoint_dir,
    'buffer': buffer,
    'max_to_keep': 10
}
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 list, ndim 1, dtype family float — a list 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

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, 5 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 5 later) and 3 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
helper_load_train 5 other papers
1 dated earlier, 4 later
2210.11054 (2022-10)
Incorporating Bias-aware Margins into Contrastive Loss for Collaborative Filtering
2310.10108 (2023-10)
On Generative Agents in Recommendation
2310.10696 (2023-10)
Robust Collaborative Filtering to Popularity Distribution Shift
and 2 more not named here
helper_load 4 other papers
1 dated earlier, 3 later
2210.11054 (2022-10)
Incorporating Bias-aware Margins into Contrastive Loss for Collaborative Filtering
2310.10108 (2023-10)
On Generative Agents in Recommendation
2310.18700 (2023-10)
Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss
and 1 more not named here
merge_user_list 1 other paper
1 later
2310.18700 (2023-10)
Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss
merge_user_list_no_dup 1 other paper
1 later
2310.18700 (2023-10)
Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss
save_checkpoint 1 other paper
1 later
2310.18700 (2023-10)
Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss

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

Collaborative Filtering (CF) models, despite their great success, suffer from severe performance drops due to popularity distribution shifts, where these changes are ubiquitous and inevitable in real-world scenarios. Unfortunately, most leading popularity debiasing strategies, rather than tackling the vulnerability of CF models to varying popularity distributions, require prior knowledge of the test distribution to identify the degree of bias and further learn the popularity-entangled representations to mitigate the bias. Consequently, these models result in significant performance benefits in the target test set, while dramatically deviating the recommendation from users' true interests without knowing the popularity distribution in advance. In this work, we propose a novel learning framework, Invariant Collaborative Filtering (InvCF), to discover disentangled representations that faithfully reveal the latent preference and popularity semantics without making any assumption about the popularity distribution. At its core is the distillation of unbiased preference representations (i.e., user preference on item property), which are invariant to the change of popularity semantics, while filtering out the popularity feature that is unstable or outdated. Extensive experiments on five benchmark datasets and four evaluation settings (i.e., synthetic long-tail, unbiased, temporal split, and out-of-distribution evaluations) demonstrate that InvCF outperforms the state-of-the-art baselines in terms of popularity generalization ability on real recommendations. Visualization studies shed light on the advantages of InvCF for disentangled representation learning. Our codes are available at https://github.com/anzhang314/InvCF.

For agents

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

get_harvested_code_for_paper("2302.05328")
get_code_for_paper("2302.05328")
have("2302.05328")

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

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

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

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

Connect an agent — have() is free.