{"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/preadd-prefix-adaptive-decoding-for","title":"PREADD: Prefix-Adaptive Decoding for Controlled Text Generation","arxiv_id":"2307.03214","date":"2023-07-06","proceeding":null,"authors":["Jonathan Pei","Kevin Yang","Dan Klein"],"abstract":"We propose Prefix-Adaptive Decoding (PREADD), a flexible method for controlled text generation. Unlike existing methods that use auxiliary expert models to control for attributes, PREADD does not require an external model, instead relying on linearly combining output logits from multiple prompts. Specifically, PREADD contrasts the output logits generated using a raw prompt against those generated using a prefix-prepended prompt, enabling both positive and negative control with respect to any attribute encapsulated by the prefix. We evaluate PREADD on three tasks -- toxic output mitigation, gender bias reduction, and sentiment control -- and find that PREADD outperforms not only prompting baselines, but also an auxiliary-expert control method, by 12% or more in relative gain on our main metrics for each task.","url_abs":"https://arxiv.org/abs/2307.03214v1","url_pdf":"https://arxiv.org/pdf/2307.03214v1.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":"preadd-prefix-adaptive-decoding-for","repo_url":"https://github.com/jonnypei/acl23-preadd","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2307.03214","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.03214"}},"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/jonnypei/acl23-preadd","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":6,"unverified":6},"by_repo_kind":{"official":{"samples":12,"ran":6,"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":"2f04763df90287b6","entry":"clamp","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/fudge/util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/fudge/util.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":"2f04763df90287b6"}},{"code_sha256_prefix":"bd461652e2d3d3ad","entry":"collate","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/fudge/data.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/fudge/data.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":"bd461652e2d3d3ad"}},{"code_sha256_prefix":"aab18278f4e1c226","entry":"get_tokenizer","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/engine_util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/engine_util.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":"aab18278f4e1c226"}},{"code_sha256_prefix":"48689cd65df839d6","entry":"num_params","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/fudge/util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/fudge/util.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":"48689cd65df839d6"}},{"code_sha256_prefix":"bb59f1498141e958","entry":"pad_to_length","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/fudge/util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/fudge/util.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":"bb59f1498141e958"}},{"code_sha256_prefix":"bc1c2e993c8a4009","entry":"server_next_logprobs","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/engine_util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/engine_util.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":"bc1c2e993c8a4009"}},{"code_sha256_prefix":"3809b788d60c9780","entry":"generate_preadd","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/method_preadd.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/method_preadd.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":"3809b788d60c9780"}},{"code_sha256_prefix":"e85fb66a8e9c0dc8","entry":"generate_standard","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"methods/method_standard.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/methods/method_standard.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":"e85fb66a8e9c0dc8"}},{"code_sha256_prefix":"255dbccf793bbcfb","entry":"get_next_logprobs","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/engine_util.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/engine_util.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":"255dbccf793bbcfb"}},{"code_sha256_prefix":"b871ff7f6e73b7a8","entry":"grammaticality","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/metrics.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/metrics.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":"b871ff7f6e73b7a8"}},{"code_sha256_prefix":"e621046299d54577","entry":"load_model","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/model_server.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/model_server.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":"e621046299d54577"}},{"code_sha256_prefix":"99ee132d16e7f4b7","entry":"perplexity","repo":"jonnypei/acl23-preadd","repo_kind":"official","path":"utils/metrics.py","file_url":"https://github.com/jonnypei/acl23-preadd/blob/HEAD/utils/metrics.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":"99ee132d16e7f4b7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}