Sub topic 1
What Counts as Personal Data
Prerequisites
Assume you know basic Python, regular expressions, and the roles of prompts, model responses, and application logs.
What Counts as Personal Data
Personal data is information that identifies a person or can reasonably be linked to one.
- Direct identifiers identify someone by themselves, such as a name, email address, phone number, or government ID.
- Quasi-identifiers identify someone when combined with other data, such as a birth date, postcode, job title, or IP address.
- Sensitive categories need stronger protection because misuse can cause greater harm. Examples include health, financial, biometric, political, and authentication data.
A customer number might look harmless alone but become identifying when joined with a database. Classify data according to its context, not only its format.
| Data | Typical classification | Example |
|---|---|---|
| Email address | Direct identifier | `[email protected]` |
| Postcode and birth date | Quasi-identifier | `90210`, `1988-04-12` |
| Medical diagnosis | Sensitive category | `asthma` |
Where Personal Data Travels in an LLM App
Personal data can enter through a user message, uploaded document, retrieved search result, tool response, or conversation history. It may then appear in the prompt sent to the model, the model's response, traces, analytics, caches, backups, or logs.
Why It Matters: Risks and Obligations
Unnecessary exposure can cause identity theft, discrimination, account compromise, or loss of trust. Data minimization means collecting and sending only what the task requires. Access controls, retention limits, encryption, and provider contracts reduce exposure, but they do not find data automatically.
Detecting Structured Identifiers with Regular Expressions
A regular expression is a pattern that searches text. It works well for predictable formats such as email addresses, but it can miss unusual values and produce false positives.
import re
EMAIL_RE = re.compile(
r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"
)
def find_emails(text):
return [
(match.start(), match.end(), "EMAIL")
for match in EMAIL_RE.finditer(text)
]
print(find_emails("Contact [email protected]"))Exercise
Why might a postcode be personal data even when it contains no name?
Show answer
Combined with other attributes, it can narrow the data to a particular person or small group.