# How Do You Build Content Moderation?

> How to build a moderation system for an AI product: layers, limits, human review and the trade-offs to name, explained simply for your AI interview.

**In short:** Content moderation checks what goes into and out of an AI product against a written policy, then publishes, holds or blocks each item. You layer a blocklist and a moderation model, set limits on real data, and send the unclear cases to a trained person.

AI and LLM interview question Q218, Guardrails and AI safety. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-do-you-build-content-moderation

## Say it in 30 seconds

Content moderation means checking what goes into an AI product and what comes out, against a written policy. I use layers. A blocklist catches exact banned words first. A moderation model scores each message by harm category. My policy sets two limits: clear cases go through or get stopped, and the unsure ones go to a trained reviewer. I tune those limits on labelled examples, because a limit set too low annoys customers, and one set too high lets harm through.

## Say it in 2 minutes

Start with the policy, because a model can only score harm, and the policy decides what harm means for your product. For an insurer's chat assistant, the risks are threats and self-harm signals from customers, and replies that promise a payout the policy does not cover. Those are different jobs, so they need different checks.

The system runs in order. A blocklist catches exact banned phrases first, with no model call. Then a moderation model scores the text by category. Two limits split the results: low scores go through, scores in the middle go to a human reviewer, and high scores or self-harm signals go to staff at once. The same check runs on the bot's reply before the customer sees it. If the reply streams out word by word, I hold it until the check ends, because scores only arrive once the full output exists.

The limits are a business choice, and they need real data. Lower them and good customers get stopped. Raise them and harm gets through. I label a sample of chats, measure both mistakes, and size the review band to the team's hours.

For rules the model cannot know, I add a custom policy, such as forbidden promises like guaranteed payouts, tested on a small set of labelled examples. Then I have people try to break it on purpose, and I measure again every month, because users and models change.

## What is content moderation, in plain words?

Content moderation is checking what users send, or what an AI writes, against a written policy, then deciding what happens next: publish it, hold it, or stop it. In an AI product it covers two places, the message going in and the reply coming out.

OpenAI's guide puts the job simply: "Use OpenAI moderation models to detect harmful content in text and images." The model scores the text. Your policy decides what a score means for your product.

Think of a bank's fraud desk. Clear payments go through, clear fraud is stopped, and the doubtful ones go to an analyst who reads the details. Moderation works the same way: most messages pass, a few are stopped, and the unclear ones go to a person.

- **Policy:** The written rules for what your product allows and what it does not, with examples.
- **Score:** The model's confidence that the text contains content in a harm category. Higher means more likely.
- **Threshold (limit):** The score at which you act. Above it the message is stopped, below it the message goes on.
- **Blocklist:** A list of exact words or links you ban, checked before any model runs.
- **False alarm:** A harmless message that gets blocked by mistake.

## How does one message move through the checks?

Put the cheap checks first, the model second and people last. A blocklist is exact and instant, so it catches a banned phrase before any model runs. Azure's safety service also lets you add your own blocklist: "You can also upload your own blocklists to enhance the coverage of harmful content that's specific to your use case."

*Diagram, One message through the checks: A customer's message is checked against a blocklist, then scored by a moderation model. The two limits send it to one of three places: reply as normal, wait for a reviewer, or hand to staff at once.*
1. The message is checked against exact banned words first.
2. Text that passes the list goes to the model for scores.
3. Low scores: the chat goes on as normal.
4. Unsure scores: a person reads it before it is sent.
5. High scores or a self-harm signal: staff are alerted at once.

The model is one check among several. OpenAI's moderation check (the service your code calls) is free to use. Llama Guard, a safety model from a research paper, is introduced as "an LLM-based input-output safeguard model geared towards Human-AI conversation use cases".

Output needs the same care. If the bot streams its reply (sends it out word by word as it is written), the scores arrive after the full reply exists: "If you stream a generated response, moderation scores arrive after the full generated output is available." So for risky products, hold the stream until the check ends.

Plan for the check failing too. OpenAI notes that "If a moderation step can't complete, the corresponding input or output moderation field can contain an error instead of moderation scores." Decide in advance whether to hold the reply or send a safe fallback. For a bank or an insurer, holding is usually the safer default.

## Where do you set the limits, and who checks the unsure ones?

Take a made-up but realistic case. An insurer runs a chat assistant on its website and gets about 40,000 chats a month. Two things can go wrong: a customer may send a threat or a self-harm signal, or the assistant may promise a payout the policy does not allow.

*Diagram, Two limits, two kinds of mistake: Lower the limit and more good customers get stopped. Raise it and more harm passes. Count both mistakes on a labelled sample, then move the limit.*
1. More stops mean good customers get blocked too.
2. Fewer stops let some harmful chats through.
3. Count the false alarms in a labelled sample.
4. Count the misses in the same sample, then move the limit.

Now the numbers. Say 2% of chats land in the unsure band: that is 800 chats a month. A reviewer needs about 3 minutes each, so that is 40 hours. Widen the band to 5% and it becomes 2,000 chats, or 100 hours, which is more than half of one full-time reviewer's month. The reviewers' hours set how wide the band can be.

- **Strict limit: More stopped, more false alarms.** Good customers get blocked and wait for a reply, and the review queue grows.
- **Loose limit: Fewer stopped, more harm passes.** The queue stays small, but a threat or a wrong payout promise can reach a customer.
- **Tuned limit: Set on labelled chats.** Measure both mistakes on a sample, then size the review band to the team's hours.

> "Treat moderation scores as signals for your application's policy, not as an automatic blocking decision." (OpenAI moderation guide)
>
> "As with any AI application, results and output will need to be carefully monitored, validated, and refined by maintaining humans in the loop." (OpenAI, on using GPT-4 for moderation (2023))

Reviewers need care too. OpenAI's blog says "Continual exposure to harmful or offensive content can lead to emotional exhaustion and psychological stress among human moderators." So rotate people, cap their hours, and send self-harm signals only to trained staff.

## How do you stop a bot from promising what it can't?

Harm categories cover only part of the risk. The insurer's biggest risk is a reply that promises a payout the policy does not cover. A vendor model does not know the insurer's rules, so you write a custom policy: a list of forbidden promises, tested on examples. OpenAI's blog describes that step: "Once a policy guideline is written, policy experts can create a golden set of data by identifying a small number of examples and assigning them labels according to the policy." A golden set is a small set of examples with the correct labels, used as a test.

> **Tip:** The model scores harm. Your policy decides what counts as a broken rule. Those are two jobs, and only the second one is yours to design.

Here is the idea in plain Python. The scores are made up, and the banned phrases decide first.

```python
# A simplified check on an insurer's chat assistant. The scores are made up; a real
# moderation model would produce them.
BANNED = ["guaranteed payout", "we will pay in full"]
HIGH, LOW = 0.90, 0.50

def check_reply(draft, scores):
    if any(phrase in draft.lower() for phrase in BANNED):
        return "HOLD: promise the policy does not allow"
    top = max(scores, key=scores.get)
    if scores[top] >= HIGH:
        return "BLOCK: " + top
    if scores[top] >= LOW:
        return "REVIEW: a person checks it"
    return "SEND: normal reply"

print(check_reply("Your claim is in review, about 10 working days.", {"violence": 0.01}))
print(check_reply("Good news: we will pay in full on Monday.", {"violence": 0.01}))
print(check_reply("Your claim is approved, but the amount is not final.", {"hate": 0.61}))
print(check_reply("Your claim is in review.", {"hate": 0.97}))
```

Output:

```text
SEND: normal reply
HOLD: promise the policy does not allow
REVIEW: a person checks it
BLOCK: hate
```

Azure's guardrails describe the same parts: "Guardrails are made up of controls that specify the risk to detect, where to scan for it, and how the model or agent should respond when it is found."

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Layers in order: a blocklist, then model scores, then a person for the unsure band.
- [ ] Your policy sets the limits. The model only scores.
- [ ] Both mistakes named, false alarms and misses, with numbers from a labelled sample.
- [ ] Reviewer hours and wellbeing as real limits on the design.
- [ ] Output checks as well as input, and a plan for when the check fails.
- [ ] A custom policy for your own rules, such as forbidden promises.

**Common traps**

- Trap: "Just use a moderation model and block what it flags." Better: Scores are signals for your policy. Set limits on labelled data, and send the unsure band to a person.
- Trap: "Set the limit at 0.9 and forget it." Better: Limits drift as users and models change. Re-check false alarms and misses on fresh samples each month.
- Trap: "Check the input and the bot is safe." Better: Check the reply too. A clean question can still get a harmful or false promise back.

## Can you spot the risk?

**Spot the weak rule:** A bank's chat assistant checks replies with a moderation model. Which rule is the weak one?

A. Hold any reply above the high limit, and route self-harm signals to staff now.
B. Send replies in the unsure band to a trained reviewer before the customer sees them.
C. Block replies that contain banned phrases like "we will pay in full" before any model runs.
D. Ban a customer's account after one flagged message, with no review and no appeal.

**Answer:** D. One flag, with no review and no appeal, is the weak rule. Models make false alarms, so one score should never ban a person. Use a reviewer and an appeal route, and keep bans for confirmed, repeated abuse.

**Quick check:** A reply scores 0.62 in one category, and your review band is 0.50 to 0.90. What should happen?

A. Send it to the customer, since 0.62 is under 0.90
B. Hold it for a reviewer before the customer sees it
C. Delete the chat and ban the account
D. Retrain the model tonight

**Answer:** B. The band is for scores that are neither clearly fine nor clearly harmful, so a person decides. One score is never grounds to ban a customer or retrain a model.

## Can you answer these from memory?

**Flash cards**

- **What is content moderation?** Checking text or images against a written policy, then publishing, holding or stopping them.
- **What are the three outcomes?** Publish as normal, hold for a person to review, or block and route to staff.
- **Why keep a blocklist and a model?** A blocklist is exact and instant. A model catches new wording the list has never seen.
- **Are model scores a verdict?** No. They are signals. Your policy and limits decide what happens next.
- **What does a lower limit cost?** More false alarms and a bigger review queue. A higher limit lets more harm through.
- **What is a custom policy for?** Your own rules the vendor model cannot know, like forbidden promises, tested on a golden set.

## Likely follow-up questions

- Q219 How do you detect hallucinations? https://designervenkat.online/interview/ai/how-do-you-detect-hallucinations
- Q221 What is red teaming? https://designervenkat.online/interview/ai/what-is-red-teaming
- Q222 Automated vs human red teaming? https://designervenkat.online/interview/ai/automated-vs-human-red-teaming
- Q223 Guardrail tools (Llama Guard, NeMo Guardrails, cloud filters)? https://designervenkat.online/interview/ai/guardrail-tools-llama-guard-nemo-guardrails
- Q224 What is a policy classifier layer? https://designervenkat.online/interview/ai/what-is-a-policy-classifier-layer
- Q212 How do you detect and redact PII? https://designervenkat.online/interview/ai/how-to-detect-and-redact-pii

## Learn it in depth

- [Content Moderation APIs](https://designervenkat.online/learn/ai-engineering/content-moderation-apis)
