Applied AI
Meddies-PII: Synthetic Data for Multilingual Clinical De-identification
The synthetic data pipeline behind a compact PII model for clinical text: 1M documents in 17 languages, filtered by 13 deterministic validation gates.
At a glance
- synthetic clinical documents
- 1M
- 17 languages in the published dataset, 9 PII labels
- deterministic validation gates
- 13
- regex, character-offset parser, rule checks, SHA-256 de-duplication
- mean exact-match micro-F1
- 0.827
- downstream 350M model on 15 external benchmarks; strongest baseline (OpenAI Privacy Filter) 0.658
- F1 on adversarial benchmark
- 0.878
- 5,100 documents; baseline 0.540
Problem#
Clinical conversations are full of names, phone numbers, patient IDs and insurance numbers. Before that text can be summarised, analysed or used for training, those details have to be found and masked, in every language the product supports.
A model that does this needs labelled examples, and real patient records are exactly what you can’t pass around. So everything depends on synthetic clinical documents: realistic enough to learn from, with labels that are exactly right.
My role#
I designed and maintain the data pipeline. My teammates trained the model, and I’m co-first author of the paper describing the framework (arXiv:2609.12544).
The hard part#
In healthcare, one missed name is already a privacy leak, so “good enough” doesn’t exist. I kept optimising the data, round after round. The model also needed a lot of data, and varied data: realistic names, IDs and addresses for many countries, not the same few patterns repeated.
A decision I made#
Off-the-shelf fake-data libraries couldn’t give that variety, so I built my own: meddies-faker, which samples names and personal details from real population statistics. It took far more research than I expected, and it’s the part of this project I’m proudest of.
The other key choice was deterministic checks over an AI judge for the labels. A label has to point at exactly the right characters; a judge model can’t guarantee that, but a parser can.
How it works#
Generation is attribute-conditioned: each document is sampled from 12 medical document types, 11 formats and 12 scenarios, with the personal details chosen before the text is written. A pool of 9 LLMs writes the documents, so no single model’s style dominates. Every record then passes 13 deterministic validation gates: regex checks, a character-level offset parser, rule checks and SHA-256 de-duplication. A conservative auto-repair loop fixes what it safely can and re-checks it; anything else is dropped.
Results#
The data trains Meddies-PII-Model, a 350M-parameter (LFM2.5) BIOES token classifier with constrained Viterbi decoding:
| Benchmark | Meddies-PII | Strongest baseline |
|---|---|---|
| 15 external benchmarks (mean exact-match micro-F1) | 0.827 | 0.658 (OpenAI Privacy Filter) |
| 5,100-document adversarial set | 0.878 | 0.540 |
Exact match means a prediction only counts if both the span and the label are right. The external benchmarks were not produced by this pipeline.
What I learned#
The rules about what counts as personal data have to shape how the data, and so the model, is made from the start.
Limitations: what this does not prove#
- The scores measure a model trained on this data, so they mix data and modelling choices.
- Public benchmarks may not match real Meddies conversations.
- Synthetic data can carry the generators’ own biases.
- A high F1 isn’t the same as compliance with a privacy law; de-identification still needs process and human review.
What I’d do next#
Keep optimising, because in this domain the last few errors matter most. The current pipeline already covers 20 languages, with personal details from meddies-faker sampled from real distributions for 18 countries.