SPY : Enhancing Privacy with Synthetic PII Detection Dataset (2025)

Abstract: We introduce **SPY Dataset**: a novel synthetic dataset for the task of **Personal Identifiable Information (PII) detection**, underscoring the significance of protecting PII in modern data processing. Our research innovates by leveraging Large Language Models (LLMs) to generate a dataset that emulates real-world PII scenarios. Through evaluation, we validate the dataset’s quality, providing a benchmark for PII detection. Comparative analyses reveal that while PII and Named Entity Recognition (NER) share similarities, **dedicated NER models exhibit limitations** when applied to PII-specific contexts. This work contributes to the field by making the generation methodology and the generated dataset publicly, thereby enabling further research and development in this field.

## introduction in the expanding digital realm, the accumulation of personal data has reached unprecedented levels. details encompassing our search queries, online activity, social connections, health records, and more are gathered and disseminated among advertisers, researchers, and government bodies, giving rise to complex privacy concerns about keeping personal information safe. what entities qualify as personally identifiable information? for example, a social security number (ssn) is undoubtedly considered pii, but is a person's name considered pii? @xcite argues that pii is surprisingly difficult to define. historically, ner techniques have been employed for pii detection. however, when security is a primary concern, pii entities constitute a subset of ner entities. for instance, a person's name on a credit card is clearly pii, and revealing this information can indeed cause harm. conversely, † these authors contributed equally to this work. all examples of personal information provided are generated using the faker library @xcite . the name of the lead actress in the titanic movie would likely not cause any harm upon disclosure. in this work, we define pii entities as those that can be used to identify, contact, or locate a specific individual and should not be disclosed to the public due to security concerns. the distinction between pii and ner entities is described in if pii detection and ner are distinct, it implies that data-driven approaches for pii detection require their own specialized dataset. however, creating and sharing a dataset with actual pii entities online is not feasible due to privacy concerns. consequently, there are two options: (1) use a dataset that contains real pii entities and substitute them with fake ones; (2) devise a methodology to generate a completely pii-focused dataset from scratch and then replace the placeholders of pii with fake entities generated by a tool such as faker @xcite , see section 3 for more details. the benefit of the former approach is that it maintains the data's characteristics. the drawback is in ensuring that all genuine pii entities have been accurately replaced. in our work, we opt for the second approach. we used faker to create artificial pii entities and llama-3-70b (ai@meta, 2024) to generate text where these fake entities could be seamlessly integrated. the additional advantage of the fully generated approach lies in having complete control over the generation process. you can tailor it to your specific domain, including designated pii entities and their desired distribution or balance. our contributions can be summarized as follows. ## related work knowledge-based approaches for safeguarding pii like regexp achieve fair accuracy in identifying pii that have a strict and template-based format, but fall short when applied to unstructured text. this is where data-driven approaches, like named entity recognition (ner), come into play. ner models offer greater flexibility in identifying pii in various contexts, particularly when dealing with unstructured data such as names or addresses, by learning from labeled datasets containing examples of pii instances @xcite @xcite . detecting pii requires identifying entities that pose potential privacy risks, which may not always align with conventional ner categories. existing pii detection tools and datasets often fail to distinguish between personal and non-personal entities within the same entity type, essentially performing as traditional ner systems. for example, microsoft's presidio (microsoft, 2021), a popular tool for pii detection, combines ner models with regular expressions and pattern matching. however, this approach labels all entities of a given type (e.g., names) as pii, without differentiating between personal and non-personal entities. similarly, ner-pii @xcite , a pseudonymization tool for structured data, leverages presidio and bert @xcite for pii detection, but shares the same limitations. one of the major challenges in pii detection is the scarcity of publicly available datasets due to privacy concerns. to address this, some approaches replace personal data in real texts with synthetic data, while others generate entirely synthetic texts. below are some of the more popular datasets for pii detection: the bigcode foot_0 pii dataset was created by manually annotation of the stack @xcite dataset. specifically, it targets the identification of pii in programming contexts, making it less suitable for broader text-based pii scenarios. the ai4privacy foot_1 is a synthetic pii dataset created using proprietary algorithms. it spans six languages and eight jurisdictions, with 63 pii classes, making it one of the most comprehensive datasets available. however, its proprietary nature limits transparency, making it difficult to assess the representativeness of the data or adapt it to specific needs. the kaggle pii detection competition (langdon et al., 2024) dataset contains around 22,000 student essays from a massive open online course. unlike other pii datasets mentioned earlier, this one distinguishes between pii and non-pii entities, aligning more closely with the goal of this research. however, it has two significant limitations. first, all essays are written in response to a single assignment prompt, which limits the diversity of the data. second, only 30% of the dataset is publicly available for training, with the remaining 70% reserved for testing, making it unsuitable for a comprehensive evaluation (see figure 2 for detailed statistics). although the dataset provides accurate pii annotations for seven entity types, these limitations in diversity and access make it less ideal for broader applications and thorough evaluations. ## data construction although direct prompting of llms to annotate text data has proven effective for datasets rich in ner entities @xcite @xcite , this approach is less effective in data-scarce environments. when only a small fraction of the dataset contains pii entities, llm-based annotation becomes less efficient due to several challenges: (1) only a small portion of texts in the dataset will receive any annotations, (2) certain entity types will be underrepresented, and (3) the resulting annotations will be highly imbalanced across classes. for example, in the kaggle competition dataset @xcite , only 24% of all essays contain any personal data, and six of the seven entity types have fewer than 110 samples (see figure 2 ), leading to class imbalance and limited representation. to address those constraints, we generate texts that contain placeholders for predetermined sets of personal entities. then we replace these placeholders with pii entities generated by faker -an open-source python library that generates realistic synthetic entities. it can produce a wide range of data types, including names, addresses, emails, dates, and more, supporting multiple locales and customization. we chose two domains: (1) legal -informal questions in legal domain similar to r/legaladvice foot_2 and (2) medical -forms completed by patients for online medical consultations. specifically, we select the following pii entity types: name, email, phone number, personal url, personal identifier, username, and personal address. ## data analysis spy's flexible pipeline for synthetic pii data generation demonstrates several key advantages: even distribution of pii entities: the pipeline ensures that pii entities are evenly distributed throughout the generated texts. this even distribution is visually represented in figure 3 where the entities' positions are spread relatively uniformly across the texts, avoiding clustering in any specific section. ## experimental results first, we verify that spy contains a substantial amount of non-pii entities. to do this, we evaluated uniner @xcite on the name entity type using the prompt shown in following the pipeline presented, we generated two datasets from the legal and medical domains. metrics are calculated specifically for name enity type, using prompts from the original uniner paper @xcite : "what describes a person in the text?" the encoder model specifically trained to detect pii entities outperforms the general ner models, confirming the fact that the task of pii detection is not equivalent to ner. the distinction between them can be effectively learned by a supervised classification model. ## conclusions in this study, we discuss the critical issue of pii detection, highlighting its importance in the realm of data privacy and security. we underscore the distinction between pii detection and ner, emphasizing that while related, pii detection carries unique nuances and requirements. we highlight the disadvantages of existing datasets and pii tools and provide a robust methodology for creating diverse training datasets tailored for pii detection. our approach is based on employing llm to generate data and does not require human supervision. these advancements reinforce our commitment to safeguarding personal data, a significant area in today's digital landscape. the generated dataset can be utilized to finetune the pii model independently or within the deeppavlov framework @xcite . to encourage research in the field, we make the spy dataset freely available.