esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

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.

11 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

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.

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.

Key words

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."

One message through the checks

Customer message

or the bot's draft reply

Blocklist

banned word: stopped, no model call

Moderation model

scores each harm category

Your two limits

Reply as usual

low scores, normal flow

Human reviews

scores in the unsure band

Block and hand to staff

above the high limit, or self-harm

  1. 1The message is checked against exact banned words first.
  2. 2Text that passes the list goes to the model for scores.
  3. 3Low scores: the chat goes on as normal.
  4. 4Unsure scores: a person reads it before it is sent.
  5. 5High scores or a self-harm signal: staff are alerted at once.
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.

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.

Two limits, two kinds of mistake

Limit set low

more messages stopped or reviewed

Limit set high

fewer messages stopped

Good customers stopped

false alarms, slow replies

Harm gets through

misses, real harm to people

Tune on labelled chats

measure both, then move the limit

  1. 1More stops mean good customers get blocked too.
  2. 2Fewer stops let some harmful chats through.
  3. 3Count the false alarms in a labelled sample.
  4. 4Count the misses in the same sample, then move the limit.
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.

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

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."

    BetterScores 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."

    BetterLimits 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."

    BetterCheck 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?

Quick check

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

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q219How do you detect hallucinations?12 min
  2. Q221What is red teaming?10 min
  3. Q222Automated vs human red teaming?11 min
  4. Q223Guardrail tools (Llama Guard, NeMo Guardrails, cloud filters)?10 min
  5. Q224What is a policy classifier layer?12 min
  6. Q212How do you detect and redact PII?13 min

Learn it in depth

Last updated on 26 November 2026

Building a chatbot that talks to your customers?

I design and build AI products and agents, including the UI and the system behind them. Book a short call and tell me what your assistant must never say.