{"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/diffusion-guided-language-modeling","title":"Diffusion Guided Language Modeling","arxiv_id":"2408.04220","date":"2024-08-08","proceeding":null,"authors":["Justin Lovelace","Varsha Kishore","YiWei Chen","Kilian Q. Weinberger"],"abstract":"Current language models demonstrate remarkable proficiency in text generation. However, for many applications it is desirable to control attributes, such as sentiment, or toxicity, of the generated language -- ideally tailored towards each specific use case and target audience. For auto-regressive language models, existing guidance methods are prone to decoding errors that cascade during generation and degrade performance. In contrast, text diffusion models can easily be guided with, for example, a simple linear sentiment classifier -- however they do suffer from significantly higher perplexity than auto-regressive alternatives. In this paper we use a guided diffusion model to produce a latent proposal that steers an auto-regressive language model to generate text with desired properties. Our model inherits the unmatched fluency of the auto-regressive approach and the plug-and-play flexibility of diffusion. We show that it outperforms previous plug-and-play guidance methods across a wide range of benchmark data sets. Further, controlling a new attribute in our framework is reduced to training a single logistic regression classifier.","url_abs":"https://arxiv.org/abs/2408.04220v1","url_pdf":"https://arxiv.org/pdf/2408.04220v1.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":"diffusion-guided-language-modeling","repo_url":"https://github.com/justinlovelace/diffusion-guided-lm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"logistic-regression","method_name":"Logistic Regression"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2408.04220","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.04220"}},"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/justinlovelace/diffusion-guided-lm","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":9,"ran_violates":2,"ran_draft_wrong":1,"unverified":3},"by_repo_kind":{"official":{"samples":15,"ran":12,"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":"0dacf1cd4472c7f4","entry":"convert_epsweight_to_xweight","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/loss_weighting.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/loss_weighting.py","link_basis":"first_harvest_node","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":"0dacf1cd4472c7f4"}},{"code_sha256_prefix":"44964eb2373817aa","entry":"convert_vweight_to_epsweight","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/loss_weighting.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/loss_weighting.py","link_basis":"first_harvest_node","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":"44964eb2373817aa"}},{"code_sha256_prefix":"1d0ae3a51abe89ef","entry":"cosine_schedule","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/noise_schedule.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/noise_schedule.py","link_basis":"first_harvest_node","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":"1d0ae3a51abe89ef"}},{"code_sha256_prefix":"0dd9d3962e8f433d","entry":"distinctness","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"evaluation/wrappers.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/evaluation/wrappers.py","link_basis":"first_harvest_node","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":"0dd9d3962e8f433d"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"models/diff_gpt.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/models/diff_gpt.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"608e364a9d2376a3","entry":"exists","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/trainer.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/trainer.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"608e364a9d2376a3"}},{"code_sha256_prefix":"d93be7ef30d67f1e","entry":"log","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/noise_schedule.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/noise_schedule.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d93be7ef30d67f1e"}},{"code_sha256_prefix":"464efe215a8b78a6","entry":"log_snr_to_alpha2","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/noise_schedule.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/noise_schedule.py","link_basis":"first_harvest_node","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":"464efe215a8b78a6"}},{"code_sha256_prefix":"c2cdff12cab93636","entry":"predict_noise_from_start","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/diff_utils.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/diff_utils.py","link_basis":"first_harvest_node","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":"c2cdff12cab93636"}},{"code_sha256_prefix":"669feaf2125330e9","entry":"predict_start_from_noise","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/diff_utils.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/diff_utils.py","link_basis":"first_harvest_node","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":"669feaf2125330e9"}},{"code_sha256_prefix":"080807179fd2bc7d","entry":"predict_start_from_v","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/diff_utils.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/diff_utils.py","link_basis":"first_harvest_node","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":"080807179fd2bc7d"}},{"code_sha256_prefix":"95df472b7c0a3c59","entry":"variance_preserving_map","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"models/diff_gpt.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/models/diff_gpt.py","link_basis":"first_harvest_node","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":"95df472b7c0a3c59"}},{"code_sha256_prefix":"fdee5b2a7081c1df","entry":"compute_olmo_perplexity","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"evaluation/wrappers.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/evaluation/wrappers.py","link_basis":"first_harvest_node","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":"fdee5b2a7081c1df"}},{"code_sha256_prefix":"5668b62a6e4b01bb","entry":"convert_epsweight_to_vweight","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"diffusion/loss_weighting.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/diffusion/loss_weighting.py","link_basis":"plan_row","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":"5668b62a6e4b01bb"}},{"code_sha256_prefix":"8d1a3ec5840c93c9","entry":"create_causal_mask","repo":"justinlovelace/diffusion-guided-lm","repo_kind":"official","path":"models/modules/blocks.py","file_url":"https://github.com/justinlovelace/diffusion-guided-lm/blob/HEAD/models/modules/blocks.py","link_basis":"plan_row","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":"8d1a3ec5840c93c9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}