Learn AI/Responsible AI
LESSON 29 / 36Intermediate 30 min with practice

Privacy starts with the data you do not collect

Design an experiment with minimal records and deliberate retention.

WHAT YOU WILL LEARN
  • Distinguish redaction from anonymization
  • Minimize collected fields
  • Separate debugging from raw-content logging

Reduce exposure at collection time

Before collecting a field, explain what decision it supports and how long it is needed. A lesson recommendation experiment may need topic choices and completion counts, but not a learner’s private messages. Reducing fields simplifies both the system and its risk.

A hash is not automatic anonymization. Predictable identifiers such as email addresses can be guessed and hashed again. Combining several harmless-looking attributes may also identify someone. Use precise terms such as pseudonymized when re-identification remains possible.

Redaction is one layer

Pattern matching can remove obvious identifiers from logs, but misses unusual formatting and context-dependent personal information. Treat it as a convenience layer, not proof that text is safe to publish.

Prefer structured diagnostic events: operation name, duration, status, and a request ID. Restrict log access and choose a retention window. Apply the same care to prompts, retrieved passages, generated outputs, and evaluation datasets.

PUT THE IDEA INTO CODE

A small experiment you can run.

The email is invented. The regular expression demonstrates a narrow pattern and should not be presented as comprehensive anonymization.

privacy-and-data-minimization.py
import re
text = "Contact learner@example.test about lesson 3."
redacted = re.sub(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}", "[email removed]", text)
event = {"operation": "lesson_search", "status": "ok", "duration_ms": 12}
print(redacted)
print(event)
Copy code

Save the file, open your terminal in that folder, and run python privacy-and-data-minimization.py. Use python3 or py if required by your installation. Setup guide

What to expect

The example email is replaced, while the structured event contains no message text.

YOUR TURN

Create a minimal analytics event.

  1. List five fields you might collect.
  2. Remove fields that are not required to answer a concrete product question.
  3. Choose a retention period and explain who needs access.
Compare with a suggested solution

For a completion counter, lesson ID and a coarse date may be sufficient. A raw prompt, email address, and full IP address are not automatically necessary. Requirements vary, so document the purpose rather than collecting everything by default.

CHECK YOUR UNDERSTANDING

One idea to take with you.

Does replacing email addresses make arbitrary text anonymous?

Make it part of your progress.

Finish the practice and answer the knowledge check to mark this lesson complete.

Go deeper with primary documentation

Optional references for further study. This lesson and its examples were written for Artificials.

NIST AI Risk Management Framework