Sub topic 1
What counts as personal data
Personal data is any information that relates to an identified or identifiable person. Before you write a detector, you need a working classification of what you are detecting. This chapter gives you one, and it sets up the labels that later chapters use for spans.
Prerequisites
This chapter assumes you have:
- Basic Python (functions, lists, dictionaries).
- Regular expression basics.
- Familiarity with calling an LLM API or chat model.
- A general idea of what a prompt, a response, and a log are.
No code runs in this chapter. The classification you learn here decides which detector you build for each kind of data.
Three categories of personal data
Detection work is easier when you sort data by how it identifies someone. Three categories cover most cases.
Direct identifiers
A direct identifier points to one person on its own. Examples are a full name, an email address, a phone number, a passport number, a credit card number, and a national ID number.
Many of these have a fixed format. That makes them good targets for regular expressions and checksums, which come in later chapters.
Quasi-identifiers
A quasi-identifier does not identify a person alone, but it can do so when combined with other facts. Examples are a birth date, a postal code, a job title, an employer, and a gender.
A well-known result from privacy research found that many people in a population can be singled out by just date of birth, gender, and postal code. Each field looks harmless. The combination is not.
Quasi-identifiers are hard to detect. They have no fixed format, and their risk depends on context.
Sensitive categories
Some data is sensitive because of what it reveals, not because of how it identifies. Examples are health conditions, religion, political views, sexual orientation, biometric data, and financial details. Many privacy laws give these categories stricter protection.
A sensitive category can appear in free text with no identifier next to it. Once a name appears in the same message, the two together become high risk.
| Category | Examples | Typical detection approach |
|---|---|---|
| Direct identifier | Email, phone, card number | Regex, plus a checksum where one exists |
| Direct identifier | Person name, street address | Named-entity recognition (NER) |
| Quasi-identifier | Birth date, postal code, job title | Patterns and NER, with context rules |
| Sensitive category | Diagnosis, religion | Hard. Keyword lists, classifiers, or human review |
Context decides the label
The same string can be personal data in one place and harmless in another. Consider "Jordan".
- "Ask Jordan to approve the invoice" is a person's name.
- "The river Jordan flows south" is a place.
- "Michael Jordan" is a famous person, but the text may still be about a different private individual with that name.
A 16-digit number might be a card number or an order ID. A detector that looks only at characters cannot always tell. This is why later chapters combine several detectors and validate matches.
Labels for your detectors
In the rest of this tutorial, each detector returns spans of the form (start, end, label). Choose label names that match your categories, such as EMAIL, PHONE, CREDIT_CARD, PERSON, and LOCATION. Consistent labels let you apply different redaction rules per category later.
Common mistakes
- Treating only emails and card numbers as personal data. Names, addresses, and free-text details count too.
- Ignoring quasi-identifiers because each one looks harmless alone.
- Assuming that removing the name makes a text anonymous. A rare job title in a small town can still identify someone.
- Forgetting that users type personal data into prompts without being asked to.
Exercise
A support message reads: "I'm the only cardiologist at the clinic in Tromsø, and my email is [email protected]." Classify each part as a direct identifier, quasi-identifier, or sensitive category, and say which ones a regex alone could find.
Show answer
"[email protected]" is a direct identifier, and a regex can find it. "Cardiologist" (job title) and "clinic in Tromsø" (workplace and place) are quasi-identifiers. Together with "only" they can single out one person. A regex cannot find them reliably, so you need NER or context rules. The message has no sensitive category on its own, although a health-related detail added to it would create one.