The idea
Prompts and traces often contain personal data: names, emails, phone numbers, addresses, account and ID numbers. Sending it to third-party models and storing it in logs creates privacy and compliance obligations (GDPR in Europe, among others).
Redaction detects PII and replaces it with placeholders, either irreversibly (for logs) or reversibly with a mapping kept on your side (pseudonymisation), so the model works with <PERSON_1> and you restore real values in the final output.
Use a detector like Microsoft Presidio (regex + NER models), tune it for your locale (Irish PPS numbers, Eircodes), and test both misses and over-redaction.
It reduces the blast radius of a breach and is often a requirement to use cloud models with customer data.
Words to know
- PIIPersonally identifiable information.
- PseudonymisationReplacing identifiers with reversible placeholders.
Try it without code
Spot PII
- Take 10 real-looking support messages.
- Highlight every piece of personal data.
- Decide which the model actually needs to see.
Use it in code
Detect and anonymise with Presidio.
# pip install presidio-analyzer presidio-anonymizer ; python -m spacy download en_core_web_lg
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
text = "Hi, I'm Aoife Byrne, call me on 087 123 4567 or aoife@example.ie about order 5531."
analyzer, anonymizer = AnalyzerEngine(), AnonymizerEngine()
findings = analyzer.analyze(text=text, language="en")
print(anonymizer.anonymize(text=text, analyzer_results=findings).text)
# -> "Hi, I'm <PERSON>, call me on <PHONE_NUMBER> or <EMAIL_ADDRESS> about order 5531."Redact PII from all traces in your app before they are stored, and add a test with Irish-format phone numbers.
Common mistakes
- Redacting logs but sending raw PII to the model unnecessarily.
- Assuming default detectors handle your country’s formats.