{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/empowering-collaborative-filtering-with","title":"Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss","arxiv_id":"2310.18700","date":"2023-10-28","proceeding":"NeurIPS 2023 11","authors":["An Zhang","Leheng Sheng","Zhibo Cai","Xiang Wang","Tat-Seng Chua"],"abstract":"Contrastive Learning (CL) has achieved impressive performance in self-supervised learning tasks, showing superior generalization ability. Inspired by the success, adopting CL into collaborative filtering (CF) is prevailing in semi-supervised top-K recommendations. The basic idea is to routinely conduct heuristic-based data augmentation and apply contrastive losses (e.g., InfoNCE) on the augmented views. Yet, some CF-tailored challenges make this adoption suboptimal, such as the issue of out-of-distribution, the risk of false negatives, and the nature of top-K evaluation. They necessitate the CL-based CF scheme to focus more on mining hard negatives and distinguishing false negatives from the vast unlabeled user-item interactions, for informative contrast signals. Worse still, there is limited understanding of contrastive loss in CF methods, especially w.r.t. its generalization ability. To bridge the gap, we delve into the reasons underpinning the success of contrastive loss in CF, and propose a principled Adversarial InfoNCE loss (AdvInfoNCE), which is a variant of InfoNCE, specially tailored for CF methods. AdvInfoNCE adaptively explores and assigns hardness to each negative instance in an adversarial fashion and further utilizes a fine-grained hardness-aware ranking criterion to empower the recommender's generalization ability. Training CF models with AdvInfoNCE, we validate the effectiveness of AdvInfoNCE on both synthetic and real-world benchmark datasets, thus showing its generalization ability to mitigate out-of-distribution problems. Given the theoretical guarantees and empirical superiority of AdvInfoNCE over most contrastive loss functions, we advocate its adoption as a standard loss in recommender systems, particularly for the out-of-distribution tasks. Codes are available at https://github.com/LehengTHU/AdvInfoNCE.","url_abs":"https://arxiv.org/abs/2310.18700v1","url_pdf":"https://arxiv.org/pdf/2310.18700v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"empowering-collaborative-filtering-with","repo_url":"https://github.com/lehengthu/advinfonce","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"collaborative-filtering","task_name":"Collaborative Filtering"},{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"data-augmentation","task_name":"Data Augmentation"},{"task_slug":"recommendation-systems","task_name":"Recommendation Systems"},{"task_slug":"self-supervised-learning","task_name":"Self-Supervised Learning"}],"methods":[{"method_slug":"focus","method_name":"Focus"},{"method_slug":"infonce","method_name":"InfoNCE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.18700","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.18700"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/LehengTHU/AdvInfoNCE","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lehengthu/advinfonce","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"ran_draft_wrong":3,"unverified":1},"by_repo_kind":{"official":{"samples":8,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"cf3edb57afbf264e","entry":"AdvInfoNCE","repo":"lehengthu/advinfonce","repo_kind":"official","path":"model.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cf3edb57afbf264e"}},{"code_sha256_prefix":"d08e6a8f2f8b1da8","entry":"MF","repo":"lehengthu/advinfonce","repo_kind":"official","path":"model.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d08e6a8f2f8b1da8"}},{"code_sha256_prefix":"029327c4f6fb55d0","entry":"helper_load","repo":"LehengTHU/AdvInfoNCE","repo_kind":"official","path":"data.py","file_url":"https://github.com/LehengTHU/AdvInfoNCE/blob/HEAD/data.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"029327c4f6fb55d0"}},{"code_sha256_prefix":"f1fe817c737b6fed","entry":"helper_load_train","repo":"LehengTHU/AdvInfoNCE","repo_kind":"official","path":"data.py","file_url":"https://github.com/LehengTHU/AdvInfoNCE/blob/HEAD/data.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f1fe817c737b6fed"}},{"code_sha256_prefix":"7513663e5a710c16","entry":"merge_user_list","repo":"lehengthu/advinfonce","repo_kind":"official","path":"train_AdvInfoNCE.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/train_AdvInfoNCE.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7513663e5a710c16"}},{"code_sha256_prefix":"63bb511f56afa437","entry":"merge_user_list_no_dup","repo":"lehengthu/advinfonce","repo_kind":"official","path":"train_AdvInfoNCE.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/train_AdvInfoNCE.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"63bb511f56afa437"}},{"code_sha256_prefix":"380a5cea5655f733","entry":"save_checkpoint","repo":"lehengthu/advinfonce","repo_kind":"official","path":"train_AdvInfoNCE.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/train_AdvInfoNCE.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"380a5cea5655f733"}},{"code_sha256_prefix":"6cab2d4c2ffaeb32","entry":"LGN","repo":"lehengthu/advinfonce","repo_kind":"official","path":"model.py","file_url":"https://github.com/lehengthu/advinfonce/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6cab2d4c2ffaeb32"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}