{"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/contrastive-difference-predictive-coding","title":"Contrastive Difference Predictive Coding","arxiv_id":"2310.20141","date":"2023-10-31","proceeding":null,"authors":["Chongyi Zheng","Ruslan Salakhutdinov","Benjamin Eysenbach"],"abstract":"Predicting and reasoning about the future lie at the heart of many time-series questions. For example, goal-conditioned reinforcement learning can be viewed as learning representations to predict which states are likely to be visited in the future. While prior methods have used contrastive predictive coding to model time series data, learning representations that encode long-term dependencies usually requires large amounts of data. In this paper, we introduce a temporal difference version of contrastive predictive coding that stitches together pieces of different time series data to decrease the amount of data required to learn predictions of future events. We apply this representation learning method to derive an off-policy algorithm for goal-conditioned RL. Experiments demonstrate that, compared with prior RL methods, ours achieves $2 \\times$ median improvement in success rates and can better cope with stochastic environments. In tabular settings, we show that our method is about $20 \\times$ more sample efficient than the successor representation and $1500 \\times$ more sample efficient than the standard (Monte Carlo) version of contrastive predictive coding.","url_abs":"https://arxiv.org/abs/2310.20141v2","url_pdf":"https://arxiv.org/pdf/2310.20141v2.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":"contrastive-difference-predictive-coding","repo_url":"https://github.com/chongyi-zheng/td_infonce","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"time-series-1","task_name":"Time Series"}],"methods":[{"method_slug":"contrastive-predictive-coding","method_name":"Contrastive Predictive Coding"},{"method_slug":"infonce","method_name":"InfoNCE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.20141","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.20141"}},"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/chongyi-zheng/td_infonce","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":5},"by_repo_kind":{"official":{"samples":5,"ran":5,"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":"86b31cc8f58a61b4","entry":"apply_policy_and_sample","repo":"chongyi-zheng/td_infonce","repo_kind":"official","path":"td_infonce/networks.py","file_url":"https://github.com/chongyi-zheng/td_infonce/blob/HEAD/td_infonce/networks.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":"86b31cc8f58a61b4"}},{"code_sha256_prefix":"35bd6ebd08652e20","entry":"get_reward","repo":"chongyi-zheng/td_infonce","repo_kind":"official","path":"envs/fetch_envs.py","file_url":"https://github.com/chongyi-zheng/td_infonce/blob/HEAD/envs/fetch_envs.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":"35bd6ebd08652e20"}},{"code_sha256_prefix":"aae1c7c736822527","entry":"make_offline_d4rl","repo":"chongyi-zheng/td_infonce","repo_kind":"official","path":"envs/offline_ant_envs.py","file_url":"https://github.com/chongyi-zheng/td_infonce/blob/HEAD/envs/offline_ant_envs.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":"aae1c7c736822527"}},{"code_sha256_prefix":"414dbeb2f8b06a40","entry":"obs_to_goal_1d","repo":"chongyi-zheng/td_infonce","repo_kind":"official","path":"td_infonce/utils.py","file_url":"https://github.com/chongyi-zheng/td_infonce/blob/HEAD/td_infonce/utils.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":"414dbeb2f8b06a40"}},{"code_sha256_prefix":"1896647d018339ef","entry":"obs_to_goal_2d","repo":"chongyi-zheng/td_infonce","repo_kind":"official","path":"td_infonce/utils.py","file_url":"https://github.com/chongyi-zheng/td_infonce/blob/HEAD/td_infonce/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1896647d018339ef"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}