{"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/plug-and-play-language-models-a-simple","title":"Plug and Play Language Models: A Simple Approach to Controlled Text Generation","arxiv_id":"1912.02164","date":"2019-12-04","proceeding":"ICLR 2020 1","authors":["Sumanth Dathathri","Andrea Madotto","Janice Lan","Jane Hung","Eric Frank","Piero Molino","Jason Yosinski","Rosanne Liu"],"abstract":"Large transformer-based language models (LMs) trained on huge text corpora have shown unparalleled generation capabilities. However, controlling attributes of the generated language (e.g. switching topic or sentiment) is difficult without modifying the model architecture or fine-tuning on attribute-specific data and entailing the significant cost of retraining. We propose a simple alternative: the Plug and Play Language Model (PPLM) for controllable language generation, which combines a pretrained LM with one or more simple attribute classifiers that guide text generation without any further training of the LM. In the canonical scenario we present, the attribute models are simple classifiers consisting of a user-specified bag of words or a single learned layer with 100,000 times fewer parameters than the LM. Sampling entails a forward and backward pass in which gradients from the attribute model push the LM's hidden activations and thus guide the generation. Model samples demonstrate control over a range of topics and sentiment styles, and extensive automated and human annotated evaluations show attribute alignment and fluency. PPLMs are flexible in that any combination of differentiable attribute models may be used to steer text generation, which will allow for diverse and creative applications beyond the examples given in this paper.","url_abs":"https://arxiv.org/abs/1912.02164v4","url_pdf":"https://arxiv.org/pdf/1912.02164v4.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":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/uber-research/PPLM","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/AdarshKumar712/PPLM.jl","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/ImadENSMN/pplm_gptneo","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/fsoft-ailab/poem-generator","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/jefflai108/6.438-final","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/qkaren/unsup_gen_for_cms_reasoning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"plug-and-play-language-models-a-simple","repo_url":"https://github.com/huggingface/transformers","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1912.02164","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1912.02164"}},"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/huggingface/transformers","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/AdarshKumar712/PPLM.jl","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/fsoft-ailab/poem-generator","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/uber-research/PPLM","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jefflai108/6.438-final","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ImadENSMN/pplm_gptneo","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/qkaren/unsup_gen_for_cms_reasoning","reach":null}],"summary":{"ran":2,"ran_fixture":2,"unverified":18},"by_repo_kind":{"official":{"samples":3,"ran":2,"repositories":1},"listed":{"samples":19,"ran":2,"repositories":2}},"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":"9f95f3541586ad5c","entry":"cached_collate_fn","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"run_pplm_discrim_train.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/run_pplm_discrim_train.py","link_basis":"harvester_set","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":"9f95f3541586ad5c"}},{"code_sha256_prefix":"c5e400dbec9871ce","entry":"collate_fn","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"run_pplm_discrim_train.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/run_pplm_discrim_train.py","link_basis":"harvester_set","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":"c5e400dbec9871ce"}},{"code_sha256_prefix":"bbebd95a156061b0","entry":"to_var","repo":"uber-research/PPLM","repo_kind":"official","path":"run_pplm.py","file_url":"https://github.com/uber-research/PPLM/blob/HEAD/run_pplm.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bbebd95a156061b0"}},{"code_sha256_prefix":"ac71b1f4007ef1dd","entry":"top_k_filter","repo":"uber-research/PPLM","repo_kind":"official","path":"run_pplm.py","file_url":"https://github.com/uber-research/PPLM/blob/HEAD/run_pplm.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ac71b1f4007ef1dd"}},{"code_sha256_prefix":"da6a6099de169fa6","entry":"add_past","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/method3.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/method3.py","link_basis":"harvester_set","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":"da6a6099de169fa6"}},{"code_sha256_prefix":"bb82e66218a5e42e","entry":"build_bows_one_hot_vectors","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/bow.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/bow.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":"bb82e66218a5e42e"}},{"code_sha256_prefix":"200de6c5c7533d37","entry":"cat_past","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/method3.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/method3.py","link_basis":"harvester_set","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":"200de6c5c7533d37"}},{"code_sha256_prefix":"9b3442a1518d31ff","entry":"cat_past","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/method4.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/method4.py","link_basis":"harvester_set","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":"9b3442a1518d31ff"}},{"code_sha256_prefix":"895ee1e721fbbb88","entry":"collate_fn","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"paper_code/gpt2tunediscrim.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/paper_code/gpt2tunediscrim.py","link_basis":"harvester_set","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":"895ee1e721fbbb88"}},{"code_sha256_prefix":"41cffde6e7f145a7","entry":"conditioning","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/utils.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/utils.py","link_basis":"harvester_set","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":"41cffde6e7f145a7"}},{"code_sha256_prefix":"368c3700824b81fb","entry":"evaluate_performance","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"run_pplm_discrim_train.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/run_pplm_discrim_train.py","link_basis":"harvester_set","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":"368c3700824b81fb"}},{"code_sha256_prefix":"73250b2a460d9cd9","entry":"generate_text_pplm","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/generate/generate_topic.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/generate/generate_topic.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":"73250b2a460d9cd9"}},{"code_sha256_prefix":"2bc0b122982a024e","entry":"get_bag_of_words_indices","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/bow.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/bow.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":"2bc0b122982a024e"}},{"code_sha256_prefix":"85766c79fe9b99bb","entry":"is_stanza","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/check_rule.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/check_rule.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":"85766c79fe9b99bb"}},{"code_sha256_prefix":"217f0089cb193f97","entry":"load_data","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/check_rule.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/check_rule.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":"217f0089cb193f97"}},{"code_sha256_prefix":"13fe54bb9dec7e8c","entry":"perturb_past","repo":"uber-research/PPLM","repo_kind":"official","path":"run_pplm.py","file_url":"https://github.com/uber-research/PPLM/blob/HEAD/run_pplm.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":"13fe54bb9dec7e8c"}},{"code_sha256_prefix":"3176b47b94387f2a","entry":"perturb_past","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/generate/generate_topic.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/generate/generate_topic.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":"3176b47b94387f2a"}},{"code_sha256_prefix":"49e475b822b30d82","entry":"post_process","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/process.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/process.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":"49e475b822b30d82"}},{"code_sha256_prefix":"1dcfab77356ba4f5","entry":"repeat_past","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/utils.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/utils.py","link_basis":"harvester_set","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":"1dcfab77356ba4f5"}},{"code_sha256_prefix":"10c0ed80ad796bd1","entry":"split_word","repo":"fsoft-ailab/poem-generator","repo_kind":"listed","path":"ailamtho/utils/check_rule.py","file_url":"https://github.com/fsoft-ailab/poem-generator/blob/HEAD/ailamtho/utils/check_rule.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":"10c0ed80ad796bd1"}},{"code_sha256_prefix":"b975947f493d596d","entry":"top_k_filtering","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/method3.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/method3.py","link_basis":"harvester_set","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":"b975947f493d596d"}},{"code_sha256_prefix":"a6e350b1e7b2bef3","entry":"top_k_filtering","repo":"jefflai108/6.438-final","repo_kind":"listed","path":"ours/utils.py","file_url":"https://github.com/jefflai108/6.438-final/blob/HEAD/ours/utils.py","link_basis":"harvester_set","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":"a6e350b1e7b2bef3"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}