{"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-2510-13183","title":"DSCD: Large Language Model Detoxification with Self-Constrained Decoding","arxiv_id":"2510.13183","date":"2025-10-15","proceeding":"EMNLP","authors":["Ming Dong","Jinkui Zhang","Bolong Zheng","Xinhui Tu","Po Hu","Tingting He"],"abstract":"Detoxification in large language models (LLMs) remains a significant research challenge. Existing decoding detoxification methods are all based on external constraints, which require additional resource overhead and lose generation fluency. This work proposes Detoxification with Self-Constrained Decoding (DSCD), a novel method for LLM detoxification without parameter fine-tuning. DSCD strengthens the inner next-token distribution of the safety layer while weakening that of hallucination and toxic layers during output generation. This effectively diminishes toxicity and enhances output safety. DSCD offers lightweight, high compatibility, and plug-and-play capabilities, readily integrating with existing detoxification methods for further performance improvement. Extensive experiments on representative open-source LLMs and public datasets validate DSCD's effectiveness, demonstrating state-of-the-art (SOTA) performance in both detoxification and generation fluency, with superior efficiency compared to existing methods. These results highlight DSCD's potential as a practical and scalable solution for safer LLM deployments.","url_abs":"https://arxiv.org/abs/2510.13183","url_pdf":"https://arxiv.org/pdf/2510.13183","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=2510.13183","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2510.13183"}},"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/ZHANGJINKUI/DSCD","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":7,"ran_draft_wrong":1,"unverified":5},"by_repo_kind":{"found_in_text":{"samples":13,"ran":8,"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":"1adcf2d05b2faed1","entry":"get_imports","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/dynamic_module_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/dynamic_module_utils.py","link_basis":"plan_row","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":"1adcf2d05b2faed1"}},{"code_sha256_prefix":"518f6a89865f25d2","entry":"get_relative_import_files","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/dynamic_module_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/dynamic_module_utils.py","link_basis":"plan_row","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":"518f6a89865f25d2"}},{"code_sha256_prefix":"4af5faa701d0f2c9","entry":"get_relative_imports","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/dynamic_module_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/dynamic_module_utils.py","link_basis":"plan_row","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":"4af5faa701d0f2c9"}},{"code_sha256_prefix":"dd8f7751ef859581","entry":"infer_metric_tags_from_eval_results","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modelcard.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modelcard.py","link_basis":"plan_row","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":"dd8f7751ef859581"}},{"code_sha256_prefix":"e6632a5722f0840d","entry":"parse_keras_history","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modelcard.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modelcard.py","link_basis":"plan_row","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":"e6632a5722f0840d"}},{"code_sha256_prefix":"a66d2b78670c85e1","entry":"quick_gelu","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modeling_flax_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modeling_flax_utils.py","link_basis":"plan_row","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":"a66d2b78670c85e1"}},{"code_sha256_prefix":"f8c65c92ec213846","entry":"read_json","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"run_dscd.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/run_dscd.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f8c65c92ec213846"}},{"code_sha256_prefix":"30d50ff2ced6b7a3","entry":"rename_key_and_reshape_tensor","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modeling_flax_pytorch_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modeling_flax_pytorch_utils.py","link_basis":"plan_row","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":"30d50ff2ced6b7a3"}},{"code_sha256_prefix":"b1260d802f5e3997","entry":"convert_pytorch_state_dict_to_flax","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modeling_flax_pytorch_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modeling_flax_pytorch_utils.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":"b1260d802f5e3997"}},{"code_sha256_prefix":"9d98806acb3144b7","entry":"dtype_byte_size","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modeling_flax_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modeling_flax_utils.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":"9d98806acb3144b7"}},{"code_sha256_prefix":"e3ce70ca9258800e","entry":"flax_shard_checkpoint","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modeling_flax_utils.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modeling_flax_utils.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":"e3ce70ca9258800e"}},{"code_sha256_prefix":"ec7b1528a936234d","entry":"is_hf_dataset","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"transformers/modelcard.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/transformers/modelcard.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":"ec7b1528a936234d"}},{"code_sha256_prefix":"e345e36e3994af05","entry":"predict","repo":"ZHANGJINKUI/DSCD","repo_kind":"found_in_text","path":"run_dscd.py","file_url":"https://github.com/ZHANGJINKUI/DSCD/blob/HEAD/run_dscd.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":"e345e36e3994af05"}}]},"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_api"},"syntology_extracted_results":null}