{"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/cocon-a-self-supervised-approach-for","title":"CoCon: A Self-Supervised Approach for Controlled Text Generation","arxiv_id":"2006.03535","date":"2020-06-05","proceeding":"ICLR 2021 1","authors":["Alvin Chan","Yew-Soon Ong","Bill Pung","Aston Zhang","Jie Fu"],"abstract":"Pretrained Transformer-based language models (LMs) display remarkable natural language generation capabilities. With their immense potential, controlling text generation of such LMs is getting attention. While there are studies that seek to control high-level attributes (such as sentiment and topic) of generated text, there is still a lack of more precise control over its content at the word- and phrase-level. Here, we propose Content-Conditioner (CoCon) to control an LM's output text with a content input, at a fine-grained level. In our self-supervised approach, the CoCon block learns to help the LM complete a partially-observed text sequence by conditioning with content inputs that are withheld from the LM. Through experiments, we show that CoCon can naturally incorporate target content into generated texts and control high-level text attributes in a zero-shot manner.","url_abs":"https://arxiv.org/abs/2006.03535v3","url_pdf":"https://arxiv.org/pdf/2006.03535v3.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":"cocon-a-self-supervised-approach-for","repo_url":"https://github.com/alvinchangw/COCON_ICLR2021","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2006.03535","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2006.03535"}},"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/alvinchangw/COCON_ICLR2021","reach":null}],"summary":{"ran":3,"ran_honours":1,"ran_draft_wrong":1,"unverified":1},"by_repo_kind":{"official":{"samples":5,"ran":4,"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":1,"samples":[{"code_sha256_prefix":"ecda3bf262fb3173","entry":"CoconAttention","repo":"alvinchangw/COCON_ICLR2021","repo_kind":"official","path":"transformers/modeling_gpt2.py","file_url":"https://github.com/alvinchangw/COCON_ICLR2021/blob/HEAD/transformers/modeling_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ecda3bf262fb3173"}},{"code_sha256_prefix":"1f5e6090de4f273a","entry":"Conv1D","repo":"alvinchangw/COCON_ICLR2021","repo_kind":"official","path":"transformers/modeling_gpt2.py","file_url":"https://github.com/alvinchangw/COCON_ICLR2021/blob/HEAD/transformers/modeling_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1f5e6090de4f273a"}},{"code_sha256_prefix":"ae4f6a5f000c8cbd","entry":"MLP","repo":"alvinchangw/COCON_ICLR2021","repo_kind":"official","path":"transformers/modeling_gpt2.py","file_url":"https://github.com/alvinchangw/COCON_ICLR2021/blob/HEAD/transformers/modeling_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ae4f6a5f000c8cbd"}},{"code_sha256_prefix":"77601724cad03f95","entry":"gelu_new","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"77601724cad03f95"}},{"code_sha256_prefix":"c92db0c571d83ad4","entry":"prune_conv1d_layer","repo":"alvinchangw/COCON_ICLR2021","repo_kind":"official","path":"transformers/modeling_gpt2.py","file_url":"https://github.com/alvinchangw/COCON_ICLR2021/blob/HEAD/transformers/modeling_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c92db0c571d83ad4"}},{"code_sha256_prefix":"5070af0ce59c31c0","entry":"CoconBlock","repo":"alvinchangw/COCON_ICLR2021","repo_kind":"official","path":"transformers/modeling_gpt2.py","file_url":"https://github.com/alvinchangw/COCON_ICLR2021/blob/HEAD/transformers/modeling_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5070af0ce59c31c0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}