Skip to content
AI Engineering
Evals, Observability & Safety

Misuse, privacy and moderation

People will try to make your system do things it should not, and it will handle their data. Plan for both before launch.

Chapter 11: Evals, Observability & SafetyLesson 11 of 11Level: CoreAbout 12 min
Words on this page (7)
training
: Adjusting a model's parameters on data so its predictions improve.
prompt
: The input text you give a model, including instructions, examples and data.
least privilege
: Giving a person or program only the access it needs for the job and nothing more.
prompt injection
: Untrusted text that contains instructions the model follows, such as a web page telling it to leak data.
logarithm
: The power you raise a base to in order to get a number. log base 2 of 8 is 3 because 2 to the power 3 is 8.
sampling
: Picking the next token at random according to the model's probabilities.
system prompt
: Standing instructions placed at the start of every call that set the model's role and rules.

Privacy and security

Do not send data to a provider you have not vetted. Know its retention and terms. Classify your data (public, internal, confidential, regulated) and set rules for which classes may reach which models. Redact personal data from and logs. Pass an end-user identifier with each request, where the provider supports it, so abuse can be traced to one account instead of your whole product. Limit what the system can reach: applies to models as much as to people.

Misuse and content

Run a moderation check on inputs and outputs for the harmful categories that matter to your product. Many providers offer a free endpoint, and you can add your own classifier. Red-team the system: have people and scripts try to break the rules, including , and add every success to your regression test set. Give users a way to report problems, and read the reports.

A worked example: a launch checklist

For a public chat feature: a moderation call on every user message and every reply. An end-user id on every request. A daily spend cap and a rate limit per user, so an attacker cannot run up your bill. Logs with names and emails redacted, kept for 30 days. Fifty red-team prompts in the test set, rerun on every release. A visible "report this answer" button wired to a queue someone reads.

Why limits come in layers

Invented numbers: a script sends 10 requests a second, and each request costs one cent. That is 10 cents a second, $360 an hour, $8,640 a day.

A per-user limit of 20 requests an hour caps one account at 20 cents an hour. But an attacker with 50 accounts can still spend $10 an hour. So also add a daily spend cap, for example $100, which bounds the worst case. Each layer covers a hole in the others.

What goes wrong: redaction misses

Redaction replaces personal details with placeholders before text leaves your system. "Write to dana@example.com" becomes "Write to [EMAIL_1]". Your code keeps the mapping and restores it in the reply.

Pattern-based redaction handles emails and phone numbers well. Names are harder. Symptom: personal data shows up in your logs. To confirm, sample 100 lines and count the leaks. Invented result: 3 of 100. Fix the patterns, repeat, and keep .

What goes wrong: blocking too much

A moderation filter tuned to be strict also blocks a nurse asking about drug doses, or a novelist writing a crime scene. Symptom: complaints from legitimate users. Confirm by reading a sample of blocked messages. If many are harmless, loosen the setting for that category or add a human review path.

Common mistake

Relying on the alone to stop misuse. A prompt can be overridden. Rules that matter belong in code, permissions and monitoring.

Check yourself

Why send an end-user identifier with each request to the provider?

A red-team prompt gets past your safeguards. What should you do with it?

Where should the rules that must never break live?

Go deeper

Spotted a mistake or something unclear? Report it on GitHub.

On this page