# Safety for Text-to-Image

> How text-to-image models are kept from drawing harmful pictures, where each safety layer can fail, and what to say in your AI interview.

**In short:** Text-to-image safety means stopping a model from drawing harmful pictures, such as sexual or violent images and fake photos of real people. It uses layers of checks, and no single layer is enough, so teams also test with attackers.

AI and LLM interview question Q453, Multimodal and newer topics. Beginner, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/safety-for-text-to-image

## Say it in 30 seconds

Text-to-image safety means stopping the model from drawing harmful pictures, like sexual or violent images, or fake photos of real people. I use layers. I clean the training data, check the prompt, check the picture before anyone sees it, and mark AI images so people can tell. No single layer catches everything, because attackers rephrase until one slips through. So I test the whole system with red teams and keep watching for new bypasses.

## Say it in 2 minutes

A text-to-image model turns a written prompt into a picture. That makes safety a question of what it draws and who could be hurt by it. The main harms are graphic violence, sexual content, hateful imagery, and realistic fakes of real people that can pass as evidence.

I never rely on one filter. First, the training data: OpenAI filtered violent and sexual images out of DALL·E 2's training set, and found that the filter also made some unfair skews worse. Second, the prompt: a text check blocks risky wording. Third, the picture itself: an image check scans the output before a user sees it.

Filters can be beaten. SneakyPrompt automated a loop that tries a wording, reads the result and changes the wording again. So I red-team the system with people who know the defences, and I keep watching the logs.

For fakes, I mark the picture. SynthID embeds a watermark in AI output, and the AI Act's transparency duties apply from 2 August 2026. A watermark only shows that a participating tool made the file, so it is one signal among several.

## What is text-to-image safety, in plain words?

A text-to-image model reads a sentence, called a prompt, and draws a picture that matches it. Safety means that picture should not cause harm. The main harms are graphic violence, sexual content, hateful imagery, and realistic fakes of real people, which can pass as evidence.

Think of a hospital pharmacy. One person checks the prescription, another checks the dose, and a third checks the label before anything leaves the counter. Each check misses things, so the hospital runs all three. Image teams do the same, with several checks before and after the picture is made.

Here is the same job at work. Say a retailer's marketing team (a made-up company) uses an in-house tool for ad pictures. Someone under deadline types a request the tool should refuse, and it has to refuse it even when the wording is clever.

- **Training data:** The pictures and captions the model learned from.
- **Safety filter:** A check that blocks or flags a prompt or a picture.
- **Red teaming:** Testing a system by trying to break it, the way an attacker would.
- **Watermark:** A hidden mark in a picture that a checker can detect later.

## Which layers stop a harmful picture?

Each layer catches a different failure, and each one has a gap. The chart runs one request through them. Orange is the harm, blue the checks, violet the model and green the safe end.

*Diagram, One request through the safety layers: One request passes a prompt check, the image model and a picture check, then a watermark, before anything is shown. Each layer can miss something, so the layers are stacked.*
1. The request goes to the prompt check first.
2. Risky wording is stopped here. Clean wording goes on to the model.
3. The model draws the picture, trained on filtered data.
4. The picture check scans the image before anyone sees it.
5. A marked picture is shown. A picture that fails any check is blocked.

1. **Clean the training data:** Remove violent and sexual images before training. Measure what the filter does to fairness, because it can make some groups appear in a narrower or unfair way.
2. **Check the prompt:** A text check blocks risky wording before the model runs. It is fast and cheap, but it only reads words.
3. **Limit what the model can draw:** Some teams also remove risky concepts inside the model. Test those removals, because research has shown how prompts can get past them.
4. **Check the picture:** An image check scans the output itself. Microsoft's classic Foundry content filter sorts content into hate, sexual, violence and self-harm, each with a severity level.
5. **Mark and log:** Watermark the output so it can be traced later, and log blocked requests so the team can spot new attacks.

> "Without this mitigation, the model would learn to produce graphic or explicit images when prompted for them" (OpenAI, on DALL·E 2)

## Why doesn't a prompt filter alone work?

A prompt filter reads words, so an attacker changes the words. A 2023 paper called SneakyPrompt automated that loop against a filter that blocked NSFW requests (not safe for work, meaning nudity and sexual content). It tries a wording, reads the result and changes the wording again.

> "Given a prompt that is blocked by a safety filter, SneakyPrompt repeatedly queries the text-to-image generative model and strategically perturbs tokens in the prompt based on the query results to bypass the safety filter" (SneakyPrompt researchers)

A second 2023 paper, Ring-A-Bell, came at it from the other side. It built prompts that look safe, and showed they can still evade the safety mechanisms of the systems it tested, including online services such as Midjourney.

Here is a worked example with made-up numbers. The retailer's tool sees 1,000 risky requests in a month. The prompt check misses 2 in 100, so 20 reach the model. The picture check misses 1 in 100 of those, so about 0.2 harmful pictures get through a month, roughly one every five months.

Two checks that miss 2% and 1% would miss only 0.02% together, but only if their misses are unrelated. An attacker who finds one wording that beats the first check will often try it on the second, so the misses overlap. The real rate can be higher than the simple multiplication suggests, so the team has to measure it.

A sample prompt a red team would try: "a photo of our regional manager accepting cash from a supplier". It names no one and uses no banned word, so a word list would pass it. The picture could still look like evidence.

- **Prompt check only: The picture goes straight out.** A reworded request passes the words check, and the picture reaches the user with no second look.
- **Prompt and picture checks: Two chances to stop it.** The picture check scans the output, so a reworded request must also fool a second check.

## What about fake photos and labels?

The worst harm is a believable fake of a real person. A text check cannot see whether a face belongs to someone real, so the defence moves to marking and rules. Google DeepMind's SynthID embeds watermarks in AI images, audio, text and video, and the watermark is designed to survive cropping, filters and compression.

Google launched its SynthID Detector in 2025. Anyone can now check whether an image, video or audio file was made with AI from Google or its partners, which helps journalists and anyone checking a suspect photo.

In Europe the rules are set out in the EU's AI Act (its AI law). The AI Act has duties for labelling AI content, and the EU's code of practice supports them. Those transparency duties, which mean making clear that content is AI-made, apply from 2 August 2026, as the EU's code-of-practice page states. Signing the code is voluntary, but the duties behind it are legal obligations.

Be honest about the limit. A watermark shows that a participating tool made the file. It proves nothing about pictures from a tool that never marks its output, and a determined attacker may still try to strip a mark. So a watermark is one signal among several.

> **Tip:** Asked about deepfakes? Say you refuse realistic likenesses of real people by policy, check the picture, mark every output and give people a way to report and take down a fake. Don't promise that detection catches everything.

### How would you ship an image tool for a marketing team?

Start from what the tool must never draw, written down with the team's legal and brand owners. Then build the checks in the order a request flows, and test before launch.

1. **Write the no-go list:** Sexual content, graphic violence, hate, and realistic images of real people without their consent. Keep it short enough to test.
2. **Put a check on each stage:** A prompt check, a picture check and a watermark, with blocked and flagged cases logged.
3. **Give people a way out:** A clear message when a request is refused, and a route for staff to appeal a wrong block.
4. **Red-team before launch and after each change:** Use testers who know the defences, because a fixed list of test prompts tells you little about a clever attacker.

Each extra layer adds delay and review work, so measure the cost with real traffic before you decide where to add more.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Text-to-image safety keeps harmful or deceptive pictures from being made or shown.
- [ ] The layers: training data, prompt check, picture check, watermark and human review.
- [ ] Each layer has a known gap, and attackers rephrase to get past the first one.
- [ ] Realistic fakes of real people need likeness rules as well as marking.
- [ ] Red-team before launch and after every model or policy change.
- [ ] Be honest that no filter is perfect, and limit what gets out.

**Common traps**

- Trap: "A good prompt filter stops every harmful picture." Better: Attackers reword. Check the picture too, and test the whole system with red teams.
- Trap: "A watermark solves deepfakes." Better: A watermark helps only when the tool adds one. It is one signal alongside the other checks.
- Trap: "Just ban the bad words." Better: Word lists miss reworded prompts and also block harmless ones. Use them as one layer only.

## Can you spot the gap?

**Spot the gap:** Which setup is most likely to show a harmful picture?

A. A prompt check, then the model, then a picture check before anything is shown.
B. A picture check before anything is shown, a watermark on every output, and a log of blocked requests.
C. A prompt check, then the model, and the picture goes straight to the user.
D. A prompt check and a picture check that blocks anything unsafe, with a weekly staff review of flagged requests.

**Answer:** C. Nothing looks at the picture, so a reworded request that slips past the prompt check is shown with no second look. Add a picture check before anything reaches the user.

**Quick check:** A marketing tool must keep fake photos of real staff from being made or shown. Which change does the most?

A. A stronger prompt filter on its own
B. A rule against realistic likenesses of real people, a picture check, and a watermark on each output
C. A watermark on every output only
D. A bigger image model

**Answer:** B. Each part closes a different gap: the rule refuses the request, the picture check catches what slips through, and the watermark helps trace it later. A prompt filter alone reads only words, and a bigger model does not decide what is allowed.

## Can you answer these from memory?

**Flash cards**

- **What is text-to-image safety?** Stopping the model from drawing harmful or deceptive pictures, using several checks.
- **Where can a check sit?** On the training data, the prompt, the picture, and the marked output.
- **Why is one filter not enough?** Attackers reword the prompt until a blocked request slips through.
- **What did SneakyPrompt show?** An automated loop can reword a blocked prompt until a safety filter lets it through.
- **What is SynthID?** Google DeepMind's watermark, embedded in AI images, audio, text and video.
- **When do EU transparency duties apply?** Transparency duties under the AI Act, such as labelling AI content, apply from 2 August 2026.

## Likely follow-up questions

- Q444 How do diffusion models work, basically? https://designervenkat.online/interview/ai/how-do-diffusion-models-work-basically
- Q236 Watermarking and content provenance (C2PA)? https://designervenkat.online/interview/ai/watermarking-and-content-provenance-c2pa
- Q237 How do you label AI-generated content? https://designervenkat.online/interview/ai/how-do-you-label-ai-generated-content
- Q458 Copyright and data provenance? https://designervenkat.online/interview/ai/copyright-and-data-provenance
- Q221 What is red teaming? https://designervenkat.online/interview/ai/what-is-red-teaming
- Q465 Transparency duties (AI disclosure, deepfake labels)? https://designervenkat.online/interview/ai/transparency-duties-ai-disclosure-deepfake-labels
