π arXiv Β Β |Β Β π‘οΈ Intent-Aware Privacy Protection Β Β |Β Β π€ Large Language Models
IntentAnony is a pragmatic intent-conditioned text anonymization framework built on large language models (LLMs).
It protects user privacy under inference-based threat models while preserving communicative intent and textual utility.
Unlike surface-level masking or generic rewriting, IntentAnony selectively suppresses non-intent privacy evidence, ensuring that only information irrelevant to the userβs communicative intent is anonymized.
- π― Intent-aware anonymization rather than blanket masking
- π‘οΈ Defense against attribute inference and profiling attacks
- π Integrated privacyβutility evaluation (automatic + human)
- π Supports multiple anonymization strategies and threat settings
IntentAnony_Updated/
βββ anonymized/ # Core anonymization module
β βββ anonymizers/ # Anonymizer implementations
β βββ run_workflow.py # End-to-end anonymization workflow
β βββ eval_workflow.py # Privacy & utility evaluation workflow
βββ configs/ # Configuration definitions
β βββ config.py # Configuration class
βββ privacy_configs/ # Example privacy task configurations
βββ prompt_kits/ # Prompt management and policies
β βββ prompts/ # Prompt templates
β βββ policy_manager.py # Policy manager
βββ llm_tools/ # LLM provider wrappers
β βββ openai_tool.py
β βββ async_openai_tool.py
βββ pu_eval/ # Privacy & utility evaluation
β βββ eval_privacy.py
β βββ eval_utility.py
β βββ async_eval_utility.py
βββ infer_attack/ # Inference attack implementations
βββ utils/ # Shared utility functions
βββ dataset/ # Datasets
βββ main.py # Main entry point
βββ requirements.txt # Dependencies
- Python β₯ 3.8
- MongoDB (optional, for dataset storage and experiment logging)
- Sufficient API quotas for supported LLM providers (OpenAI, DeepSeek, Google, GLM, etc.)
git clone <repository-url>
cd IntentAnonypython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtimport nltk
nltk.download('punkt')Create or edit llm_tools/keys.json:
{
"openai": "sk-your-openai-api-key",
"deepseek": "sk-your-deepseek-api-key",
"google": "your-gemini-api-key",
"glm": "sk-your-glm-api-key"
}Note
- Only include providers you intend to use
- Keys are automatically loaded when initializing LLM tools
export MONGODB_HOST="localhost"
export MONGODB_PORT="27017"Run a complete anonymization β inference β evaluation pipeline:
python main.py \
--config_path ./privacy_configs/personal_reddit/synthetic_glm_ad_piec.yaml \
--newConfiguration files are written in YAML and include:
output_dir: "results"
seed: 10
task: "ANONYMIZED"
dataset_name: "personal_reddit"
collection_name: "personal_reddit"
task_config:
profile_path: "dataset/..."
outpath: "results/..."
anonymizer:
anon_type: "llm"
target_mode: "single"
anon_model:
name: "gemini-3-pro-preview"
provider: "google"
prompt_policy_version: "7.0"
inference_model:
name: "deepseek-reasoner"
provider: "deepseek"
utility_model:
name: "deepseek-chat"
provider: "deepseek"- IntentAnonymizer β intent-aware selective anonymization
- PIECAnonymizer β privacy inference evidence chain suppression
- AzureAnonymizer β Azure text analytics anonymizer
- Privacy Evaluation β inference success & protection rate
- Utility Evaluation β BLEU, ROUGE, LLM Judge
- Attack Evaluation β adversarial inference success rate
Supported providers include:
- OpenAI (GPT series)
- DeepSeek
- Google (Gemini)
- GLM
- Claude
- Custom providers
- Structured prompt organization
- Multi-language support
- Prompt versioning and policy control
- Inference Accuracy
- Privacy Protection Rate
- BLEU
- ROUGE-1 / ROUGE-L / ROUGE-Lsum
- LLM Judge (readability, semantic preservation, hallucination)
from anonymized.run_workflow import run_anon_infer_eval
from utils.initialization import read_config_from_yaml
import asyncio
cfg = read_config_from_yaml("configs/my_config.yaml")
asyncio.run(run_anon_infer_eval(cfg, {}))from anonymized.run import batch_evaluate_utility
from llm_tools.async_openai_tool import create_async_any_tool
from prompt_kits.prompt_manager_final import get_manager
from utils.mongo_utils import MongoDBConnector
import asyncio
prompt_manager = get_manager(default_category="eval_utility")
llm_model = create_async_any_tool(model="gpt-5", provider="openai")
mongo = MongoDBConnector()
mongo.connect()
profiles = mongo.read_data("personal_reddit", query={...})
stats = asyncio.run(batch_evaluate_utility(
profiles=profiles,
prompt_manager=prompt_manager,
llm_model=llm_model,
mongo=mongo
))- Ensure all required API keys are correctly set
- MongoDB must be running if enabled
- Input data should follow the expected JSONL format
We thank the authors of
LLM-Anonymization
for releasing their code and inspiring this work.
If you use this code, please consider citing our work:
@article{intentanony2026,
title = {You Only Anonymize What Is Not Intent-Relevant: Suppressing Non-Intent Privacy Evidence},
author = {Shen, Weihao and Xu, Yaxin and Li, Shuang and Chen, Wei and Lan, Yuqin and Yuan, Meng and Zhuang, Fuzhen},
journal = {arXiv preprint arXiv:2601.04265},
year = {2026}
}