Hi there,
I’m having an issue with the _neg_sample function in transform.MaskItemSequence.
My dataset contains around 197,000 unique users but only 10 unique items. Unfortunately, when I set MAX_ITEM_LIST_LENGTH to 50 or 100, the code sometimes encounters a user with more than 100 interactions — and their last 100 interactions include all possible item IDs. As a result, the function ends up looping forever while trying to find a negative sample that isn’t in the user’s item set.
I also tried setting train_neg_sample_args to None, but the function still gets called during BERT4Rec training.
As a temporary fix, I modified _neg_sample so that if it fails to find a negative sample after 100 attempts, it returns [PAD] (i.e., 0).
Would this be considered an acceptable workaround for my situation?
Thanks,
Osman