{"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/stepwise-alignment-for-constrained-language","title":"Stepwise Alignment for Constrained Language Model Policy Optimization","arxiv_id":"2404.11049","date":"2024-04-17","proceeding":null,"authors":["Akifumi Wachi","Thien Q. Tran","Rei Sato","Takumi Tanabe","Youhei Akimoto"],"abstract":"Safety and trustworthiness are indispensable requirements for real-world applications of AI systems using large language models (LLMs). This paper formulates human value alignment as an optimization problem of the language model policy to maximize reward under a safety constraint, and then proposes an algorithm, Stepwise Alignment for Constrained Policy Optimization (SACPO). One key idea behind SACPO, supported by theory, is that the optimal policy incorporating reward and safety can be directly obtained from a reward-aligned policy. Building on this key idea, SACPO aligns LLMs step-wise with each metric while leveraging simple yet powerful alignment algorithms such as direct preference optimization (DPO). SACPO offers several advantages, including simplicity, stability, computational efficiency, and flexibility of algorithms and datasets. Under mild assumptions, our theoretical analysis provides the upper bounds on optimality and safety constraint violation. Our experimental results show that SACPO can fine-tune Alpaca-7B better than the state-of-the-art method in terms of both helpfulness and harmlessness.","url_abs":"https://arxiv.org/abs/2404.11049v3","url_pdf":"https://arxiv.org/pdf/2404.11049v3.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":"stepwise-alignment-for-constrained-language","repo_url":"https://github.com/line/sacpo","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"computational-efficiency","task_name":"Computational Efficiency"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"model","task_name":"model"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2404.11049","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2404.11049"}},"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/line/sacpo","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":6,"unverified":2},"by_repo_kind":{"official":{"samples":8,"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":"be8217e10c30c538","entry":"expected_score","repo":"line/sacpo","repo_kind":"official","path":"src/evaluate/compute_scores.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/evaluate/compute_scores.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":"be8217e10c30c538"}},{"code_sha256_prefix":"2f81e6574ec58c2b","entry":"get_pku_by_helpfulness","repo":"line/sacpo","repo_kind":"official","path":"src/util.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/util.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":"2f81e6574ec58c2b"}},{"code_sha256_prefix":"3d01f355d3116ba4","entry":"get_pku_pair_by_safety","repo":"line/sacpo","repo_kind":"official","path":"src/util.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/util.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":"3d01f355d3116ba4"}},{"code_sha256_prefix":"09938dbc5870f170","entry":"query_gpt4","repo":"line/sacpo","repo_kind":"official","path":"src/evaluate/gpt4_evaluate.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/evaluate/gpt4_evaluate.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":"09938dbc5870f170"}},{"code_sha256_prefix":"0a3c31e106bd4ef7","entry":"save_progress","repo":"line/sacpo","repo_kind":"official","path":"src/evaluate/gpt4_evaluate.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/evaluate/gpt4_evaluate.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":"0a3c31e106bd4ef7"}},{"code_sha256_prefix":"7423e806d6c0d940","entry":"update_elo","repo":"line/sacpo","repo_kind":"official","path":"src/evaluate/compute_scores.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/evaluate/compute_scores.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":"7423e806d6c0d940"}},{"code_sha256_prefix":"d8b2b7b3a93ce0a6","entry":"generate_answers","repo":"line/sacpo","repo_kind":"official","path":"src/evaluate/generate.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/evaluate/generate.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":"d8b2b7b3a93ce0a6"}},{"code_sha256_prefix":"fe1e576f53a55329","entry":"get_pku_pair_by_helpfulness","repo":"line/sacpo","repo_kind":"official","path":"src/util.py","file_url":"https://github.com/line/sacpo/blob/HEAD/src/util.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":"fe1e576f53a55329"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}