{"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/max-margin-contrastive-learning","title":"Max-Margin Contrastive Learning","arxiv_id":"2112.11450","date":"2021-12-21","proceeding":null,"authors":["Anshul Shah","Suvrit Sra","Rama Chellappa","Anoop Cherian"],"abstract":"Standard contrastive learning approaches usually require a large number of negatives for effective unsupervised learning and often exhibit slow convergence. We suspect this behavior is due to the suboptimal selection of negatives used for offering contrast to the positives. We counter this difficulty by taking inspiration from support vector machines (SVMs) to present max-margin contrastive learning (MMCL). Our approach selects negatives as the sparse support vectors obtained via a quadratic optimization problem, and contrastiveness is enforced by maximizing the decision margin. As SVM optimization can be computationally demanding, especially in an end-to-end setting, we present simplifications that alleviate the computational burden. We validate our approach on standard vision benchmark datasets, demonstrating better performance in unsupervised representation learning over state-of-the-art, while having better empirical convergence properties.","url_abs":"https://arxiv.org/abs/2112.11450v1","url_pdf":"https://arxiv.org/pdf/2112.11450v1.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":"max-margin-contrastive-learning","repo_url":"https://github.com/anshulbshah/MMCL","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"self-supervised-image-classification","task_name":"Self-Supervised Image Classification"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"},{"method_slug":"svm","method_name":"SVM"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/self-supervised-image-classification-on","task":"Self-Supervised Image Classification","dataset":"ImageNet","model":"MMCL (100 epoch, 256 batch size)","rank_in_archive_order":116,"of":144,"metrics":{"Top 1 Accuracy":"63.8%"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2112.11450","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2112.11450"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/anshulbshah/MMCL","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":1,"ran_honours":1,"unverified":10},"by_repo_kind":{"official":{"samples":12,"ran":2,"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":"11bc56dd2ecb7644","entry":"accuracy","repo":"anshulbshah/MMCL","repo_kind":"official","path":"models/losses.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/models/losses.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":"11bc56dd2ecb7644"}},{"code_sha256_prefix":"7337f1f5ff01dcd0","entry":"get_lr","repo":"anshulbshah/MMCL","repo_kind":"official","path":"CIFAR100/linear.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/CIFAR100/linear.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7337f1f5ff01dcd0"}},{"code_sha256_prefix":"9498c0875cc30496","entry":"compute_kernel","repo":"anshulbshah/MMCL","repo_kind":"official","path":"models/losses.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/models/losses.py","link_basis":"harvester_set","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":"9498c0875cc30496"}},{"code_sha256_prefix":"5fa7bb56e6e22a54","entry":"compute_kernel_new","repo":"anshulbshah/MMCL","repo_kind":"official","path":"CIFAR100/svm_losses.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/CIFAR100/svm_losses.py","link_basis":"harvester_set","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":"5fa7bb56e6e22a54"}},{"code_sha256_prefix":"5bd550cf0a598b22","entry":"get_args","repo":"anshulbshah/MMCL","repo_kind":"official","path":"myexman/index.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/myexman/index.py","link_basis":"harvester_set","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":"5bd550cf0a598b22"}},{"code_sha256_prefix":"0b30248ddcadc9b7","entry":"get_dataset","repo":"anshulbshah/MMCL","repo_kind":"official","path":"CIFAR100/utils.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/CIFAR100/utils.py","link_basis":"harvester_set","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":"0b30248ddcadc9b7"}},{"code_sha256_prefix":"459939c749c8fd3f","entry":"none2none","repo":"anshulbshah/MMCL","repo_kind":"official","path":"myexman/index.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/myexman/index.py","link_basis":"harvester_set","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":"459939c749c8fd3f"}},{"code_sha256_prefix":"c404ad6b3c3cae86","entry":"only_value_error","repo":"anshulbshah/MMCL","repo_kind":"official","path":"myexman/index.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/myexman/index.py","link_basis":"harvester_set","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":"c404ad6b3c3cae86"}},{"code_sha256_prefix":"54bdbe97f492c455","entry":"pgd_simple_short","repo":"anshulbshah/MMCL","repo_kind":"official","path":"models/solvers.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/models/solvers.py","link_basis":"harvester_set","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":"54bdbe97f492c455"}},{"code_sha256_prefix":"5a39dd9aa51e8d32","entry":"pgd_with_nesterov","repo":"anshulbshah/MMCL","repo_kind":"official","path":"models/solvers.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/models/solvers.py","link_basis":"harvester_set","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":"5a39dd9aa51e8d32"}},{"code_sha256_prefix":"91f52fbcbca3f103","entry":"pgd_with_nesterov","repo":"anshulbshah/MMCL","repo_kind":"official","path":"CIFAR100/solvers.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/CIFAR100/solvers.py","link_basis":"harvester_set","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":"91f52fbcbca3f103"}},{"code_sha256_prefix":"8f49bc51cbbd9f64","entry":"train_val","repo":"anshulbshah/MMCL","repo_kind":"official","path":"CIFAR100/linear.py","file_url":"https://github.com/anshulbshah/MMCL/blob/HEAD/CIFAR100/linear.py","link_basis":"harvester_set","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":"8f49bc51cbbd9f64"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}