Skip to contentRedact PII for your data. Get a quote

Blog

Cleaning datasets for AI training without breaking the joins

Remove personal data from a training set and keep the links between records, so the same person is still the same person.

By Saul Martin · · 4 min read

Before a dataset goes into training, personal data has to come out. The quick way is to delete every value that looks personal, or replace them all with the same [REDACTED]. That removes the values, and it also removes something you need: the relationships between records.

Why relationships matter

A support dataset is rarely one file. There is a CRM export, a ticket history, chat logs and call transcripts. The same customer appears in all of them, under the same email, phone number or account ID.

Those repeated values are what tie the records together. They let you:

  • follow one conversation across channels and teach a model how issues get resolved;
  • count events per person, or deduplicate customers who wrote in twice;
  • split train and test by person, so the same customer is not on both sides and inflating your scores.

Replace every email with the same [REDACTED] and all of that is gone. Every customer becomes the same customer, or no one in particular.

The same placeholder within a call

OpenAnonymizer replaces each value with a typed placeholder instead: <EMAIL_1>, <PHONE_1>, <IBAN_1>. Within one call, the same value always gets the same placeholder, and a different value of the same type gets the next number.

One call: the same email keeps its placeholder
in:  Ticket from ana@example.org. Reply sent to ana@example.org and bo@example.net.
out: Ticket from <EMAIL_1>. Reply sent to <EMAIL_1> and <EMAIL_2>.

So the structure survives inside a document or a conversation. A model trained on it still sees that the second message comes from the same person as the first, and the call returns the mapping so you can audit what was removed.

Keyed placeholders across deliveries

Numbered placeholders restart in every call. That is fine for one document, but a dataset arrives in pieces: this month’s export, next month’s, files from two systems. Here, <EMAIL_1> in one file and <EMAIL_1> in another are unrelated.

For joins across calls, files and deliveries, give the redactor a private key. Each placeholder becomes a tag derived from the key, the type and the value, so the same value gets the same tag every time that key is used, on any machine.

Python: keyed placeholders
from openanonymizer import Redactor

r = Redactor(placeholder_key=b"replace with a long random secret")
r.redact_text("Mi DNI es 53817046J")[0]  # 'Mi DNI es <ES_DNI_ecdac08e393a>'

Run every delivery through a redactor with the same key and the tags line up. You can join files on them exactly as you would have joined on the email.

Three things to get right:

  • Keep the key secret and away from the dataset. Anyone with it can re-identify values by hashing guesses, which is quick for IDs, phone numbers and dates of birth.
  • Use one key per dataset or purpose. Outputs made with the same key can be joined with each other, which you may not want.
  • Keep the default tag length unless a single type holds millions of distinct values; then raise placeholder_length so two values do not share a tag.

Keyed output is pseudonymised, not anonymous. It is still personal data under the GDPR, and should be handled as such.

Finding the values in the first place

Consistent placeholders only help if the values are found. For an export, a missed ID is worse than an extra mask, which is what Full mode is for: on PIIMark v1 it finds 91.8% of structured personal data, against 90.6% for the default Fast mode, and masks something in 13.0% of harmless texts. (Update 4 Dec 2026: Full was called Balanced, then Strict. These figures are for Full as it ships.)

The engine covers 111 national ID and tax number formats from 70 countries, 69 of them confirmed by their check digits (the full list). People’s names are found where the text labels them, such as form fields, signatures and chat speakers; names in running prose stay as written. Quasi-identifiers and special categories are opt-in, for labelled fields in records that name a person.

Text in the library, everything else through our service

The library handles text: documents, chat logs, tickets, logs and records in JSON or tables. It runs in your process, so the data never leaves your machines.

Training data is often more than text. Call recordings, scanned forms, screenshots and video hold personal data too. For those, we run a cleaning service: personal data in audio, images, scans and video is removed, transcripts and text layers get the same placeholder for the same value, and the dataset comes back in the format you sent, with a report of what we removed.

Read how the service works on the dataset cleaning page, and how teams prepare training sets on the AI training data page.