SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.07192 · 2023

gSASRec: Reducing Overconfidence in Sequential Recommendation Trained with Negative Sampling

arXiv · PDF · Open in the Atlas

Code that ran

7 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, 1 violated it and 3 have no contract verdict; 2 failures of our instrument; 1 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/2308.07192.json · badge: /api/ran/2308.07192.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
asash/gsasrec canonical (classifier label)
classifier basis: classifier_2025
4 ran · 1 no recorded run
asash/gsasrec-pytorch community (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
FunctionStatusWhere it lives
collate_val_test Ran
ran on a synthesized input
asash/gsasrec-pytorch/dataset_utils.py
code served (permissive licence) · get_code("61aa1a96b85940bd")
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)

# The function expects input_batch to be a list of tuples
# Each tuple contains: (input_tensor, rated_value, output_tensor)
# The function stacks the inputs and outputs, and collects the rated values into a list

input_batch = [
    (torch.randn(4, 3), True, torch.randn(4, 5)),
    (torch.randn(4, 3), False, torch.randn(4, 5)),
]

ARGS = {
    "input_batch": input_batch,
}
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
collate_with_random_negatives Ran
ran on a synthesized input
asash/gsasrec-pytorch/dataset_utils.py
code served (permissive licence) · get_code("7eab2ae2aa929824")
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)

# Construct input_batch: a list of tuples where each tuple contains a tensor
# The function accesses input_batch[i][0] and stacks them
# We need batch_size=2 items, each with a tensor of shape (4, 3)
input_batch = [
    (torch.randn(4, 3),),  # First batch item
    (torch.randn(4, 3),),  # Second batch item
]

# pad_value: used as the high bound in torch.randint
# Should be larger than 1 (the low bound)
pad_value = 10

# num_negatives: the number of negative samples per position
num_negatives = 5

ARGS = {
    "input_batch": input_batch,
    "pad_value": pad_value,
    "num_negatives": num_negatives,
}
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
get_max_test_users Ran
ran, honoured the contract we drafted
asash/gsasrec/evaluation/run_experiment.py
code served (permissive licence) · get_code("81e3e95accb45fcd")
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 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 sys
import tempfile
from pathlib import Path

# Create a minimal config module
class MockConfig:
    def __init__(self, has_max_test_users=False):
        self.DATASET = "test_dataset"
        if has_max_test_users:
            self.MAX_TEST_USERS = 500
        self.out_file = sys.stdout
        self.out_dir = tempfile.mkdtemp()
        self.global_tensorboard_dir = Path(tempfile.mkdtemp())

# Test case 1: config with MAX_TEST_USERS attribute
config_with_max = MockConfig(has_max_test_users=True)

# Test case 2: config without MAX_TEST_USERS attribute
config_without_max = MockConfig(has_max_test_users=False)

ARGS = {
    "config": config_with_max
}
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 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
get_metrics Ran
ran; our contract draft was wrong, not the code
asash/gsasrec/evaluation/analyze_experiment_in_progress.py
code served (permissive licence) · get_code("455c95e4d2eb8300")
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 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 re

def get_metrics(line):
    regexp = re.compile('[a-zA-Z0-9_]+\\: [0-9\\.\\+\\-eE]+')
    result = {}
    for metric_str in regexp.findall(line):
        metric, value = metric_str.split(': ')
        result[metric] = float(value)
    return result

# The function takes a single parameter: line (a string)
# It uses regex to find metric patterns and parse them
# Valid metric strings contain alphanumeric characters and underscores,
# followed by ': ' and a number (including scientific notation)

ARGS = {
    'line': 'loss: 0.5 accuracy: 0.95 learning_rate: 1e-3 val_loss: 0.42'
}
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 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
get_num_items Ran
ran on a synthesized input
asash/gsasrec-pytorch/dataset_utils.py
code served (permissive licence) · get_code("df8bda213ff3826a")
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 os
import json
import tempfile

# Create a temporary directory structure for the dataset
temp_dir = tempfile.mkdtemp()
dataset_dir = os.path.join(temp_dir, 'datasets', 'test_dataset')
os.makedirs(dataset_dir, exist_ok=True)

# Create a valid dataset_stats.json file
stats = {
    'num_items': 1000
}
stats_file = os.path.join(dataset_dir, 'dataset_stats.json')
with open(stats_file, 'w') as f:
    json.dump(stats, f)

# Change to temp directory so the relative path works
original_cwd = os.getcwd()
os.chdir(temp_dir)

ARGS = {
    'dataset': 'test_dataset'
}
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 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
is_experiment_start Ran
ran, violated the contract we drafted
asash/gsasrec/evaluation/analyze_experiment_in_progress.py
code served (permissive licence) · get_code("90f30c1ba3ef9bf4")
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 bool, 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

def is_experiment_start(line):
    return line.startswith('evaluating for')

ARGS = {
    'line': 'evaluating for epoch 1'
}
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 bool, 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
parse_experiment Ran
ran; our contract draft was wrong, not the code
asash/gsasrec/evaluation/analyze_experiment_in_progress.py
code served (permissive licence) · get_code("d2263417dafdd010")
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 json
import re

def get_metrics(line):
    regexp = re.compile('[a-zA-Z0-9_]+\\: [0-9\\.\\+\\-eE]+')
    result = {}
    for metric_str in regexp.findall(line):
        metric, value = metric_str.split(': ')
        result[metric] = float(value)
    return result

def parse_experiment(experiment_log):
    current_recommender = None
    result = []
    cnt = 0
    metrics = []
    experiment_finished = True
    for line in experiment_log:
        if line.startswith('evaluating ') or line.startswith('!!!!!!!!!   evaluating'):
            current_recommender = line.split(' ')[-1]
            metrics = []
            experiment_finished = False
            epoch = 0
        if 'val_ndcg_at_' in line or 'val_ndcg@' in line:
            epoch += 1
            epoch_metrics = get_metrics(line)
            epoch_metrics['epoch'] = epoch
        try:
            experiment_results = json.loads(line)
            experiment_results['model_name'] = current_recommender
            experiment_results['num_epochs'] = epoch
            experiment_results['metrics_history'] = metrics
            result.append(experiment_results)
            experiment_finished = True
        except:
            pass
    if not experiment_finished:
        experiment_results = {}
        experiment_results['model_name'] = current_recommender
        experiment_results['metrics_history'] = metrics
        experiment_results['num_epochs'] = epoch
        result.append(experiment_results)
    return result


# Setup code to construct valid arguments
experiment_log = [
    "evaluating ModelA",
    "val_ndcg_at_10: 0.85 val_ndcg_at_20: 0.82",
    "val_ndcg@5: 0.88 val_ndcg@10: 0.85",
    '{"accuracy": 0.92, "loss": 0.15}',
    "evaluating ModelB",
    "val_ndcg_at_10: 0.87 val_ndcg_at_20: 0.84",
]

ARGS = {
    "experiment_log": experiment_log
}
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 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_global_tensorboard_dir Not yet run
unverified (harvested, no recorded run)
asash/gsasrec/evaluation/run_experiment.py
code served (permissive licence) · get_code("c77b2756000b5584")
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_max_test_users 1 other paper
1 dated earlier
2207.07483 (2022-07)
A Systematic Review and Replicability Study of BERT4Rec for Sequential Recommendation
get_metrics 1 other paper
1 dated earlier
2207.07483 (2022-07)
A Systematic Review and Replicability Study of BERT4Rec for Sequential Recommendation
is_experiment_start 1 other paper
1 dated earlier
2207.07483 (2022-07)
A Systematic Review and Replicability Study of BERT4Rec for Sequential 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

A large catalogue size is one of the central challenges in training recommendation models: a large number of items makes them memory and computationally inefficient to compute scores for all items during training, forcing these models to deploy negative sampling. However, negative sampling increases the proportion of positive interactions in the training data, and therefore models trained with negative sampling tend to overestimate the probabilities of positive interactions a phenomenon we call overconfidence. While the absolute values of the predicted scores or probabilities are not important for the ranking of retrieved recommendations, overconfident models may fail to estimate nuanced differences in the top-ranked items, resulting in degraded performance. In this paper, we show that overconfidence explains why the popular SASRec model underperforms when compared to BERT4Rec. This is contrary to the BERT4Rec authors explanation that the difference in performance is due to the bi-directional attention mechanism. To mitigate overconfidence, we propose a novel Generalised Binary Cross-Entropy Loss function (gBCE) and theoretically prove that it can mitigate overconfidence. We further propose the gSASRec model, an improvement over SASRec that deploys an increased number of negatives and the gBCE loss. We show through detailed experiments on three datasets that gSASRec does not exhibit the overconfidence problem. As a result, gSASRec can outperform BERT4Rec (e.g. +9.47% NDCG on the MovieLens-1M dataset), while requiring less training time (e.g. -73% training time on MovieLens-1M). Moreover, in contrast to BERT4Rec, gSASRec is suitable for large datasets that contain more than 1 million items.

For agents

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

get_harvested_code_for_paper("2308.07192")
get_code_for_paper("2308.07192")
have("2308.07192")

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

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

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

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

Connect an agent — have() is free.