learning-it by example

Back to the video

Redact Personal Data Before Your LLM Sees It (Python)

Patterns found 5 of 8 pieces of personal data, a local model found the rest, and one wrong answer taught me something. A redaction step you can score.

Video #19 ยท AI security and governance

Steps in the video

  1. 0:00 Personal data in an AI app
  2. 0:28 Why remove it
  3. 0:55 Setup
  4. 1:14 Tickets with answers
  5. 1:44 Patterns for shaped data
  6. 2:00 The card check
  7. 2:45 A model for names and addresses
  8. 3:25 Put it together
  9. 4:26 What this does not show
  10. 5:07 Mistakes to avoid
  11. 5:34 My take and next steps
  12. 5:57 Recap

Files

  • llm_find.py (38 lines)
  • patterns.py (26 lines)
  • redact.py (22 lines)
  • score_regex.py (16 lines)
  • tickets.py (30 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3

What this does not show

Four made-up tickets with eight known items, one small local model, UK formats only, one run. A passing score on this set is not compliance and not legal advice. The model returned one wrong item and can miss or reword names. The article on pattern limits is from Protecto, a vendor of data privacy software.

Sources

Learning IT by Example.