Abstract
AgentStealth is a novel framework designed to train Small Language Models (SLMs) to remove private "fingerprints" from user-generated text while preserving semantic meaning. By employing a self-reinforcing loop where the model learns to defend against an internal "attacker" persona, AgentStealth achieves state-of-the-art anonymization performance. Crucially, the framework is lightweight enough for local deployment on edge devices, addressing the privacy paradox of cloud-based anonymization.
1. Introduction
Sharing text online often inadvertently leaks sensitive personal attributes—such as age, gender, or occupation—through "latent cues." Modern Large Language Models (LLMs) are highly proficient at "author profiling," inferring these attributes even when explicit identifiers are removed. Existing solutions typically fall into two categories: rigid redaction tools that degrade text utility, or cloud-based LLMs that compromise privacy by requiring data transmission to external servers. AgentStealth bridges this gap by creating a high-performing Small Language Model (SLM) capable of on-device anonymization.
2. Methodology
The AgentStealth framework utilizes a three-stage pipeline to transform a standard SLM (specifically Llama-3-8B) into a robust privacy-preserving agent.
2.1 Adversarial Anonymization Workflow
The process begins with a "teacher" model (DeepSeek-V3) generating high-quality training data. This stage incorporates In-context Contrastive Learning, where the model analyzes pairs of successful and failed anonymization attempts. This allows the system to distill "insights"—such as identifying gendered fashion references—into a persistent Memory Module. Adaptive Utility-Aware Control is also employed to maintain text readability.
2.2 Joint Supervised Fine-Tuning (SFT)
The SLM is trained to perform two roles: the Defender (anonymizer) and the Attacker (profiler). By learning to identify sensitive attributes, the model becomes more effective at masking them. This dual-proficiency ensures the model understands the very cues it needs to obscure.
2.3 Online Reinforcement Learning (RL)
Using Group Relative Policy Optimization (GRPO), the model engages in a self-adversarial "duel." It generates multiple anonymized versions of a text and receives rewards based on two criteria: the failure of its internal "attacker" persona to guess private attributes and the maintenance of a high "utility" score (semantic similarity to the original).
3. Experimental Setup
The study utilized two primary synthetic datasets:
- SynthPAI: A Reddit-style corpus annotated with eight personal attributes.
- Synthetic Q&A Pairs: 525 pairs mimicking social media interactions. A total of 200 samples were reserved for testing, with the remainder used for the multi-stage training process.
4. Results and Discussion
AgentStealth demonstrates significant improvements over existing baselines in both privacy protection and text quality.
As shown in the results table, AgentStealth (Workflow+SFT+RL) achieved a 63.7% Anonymity score, representing a 12.3% improvement over the previous state-of-the-art adversarial method (AA). Furthermore, it maintained high utility, with a 6.8% boost in utility scores compared to baseline adversarial methods, ensuring that the anonymized text remains natural and meaningful.
Interestingly, the fine-tuned 8B parameter SLM improved its own "attack" accuracy by 30%, reaching performance levels comparable to the much larger DeepSeek-V3. This confirms that the dual-role training effectively teaches the small model to recognize subtle privacy leaks.
5. Conclusion
AgentStealth provides a powerful, local-first solution for text anonymization. By combining contrastive learning, dual-role SFT, and adversarial RL, it effectively masks latent personal cues without sacrificing text utility. Future work will focus on expanding the diversity of training datasets, testing on various edge hardware, and increasing the breadth of sensitive attributes protected by the framework.
Summary updated