{"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/chasing-moving-targets-with-online-self-play","title":"Chasing Moving Targets with Online Self-Play Reinforcement Learning for Safer Language Models","arxiv_id":"2506.07468","date":"2025-06-09","proceeding":null,"authors":["Mickel Liu","Liwei Jiang","Yancheng Liang","Simon Shaolei Du","Yejin Choi","Tim Althoff","Natasha Jaques"],"abstract":"Conventional language model (LM) safety alignment relies on a reactive, disjoint procedure: attackers exploit a static model, followed by defensive fine-tuning to patch exposed vulnerabilities. This sequential approach creates a mismatch -- attackers overfit to obsolete defenses, while defenders perpetually lag behind emerging threats. To address this, we propose Self-RedTeam, an online self-play reinforcement learning algorithm where an attacker and defender agent co-evolve through continuous interaction. We cast safety alignment as a two-player zero-sum game, where a single model alternates between attacker and defender roles -- generating adversarial prompts and safeguarding against them -- while a reward LM adjudicates outcomes. This enables dynamic co-adaptation. Grounded in the game-theoretic framework of zero-sum games, we establish a theoretical safety guarantee which motivates the design of our method: if self-play converges to a Nash Equilibrium, the defender will reliably produce safe responses to any adversarial input. Empirically, Self-RedTeam uncovers more diverse attacks (+21.8% SBERT) compared to attackers trained against static defenders and achieves higher robustness on safety benchmarks (e.g., +65.5% on WildJailBreak) than defenders trained against static attackers. We further propose hidden Chain-of-Thought, allowing agents to plan privately, which boosts adversarial diversity and reduces over-refusals. Our results motivate a shift from reactive patching to proactive co-evolution in LM safety training, enabling scalable, autonomous, and robust self-improvement of LMs via multi-agent reinforcement learning (MARL).","url_abs":"https://arxiv.org/abs/2506.07468v1","url_pdf":"https://arxiv.org/pdf/2506.07468v1.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":"chasing-moving-targets-with-online-self-play","repo_url":"https://github.com/mickelliu/selfplay-redteaming","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"multi-agent-reinforcement-learning","task_name":"Multi-agent Reinforcement Learning"},{"task_slug":"safety-alignment","task_name":"Safety Alignment"}],"methods":[{"method_slug":"patching","method_name":"Patching"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2506.07468","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2506.07468"}},"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/mickelliu/selfplay-redteaming","reach":null}],"summary":{"ran_draft_wrong":5,"ran_honours":1,"unverified":11},"by_repo_kind":{"official":{"samples":16,"ran":5,"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":1,"samples":[{"code_sha256_prefix":"e5918ff1278852d7","entry":"cot_format_check_and_extract","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e5918ff1278852d7"}},{"code_sha256_prefix":"ee235fd9a7e3e346","entry":"get_attacker_prompt_reward","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ee235fd9a7e3e346"}},{"code_sha256_prefix":"c076751eec7d6013","entry":"get_cot_formatting_reward","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c076751eec7d6013"}},{"code_sha256_prefix":"e9f51494b44f4e8e","entry":"get_response_harmfulness_reward","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e9f51494b44f4e8e"}},{"code_sha256_prefix":"9b99eb231136dd0e","entry":"get_response_refusal_reward","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9b99eb231136dd0e"}},{"code_sha256_prefix":"c44830a7722ff5f7","entry":"request_caching_arg_to_dict","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"c44830a7722ff5f7"}},{"code_sha256_prefix":"c8f1077d707eb877","entry":"DialogueGameManager","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"c8f1077d707eb877"}},{"code_sha256_prefix":"248607c655d8ea9c","entry":"GameOutcome","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"248607c655d8ea9c"}},{"code_sha256_prefix":"28badd08d6d3c33f","entry":"PromptHarmfulness","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"28badd08d6d3c33f"}},{"code_sha256_prefix":"d705dafdd918f797","entry":"ResponseHarmfulness","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"d705dafdd918f797"}},{"code_sha256_prefix":"1ed39104ef491246","entry":"ResponseRefusal","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"1ed39104ef491246"}},{"code_sha256_prefix":"f0eec14ba1e2868d","entry":"convert_game_history_to_messages","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"f0eec14ba1e2868d"}},{"code_sha256_prefix":"b3c0cd514922498f","entry":"convert_game_history_to_query","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"b3c0cd514922498f"}},{"code_sha256_prefix":"cea8712a2eeceb41","entry":"get_redteaming_game_reward_general_sum","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"cea8712a2eeceb41"}},{"code_sha256_prefix":"6070c9f7525de92f","entry":"get_redteaming_game_reward_zero_sum","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"6070c9f7525de92f"}},{"code_sha256_prefix":"3417fd8982acd9e0","entry":"remote_rm_fn","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"3417fd8982acd9e0"}},{"code_sha256_prefix":"e906613b41734aa5","entry":"request_api_wrapper","repo":"mickelliu/selfplay-redteaming","repo_kind":"official","path":"openrlhf/trainer/ppo_utils/language_game.py","file_url":"https://github.com/mickelliu/selfplay-redteaming/blob/HEAD/openrlhf/trainer/ppo_utils/language_game.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":"e906613b41734aa5"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}