{"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/understanding-contrastive-representation","title":"Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere","arxiv_id":"2005.10242","date":"2020-05-20","proceeding":null,"authors":["Tongzhou Wang","Phillip Isola"],"abstract":"Contrastive representation learning has been outstandingly successful in practice. In this work, we identify two key properties related to the contrastive loss: (1) alignment (closeness) of features from positive pairs, and (2) uniformity of the induced distribution of the (normalized) features on the hypersphere. We prove that, asymptotically, the contrastive loss optimizes these properties, and analyze their positive effects on downstream tasks. Empirically, we introduce an optimizable metric to quantify each property. Extensive experiments on standard vision and language datasets confirm the strong agreement between both metrics and downstream task performance. Remarkably, directly optimizing for these two metrics leads to representations with comparable or better performance at downstream tasks than contrastive learning. Project Page: https://ssnl.github.io/hypersphere Code: https://github.com/SsnL/align_uniform , https://github.com/SsnL/moco_align_uniform","url_abs":"https://arxiv.org/abs/2005.10242v9","url_pdf":"https://arxiv.org/pdf/2005.10242v9.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":"understanding-contrastive-representation","repo_url":"https://github.com/SsnL/align_uniform","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"understanding-contrastive-representation","repo_url":"https://github.com/pangzss/pytorch-ctvsum","is_official":0,"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"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2005.10242","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2005.10242"}},"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/SsnL/align_uniform","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pangzss/pytorch-ctvsum","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_honours":1,"ran_fixture":1,"unverified":9},"by_repo_kind":{"listed":{"samples":9,"ran":2,"repositories":1},"community":{"samples":1,"ran":0,"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":2,"samples":[{"code_sha256_prefix":"361a6b24f11fc50a","entry":"cosine_scheduler","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"361a6b24f11fc50a"}},{"code_sha256_prefix":"d8578a1e5c318cf9","entry":"trunc_normal_","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d8578a1e5c318cf9"}},{"code_sha256_prefix":"9b8289076669fe4f","entry":"accuracy","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"unverified","verification_level":0,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"9b8289076669fe4f"}},{"code_sha256_prefix":"4926d212a1822095","entry":"evaluate_summary","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"vsum_tools.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/vsum_tools.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":"4926d212a1822095"}},{"code_sha256_prefix":"94b106ddf66bb46e","entry":"evaluate_user_summaries","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"vsum_tools.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/vsum_tools.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":"94b106ddf66bb46e"}},{"code_sha256_prefix":"7a401efe934df82d","entry":"get_rc_func","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"evaluation.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/evaluation.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":"7a401efe934df82d"}},{"code_sha256_prefix":"26afde22fce432ac","entry":"knapsack","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"knapsack.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/knapsack.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":"26afde22fce432ac"}},{"code_sha256_prefix":"96b2828743f88070","entry":"knapsack_dp","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"knapsack.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/knapsack.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":"96b2828743f88070"}},{"code_sha256_prefix":"0998ae7833d6d509","entry":"nondefault_trainer_args","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"main_ablations.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/main_ablations.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":"0998ae7833d6d509"}},{"code_sha256_prefix":"641956a2906f089f","entry":"test_collate","repo":"pangzss/pytorch-ctvsum","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/pangzss/pytorch-ctvsum/blob/HEAD/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":"641956a2906f089f"}},{"code_sha256_prefix":"0358792e34e9cbb2","entry":"validate","repo":"ssnl/moco_align_uniform","repo_kind":"community","path":"main_lincls.py","file_url":"https://github.com/ssnl/moco_align_uniform/blob/HEAD/main_lincls.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"0358792e34e9cbb2"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}