AiQAI Qualitatively

A field log from a qualitative research team

How we de-identify

Done by hand, de-identifying transcripts is slow and tedious. We wanted to speed it up, while making sure that none of our sensitive data was handed to an LLM. So we wrote a program that runs on our own computer.

What is the program?

A Python script. It runs on our own computer, so the transcript is never sent anywhere.

It works in two passes. In the first pass it reads the spreadsheet and searches each transcript for every real name and nickname in it. Each exact match is replaced with that person's pseudonym, and the replacement is written to a log. Names on the public-figures list are skipped.

In the second pass it runs Presidio over the result, explained further down. Presidio does not change the transcript. It produces a list of words that look like names and were not replaced, and a person decides what to do with each one.

To build your own, install Python, make the spreadsheet (one column for the real name, one for the pseudonym), and ask an LLM to write a script that does the replacement and keeps a log. The spreadsheet is the key to the whole dataset, so store it wherever your identified data is stored.

A spreadsheet pairs every real name with a pseudonym

At the heart of it is a spreadsheet we built, with every real name and nickname paired to a pseudonym. Choosing a pseudonym for every named subject would allow us to follow this person throughout the interview corpus while keeping their identity safe. The program goes through every transcript and replaces the real names with their pseudonyms. We also gave it a list of public figures who come up in our corpus, so it leaves those names alone, since those people do not need their identities protected.

The crosswalk spreadsheet, pairing real names to pseudonyms with an action column
The crosswalk. The green rows are deliberately not replaced: a public figure, a gang name, and a street, because gang names are the subject of the research and the scope is people and groups rather than places. The amber row is a name nobody has resolved yet, left unassigned with a reason rather than guessed at. Every name here is invented.

A second tool points to names we missed

After that, a second step checks our work and suggests any names we might have missed. We run a tool called Presidio, which is open source and finds personal information in text using a name-recognition model. We downloaded it and run it on our own machine, so the information that runs through it stays local. It reads back over the transcript and points us to any name it thinks we have missed, ignoring the pseudonyms we already put in and the public figures on our list.

How does Presidio work, and how do I get it?

Presidio is a free, open-source Python library made by Microsoft for finding personal information in text. It finds names with named-entity recognition: a language model reads each sentence and labels the words that look like a person, a place or an organization. The model we use is en_core_web_lg from spaCy, another open-source library. Presidio also has pattern rules for things with a fixed shape, like phone numbers and email addresses.

To install both on your own computer, run these two commands in a terminal:

pip install presidio-analyzer presidio-anonymizer
python -m spacy download en_core_web_lg

After that it runs offline. Presidio was built for documents like medical records and business files, and it was not trained on how our subjects speak. In our transcripts it misses nicknames and flags street names and group names that are not people. That is why the spreadsheet does the replacing and Presidio only checks.

A person still reads every transcript

At the end, a person read the whole transcript to be sure it was fully de-identified. The program does not replace that check. It just makes the process much quicker.

Want to know more? How we keep interview data secure