{"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/arxiv-2602-13562","title":"Mitigating the Safety-utility Trade-off in LLM Alignment via Adaptive Safe Context Learning","arxiv_id":"2602.13562","date":"2026-02-14","proceeding":null,"authors":["Yanbo Wang","Minzheng Wang","Jian Liang","Lu Wang","Yongcan Yu","Ran He"],"abstract":"While reasoning models have achieved remarkable success in complex reasoning tasks, their increasing power necessitates stringent safety measures. For safety alignment, the core challenge lies in the inherent trade-off between safety and utility. However, prevailing alignment strategies typically construct CoT training data with explicit safety rules via context distillation. This approach inadvertently limits reasoning capabilities by creating a rigid association between rule memorization and refusal. To mitigate the safety-utility trade-off, we propose the Adaptive Safe Context Learning~(ASCL) framework to improve the reasoning given proper context. ASCL formulates safety alignment as a multi-turn tool-use process, empowering the model to autonomously decide when to consult safety rules and how to generate the ongoing reasoning. Furthermore, to counteract the preference for rule consultation during RL, we introduce Inverse Frequency Policy Optimization~(IFPO) to rebalance advantage estimates. By decoupling rule retrieval and subsequent reasoning, our method achieves higher overall performance compared to baselines. Our code is publicly available at https://github.com/ybwang119/ASCL.","url_abs":"https://arxiv.org/abs/2602.13562","url_pdf":"https://arxiv.org/pdf/2602.13562","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2602.13562","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2602.13562"}},"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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/ybwang119/ASCL","reach":null}],"summary":{"unverified":13},"by_repo_kind":{"found_in_text":{"samples":13,"ran":0,"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":13,"samples":[{"code_sha256_prefix":"10bec5fa8e6f61dd","entry":"append_log_with_lock","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/file_lock_utils.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/file_lock_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"10bec5fa8e6f61dd"}},{"code_sha256_prefix":"c01bc9ee109cbf8d","entry":"append_results_with_lock","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/file_lock_utils.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/file_lock_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c01bc9ee109cbf8d"}},{"code_sha256_prefix":"a4fcf66f43d9221a","entry":"calculate_batch_results","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/calculate_results.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/calculate_results.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a4fcf66f43d9221a"}},{"code_sha256_prefix":"726a6b9bf91dba53","entry":"collect_all_summaries","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/aggregate_results.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/aggregate_results.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"726a6b9bf91dba53"}},{"code_sha256_prefix":"320e53d22a431c6d","entry":"extract_label_categories_refusal","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/evaluator.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/evaluator.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"320e53d22a431c6d"}},{"code_sha256_prefix":"a1254dbd2ac8f59a","entry":"get_adapter","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/dataset_adapter.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/dataset_adapter.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a1254dbd2ac8f59a"}},{"code_sha256_prefix":"619bbd8e00b79eda","entry":"has_adapter","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/dataset_adapter.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/dataset_adapter.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"619bbd8e00b79eda"}},{"code_sha256_prefix":"69d99684e9c8aafc","entry":"llama_guard_moderate","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/evaluator.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/evaluator.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"69d99684e9c8aafc"}},{"code_sha256_prefix":"f33694889a861d02","entry":"load_config","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"src/rag_mcp_server.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/src/rag_mcp_server.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f33694889a861d02"}},{"code_sha256_prefix":"a90bae6c7c585846","entry":"load_detailed_metrics","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/aggregate_results.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/aggregate_results.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a90bae6c7c585846"}},{"code_sha256_prefix":"711896fc20bbdc1f","entry":"qwen_guard_moderate","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/evaluator.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/evaluator.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"711896fc20bbdc1f"}},{"code_sha256_prefix":"0f5d518fa86c579f","entry":"save_temp_results","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/core/file_lock_utils.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/core/file_lock_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0f5d518fa86c579f"}},{"code_sha256_prefix":"c8365de93184ac10","entry":"summaries_to_dataframe","repo":"ybwang119/ASCL","repo_kind":"found_in_text","path":"benchmark/aggregate_results.py","file_url":"https://github.com/ybwang119/ASCL/blob/HEAD/benchmark/aggregate_results.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c8365de93184ac10"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CL","source":"arxiv_2026.jsonl"},"syntology_extracted_results":null}