Detecting private data using extraction + decision models
Overview
When building RL environments, one of your worst nightmares is to realize that your tasks leaked personally identifiable information. To prevent this from happening, I compared a specially trained model (OpenAI's Privacy Filter), a general extraction model (Cloudflare's Clairic), and the same extraction model followed by a decision model (TypeSafe's Jev) on the Text Anonymization Benchmark (TAB).
Combining extraction and decision models performs better on almost all metrics compared to using only a specially trained model or an extraction model.
Setup
The bench used was the test split of TAB. It has 127 judgments from the European Court of Human Rights. Each document has annotator marks for identities that should be hidden.
PROCEDURE
The case originated in an application (no. 36110/97) against the Republic of Turkey lodged with the European Commission of Human Rights (“the Commission”) under former Article 25 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by four Turkish nationals, Mr Galip Yalman, Mr Bahattin Sarısoy, Mr Osman Çağlayan and Mr Yusuf Çamca (“the applicants”), on 29 November 1996.
The applicants were represented by Mr S. Esmer, a lawyer practising in Ankara. The Turkish Government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Convention institutions.
The test measures recall on two types of identifiable information, applicant names and case IDs, and precision across all identified spans. The code is accessible here: clavia-labs/private-data-detection. I hosted OpenAI's model on Baseten.
OpenAI Privacy Filter
Privacy Filter is an open-weight token classification model specially trained to redact personal data. It labels each token in the given text as one of eight categories, such as private_person or account_number, or as none. The input was the entire judgment, which is a court's written decision on a case. TAB keeps only the opening sections, the procedure and the facts, about 4,000 characters each. For example, here's a snippet from a judgment:
The case originated in an application (no. 10424/05) against the Republic of Turkey lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Russian national, Mr Ruslan Kurkaev (“the applicant”), on 21 March 2005.
The applicant was represented by Mr H. K. Elban, a lawyer practising in Istanbul.
and the output looks like this:
{
"detected_spans": [
{
"label": "private_person",
"start": 343,
"end": 357,
"text": "Mr H. K. Elban",
"placeholder": "<PRIVATE_PERSON>"
}
],
"redacted_text": "… by a Russian national, Mr Ruslan Kurkaev (“the applicant”), on 21 March 2005.\n\nThe applicant was represented by <PRIVATE_PERSON>, a lawyer practising in Istanbul."
}
It hid the lawyer but missed the applicant, Ruslan Kurkaev, and the case number.
Clairic
Clairic is a general extraction model. Cloudflare describes it as a System One-style model that returns typed answers with confidence scores. In the Clairic only setup, the model was passed a full judgment at a time and asked to extract the personally identifiable information. The instruction for names, one of eight categories, was:
"Every name of a private person, including usernames and handles that identify a specific person."
The output looked something like this:
{
"private_person": {
"value": ["Mr", "Ruslan Kurkaev", "H. K. Elban"],
"spans": [[254, 256], [257, 271], [346, 357]]
},
"account_number": { "value": ["10424/05", …], "spans": [[54, 62], …] },
"private_address": { "value": ["Turkey", "Istanbul", …], "spans": [[88, 94], [382, 390], …] },
"private_date": { "value": ["1", "21 March 2005", …], "spans": [[54, 55], [294, 307], …] }
}
Clairic + Jev
Jev is a decision model that is trained to return probabilities over a fixed set of choices. In this setup, the first step used Clairic as described above. This was followed by a hide or keep decision from Jev. The full judgment was passed, with the extracted entity marked inside about 160 characters of surrounding text, and the name of the person to protect. For example, the prompt looked like this:
To anonymise this judgment for Ruslan Kurkaev, should the marked text be hidden?
…by a Russian national, Mr [[Ruslan Kurkaev]] (“the applicant”), on 21 March 2005. The applicant was represented by…
- hide: Hide it: on its own or with other details in the judgment, it could help someone identify Ruslan Kurkaev.
- keep: Keep it: it would not help identify Ruslan Kurkaev.
The output was like:
| Extracted by Clairic | Jev | p(hide) |
|---|---|---|
| 10424/05 | hide | 0.93 |
| Ruslan Kurkaev | hide | 0.91 |
| H. K. Elban | hide | 0.61 |
| 21 March 2005 | hide | 0.53 |
| Mr | keep | 0.47 |
| Turkey | keep | 0.39 |
| Istanbul | keep | 0.22 |
Results
Precision
Clairic captures more identities in general, but it is less precise. Of all identified spans, only 78% were marked to be hidden by annotators, against 93% for OpenAI's model. However, this is mostly fixed by using it along with a decision model. Following up Clairic's extracted result with Jev increased precision to 91%.
Precision
Share of flagged spans that annotators marked to hide
Recall
Combining with Jev also retains the recall scores of Clairic alone across both identity types. On applicant names, OpenAI's model marked 77% of identities, with 96% for Clairic alone and Clairic + Jev. On case IDs, they both did 96% with OpenAI performing particularly poorly at 2.2%. It seems like OpenAI does not consider case IDs as private, even though anyone can use this to look up the applicant's name. Their model card notes that it can miss domain-specific identifiers.
Recall
Share of annotated identities each approach found
- OpenAI Privacy Filter
- Cloudflare Clairic
- Clairic + Jev
Cost
Clairic was the cheapest, at $0.17 for 1000 judgments. OpenAI came next, at $0.26. Combining Clairic and Jev cost the most, at $0.86.
Cost per 1,000 judgments
USD, lower is better
Conclusion
Bitter lesson strikes again? Combining general purpose extraction and decision models beats a specialized model at detecting private data. While these results only measure it for the legal domain, my hunch is that this approach of combining extraction and decision models generalizes across domains.