{"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/agentstealth-reinforcing-large-language-model","title":"AgentStealth: Reinforcing Large Language Model for Anonymizing User-generated Text","arxiv_id":"2506.22508","date":"2025-06-26","proceeding":null,"authors":["Chenyang Shao","TianXing Li","Chenhao Pu","Fengli Xu","Yong Li"],"abstract":"In today's digital world, casual user-generated content often contains subtle cues that may inadvertently expose sensitive personal attributes. Such risks underscore the growing importance of effective text anonymization to safeguard individual privacy. However, existing methods either rely on rigid replacements that damage utility or cloud-based LLMs that are costly and pose privacy risks. To address these issues, we explore the use of locally deployed smaller-scale language models (SLMs) for anonymization. Yet training effective SLMs remains challenging due to limited high-quality supervision. To address the challenge, we propose AgentStealth, a self-reinforcing LLM anonymization framework.First, we introduce an adversarial anonymization workflow enhanced by In-context Contrastive Learning and Adaptive Utility-Aware Control. Second, we perform supervised adaptation of SLMs using high-quality data collected from the workflow, which includes both anonymization and attack signals. Finally, we apply online reinforcement learning where the model leverages its internal adversarial feedback to iteratively improve anonymization performance. Experiments on two datasets show that our method outperforms baselines in both anonymization effectiveness (+12.3%) and utility (+6.8%). Our lightweight design supports direct deployment on edge devices, avoiding cloud reliance and communication-based privacy risks. Our code is open-source at https://github.com/tsinghua-fib-lab/AgentStealth.","url_abs":"https://arxiv.org/abs/2506.22508v1","url_pdf":"https://arxiv.org/pdf/2506.22508v1.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":"agentstealth-reinforcing-large-language-model","repo_url":"https://github.com/tsinghua-fib-lab/agentstealth","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"large-language-model","task_name":"Large Language Model"},{"task_slug":"text-anonymization","task_name":"Text Anonymization"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2506.22508","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2506.22508"}},"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":"deterministic:regex_extraction","url":"https://github.com/tsinghua-fib-lab/AgentStealth","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tsinghua-fib-lab/agentstealth","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":9},"by_repo_kind":{"official":{"samples":9,"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":0,"samples":[{"code_sha256_prefix":"17b0f353027f5a92","entry":"build_dataset","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"rl/train_single.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/rl/train_single.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":"17b0f353027f5a92"}},{"code_sha256_prefix":"3372ade9f84532b7","entry":"find_good_anon_levels","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"llama-factory/filter.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/llama-factory/filter.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":"3372ade9f84532b7"}},{"code_sha256_prefix":"dcb1343416f768e8","entry":"llm_response","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"llama_re.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/llama_re.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":"dcb1343416f768e8"}},{"code_sha256_prefix":"c87e60f353c8bbe2","entry":"parse_operation","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"summary_coding.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/summary_coding.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":"c87e60f353c8bbe2"}},{"code_sha256_prefix":"ee098935e8aa1019","entry":"parse_utility_answer","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"src/anonymized/anonymized.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/src/anonymized/anonymized.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":"ee098935e8aa1019"}},{"code_sha256_prefix":"da959e0afec4c3a6","entry":"process_llm_output","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"summary_coding.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/summary_coding.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":"da959e0afec4c3a6"}},{"code_sha256_prefix":"cfa3ed61b3c34083","entry":"prompt_user","repo":"tsinghua-fib-lab/agentstealth","repo_kind":"official","path":"src/anonymized/evaluate_anonymization.py","file_url":"https://github.com/tsinghua-fib-lab/agentstealth/blob/HEAD/src/anonymized/evaluate_anonymization.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":"cfa3ed61b3c34083"}},{"code_sha256_prefix":"ffe71d9e9e19f8dc","entry":"type_to_options","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"llama-factory/filter3.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/llama-factory/filter3.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":"ffe71d9e9e19f8dc"}},{"code_sha256_prefix":"70ac3c4be033e165","entry":"type_to_str","repo":"tsinghua-fib-lab/AgentStealth","repo_kind":"official","path":"summary_coding.py","file_url":"https://github.com/tsinghua-fib-lab/AgentStealth/blob/HEAD/summary_coding.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":"70ac3c4be033e165"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}