{"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/controlled-text-generation-as-continuous","title":"Controlled Text Generation as Continuous Optimization with Multiple Constraints","arxiv_id":"2108.01850","date":"2021-08-04","proceeding":"NeurIPS 2021 12","authors":["Sachin Kumar","Eric Malmi","Aliaksei Severyn","Yulia Tsvetkov"],"abstract":"As large-scale language model pretraining pushes the state-of-the-art in text generation, recent work has turned to controlling attributes of the text such models generate. While modifying the pretrained models via fine-tuning remains the popular approach, it incurs a significant computational cost and can be infeasible due to lack of appropriate data. As an alternative, we propose MuCoCO -- a flexible and modular algorithm for controllable inference from pretrained models. We formulate the decoding process as an optimization problem which allows for multiple attributes we aim to control to be easily incorporated as differentiable constraints to the optimization. By relaxing this discrete optimization to a continuous one, we make use of Lagrangian multipliers and gradient-descent based techniques to generate the desired text. We evaluate our approach on controllable machine translation and style transfer with multiple sentence-level attributes and observe significant improvements over baselines.","url_abs":"https://arxiv.org/abs/2108.01850v1","url_pdf":"https://arxiv.org/pdf/2108.01850v1.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":"controlled-text-generation-as-continuous","repo_url":"https://github.com/sachin19/mucoco","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"machine-translation","task_name":"Machine Translation"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"style-transfer","task_name":"Style Transfer"},{"task_slug":"text-generation","task_name":"Text Generation"},{"task_slug":"translation","task_name":"Translation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2108.01850","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2108.01850"}},"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/sachin19/mucoco","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":1,"unverified":8},"by_repo_kind":{"listed":{"samples":9,"ran":1,"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":"ee3e60cc57e00353","entry":"mean_pooling","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/losses/usim.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/losses/usim.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ee3e60cc57e00353"}},{"code_sha256_prefix":"e1ad68dfafc69fa9","entry":"build_torch_optimizer","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/utils/optim.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/utils/optim.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":"e1ad68dfafc69fa9"}},{"code_sha256_prefix":"cc5d4721f229761e","entry":"clean_output","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/decode.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/decode.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":"cc5d4721f229761e"}},{"code_sha256_prefix":"76cdadf43082eedd","entry":"get_epsilon","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/utils/misc.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/utils/misc.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":"76cdadf43082eedd"}},{"code_sha256_prefix":"5f29c2161421a4d8","entry":"gold_marianMTloss","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/losses/marianmt.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/losses/marianmt.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":"5f29c2161421a4d8"}},{"code_sha256_prefix":"2841f8cb1a0660a1","entry":"make_learning_rate_decay_fn","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/utils/optim.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/utils/optim.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":"2841f8cb1a0660a1"}},{"code_sha256_prefix":"7f76acc0fa3597ff","entry":"marianMTloss","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/losses/marianmt.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/losses/marianmt.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":"7f76acc0fa3597ff"}},{"code_sha256_prefix":"e614cb6fa8ce79cd","entry":"noam_decay","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/utils/optim.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/utils/optim.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":"e614cb6fa8ce79cd"}},{"code_sha256_prefix":"cb4a7e224fe59578","entry":"top_k_top_p_filtering","repo":"sachin19/mucoco","repo_kind":"listed","path":"mucoco/utils/targets.py","file_url":"https://github.com/sachin19/mucoco/blob/HEAD/mucoco/utils/targets.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":"cb4a7e224fe59578"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}