Abstract
The increased use of text data in social science research has benefited from easy-to-access data (e.g., Twitter). That trend comes at the cost of research requiring sensitive but hard-to-share data (e.g., interview data, police reports, electronic health records). We introduce a solution to that stalemate with the open-source text anonymisation software Textwash. This paper presents the empirical evaluation of the tool using the TILD criteria: a technical evaluation (how accurate is the tool?), an information loss evaluation (how much information is lost in the anonymisation process?) and a de-anonymisation test (can humans identify individuals from anonymised text data?). The findings suggest that Textwash performs similar to state-of-the-art entity recognition models and introduces a negligible information loss of 0.84%. For the de-anonymisation test, we tasked humans to identify individuals by name from a dataset of crowdsourced person descriptions of very famous, semi-famous and non-existing individuals. The de-anonymisation rate ranged from 1.01-2.01% for the realistic use cases of the tool. We replicated the findings in a second study and concluded that Textwash succeeds in removing potentially sensitive information that renders detailed person descriptions practically anonymous.
Introduction
Social and behavioral scientists are currently caught in a dilemma: the field has an increasing appetite for large-scale text data, such as interview transcripts or police reports, but this data is often too sensitive to share due to ethical concerns and regulations like GDPR. Manual anonymization is prohibitively expensive and slow for large datasets. Meanwhile, existing automated tools often suffer from context destruction, a narrow scope that misses "soft" identifiers, and a lack of rigorous validation against human "motivated intruders."
Textwash is a new open-source tool designed to break this stalemate. By leveraging BERT-based machine learning, it identifies and replaces sensitive information with context-preserving tokens, maintaining the data's utility for NLP research while rendering individuals practically unidentifiable in realistic use cases.
The Textwash Pipeline
Textwash operates in a two-stage pipeline designed to balance privacy with data utility.
- Identification: The tool uses a fine-tuned BERT (Bidirectional Encoder Representations from Transformers) model to perform Named Entity Recognition (NER). Unlike standard NER, it targets a broader category termed Potentially Sensitive Information (PSI), which includes not just names and dates, but also occupations and other identifying attributes.
- Replacement: Instead of simple redaction (e.g., "XXX"), Textwash uses category-specific, indexed placeholders (e.g.,
[firstname1],[location2]). This preserves the grammatical structure and semantic "flow" of the text, ensuring it remains useful for downstream tasks like sentiment analysis.
Crucially, the tool is designed to run offline. This ensures that sensitive data never leaves the researcher's local machine, satisfying strict data protection requirements.
Methodology and Evaluation
The model was trained on a diverse corpus of 3,717 articles sourced from the British National Corpus (BNC), the Enron Email Dataset, and Wikipedia biographies. Evaluation was conducted using the TILD criteria:
- Technical Performance: The model achieved a weighted F1-score of 0.93 across 12 categories, performing on par with state-of-the-art NER models.
- Information Loss: When running sentiment analysis on anonymized vs. original data (using IMDb movie reviews), the utility loss was only 0.84%.
- De-anonymisation Test: In human "motivated intruder" tests, the de-anonymization rate for realistic use cases (semi-famous or non-existing people) was incredibly low, between 1.01% and 2.01%.
Discussion and Limitations
A major challenge highlighted by the research is the "Adele Problem": for global celebrities, anonymization is nearly impossible. Even if names are removed, unique life stories act as "soft" identifiers that the model cannot redact without destroying the text's meaning. For "very famous" individuals, the de-anonymization rate jumped to ~18-26%.
Future work will focus on "token-consistent" replacement across entire datasets (ensuring the same entity is replaced by the same placeholder across multiple documents) and incorporating active learning modules to improve accuracy over time through human feedback.
Textwash is available as an open-source Python project on GitHub.
Summary updated