Inferensys

Prompt

Hate Speech and Harassment Classification Prompt

A practical prompt playbook for using Hate Speech and Harassment Classification Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the operational context, ideal user, and boundaries for the hate speech and harassment classification prompt.

This prompt is designed for trust and safety engineers, content moderation teams, and API platform operators who need to classify user-generated text against a defined hate speech and harassment taxonomy. It is built for the ingress layer of an AI system, before content is stored, displayed, or passed to downstream models. Use this prompt when you need structured, auditable classification output that includes severity levels, protected characteristic targeting, and contextual factors. This is not a general-purpose toxicity scorer. It is a classification and triage tool that produces a decision record suitable for human review queues, automated actioning, and audit logging. The prompt assumes you have a defined policy taxonomy and that ambiguous cases will be escalated, not auto-resolved.

Deploy this prompt when your platform requires consistent, policy-aligned decisions about hate speech and harassment. It is appropriate for social media feeds, community forums, gaming chat, API platforms accepting third-party content, and any system where user-generated text must be screened before publication or model ingestion. The prompt expects a pre-defined taxonomy of violation categories, protected characteristics, and severity tiers. You must supply these as part of the [POLICY_TAXONOMY] placeholder. The output is designed to be consumed by a rules engine or review queue dispatcher, not displayed directly to end users. Do not use this prompt for real-time chat filtering where latency must be under 200ms without streaming, for platforms without a defined hate speech policy, or for jurisdictions where legal definitions of hate speech differ materially from your supplied taxonomy without legal review.

Before integrating this prompt, ensure you have established your escalation criteria and human review capacity. The prompt will flag ambiguous cases, coded language, and context-dependent harassment, but it cannot replace human judgment for edge cases. You should pair this prompt with a separate Abuse Escalation and Human Review Routing Prompt to handle the ESCALATE decisions this classifier produces. Always log the full classification payload, including confidence scores and evidence excerpts, for audit and model evaluation purposes. Never use the output of this prompt to automatically ban users without a human review path for high-severity classifications.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before deploying hate speech and harassment classification into a production pipeline.

01

Good Fit: High-Volume Content Moderation Queues

Use when: You have a firehose of user-generated content and need a first-pass filter to surface likely violations for human review. The prompt excels at applying a consistent taxonomy at scale. Guardrail: Never auto-block based solely on the model's classification. Always route positive detections to a human review queue with clear severity labels.

02

Bad Fit: Standalone Automated Enforcement

Avoid when: The output directly triggers account bans, content removal, or public responses without human oversight. Models miss context, coded language, and in-group reclamation. Guardrail: The prompt output must be treated as a 'recommendation for review,' not a final verdict. Implement a mandatory human-in-the-loop step for any enforcement action.

03

Required Inputs: Defined Taxonomy & Severity Scale

What to watch: Without a clear, documented hate speech taxonomy and severity levels (e.g., Tier 1: Slurs, Tier 2: Dehumanization), the model's output will be inconsistent and unactionable. Guardrail: Inject your specific policy definitions and severity tiers directly into the prompt's [POLICY_TAXONOMY] variable. Do not rely on the model's generic understanding of 'hate speech.'

04

Operational Risk: Contextual Blindness & Dog Whistles

Risk: The model will miss harassment that relies on shared cultural knowledge, in-group jargon, or coded language (dog whistles). It also struggles with sarcasm and quoted speech. Guardrail: Pair this prompt with a user-history retrieval step. A single comment may look clean, but a pattern of targeted replies reveals harassment. Flag low-confidence cases for deeper investigation.

05

Operational Risk: Over-Flagging Legitimate Counter-Speech

Risk: The model often flags counterspeech, educational content, or self-referential discussions that use the same terms it's trained to detect. This creates a high false-positive rate that overwhelms reviewers. Guardrail: Add a specific [CONTEXT] variable for the surrounding conversation and instruct the model to distinguish between 'use' and 'mention' of hateful terms. Monitor the overturn rate in your review queue.

06

Operational Risk: Multilingual & Code-Switched Attacks

Risk: The prompt's performance degrades sharply on non-English languages, mixed-language inputs, and transliterated slurs, leading to uneven policy enforcement. Guardrail: Implement a language-detection step before this prompt. Route non-primary-language content to specialized, locale-specific classifiers or a multilingual variant of this prompt with explicit language instructions.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for classifying user-generated content against a defined hate speech taxonomy, with structured JSON output and clear escalation hooks.

This template provides a complete, copy-ready prompt for classifying user-generated content for hate speech and harassment. It is designed to be dropped into a moderation pipeline, an API gateway, or a human-review queue. The prompt enforces a strict JSON-only output contract, a defined severity taxonomy, and explicit rules for handling contextual factors like reclaimed language, counter-speech, and coded terms. Before using this prompt, you must define your organization's specific protected characteristic categories, severity tiers, and escalation thresholds in the [TAXONOMY] and [ESCALATION_RULES] placeholders.

text
System: You are a content moderation classifier. Your only job is to analyze the provided text and return a valid JSON object that strictly follows the output schema. Do not include any text, explanation, or commentary outside the JSON object. Apply the taxonomy and rules defined below without deviation. If the text is ambiguous, err on the side of flagging for human review rather than dismissing.

## TAXONOMY
[TAXONOMY]

## ESCALATION RULES
[ESCALATION_RULES]

## CONTEXTUAL RULES
- Distinguish between hate speech targeting a protected group and counter-speech, educational discussion, or self-referential reclaimed language.
- Coded language, dog whistles, and in-group terminology should be classified based on their known harmful meaning, not their literal text.
- Sarcasm and humor do not excuse hate speech if the underlying message targets a protected characteristic.
- If the text contains a direct threat of violence, the severity must be set to 'critical' regardless of other factors.

## OUTPUT SCHEMA
Return only a single JSON object with the following structure:
{
  "classification": {
    "is_hate_speech": boolean,
    "is_harassment": boolean,
    "severity": "none" | "low" | "medium" | "high" | "critical",
    "primary_category": string,
    "secondary_categories": [string],
    "targeted_characteristics": [string]
  },
  "evidence": {
    "triggering_spans": [string],
    "rationale": string
  },
  "routing": {
    "recommended_action": "allow" | "flag" | "quarantine" | "block" | "escalate",
    "requires_human_review": boolean,
    "review_priority": "low" | "medium" | "high" | "urgent"
  },
  "confidence": number
}

User: [INPUT]

Adapting the template: Replace [TAXONOMY] with your organization's specific hate speech categories, protected characteristics, and definitions. Replace [ESCALATION_RULES] with concrete thresholds that map severity and confidence scores to routing actions. The [INPUT] placeholder should be populated with the raw user-generated text at runtime. For high-stakes production use, pair this prompt with a validation layer that checks the JSON schema before the output reaches any downstream system. If the model fails to return valid JSON, implement a retry with a stronger format constraint or escalate directly to a human queue. Always log the raw input, the full model response, and the final routing decision for auditability.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Hate Speech and Harassment Classification Prompt. Each placeholder must be populated before model invocation. Validation notes describe the checks needed to prevent silent misclassification.

PlaceholderPurposeExampleValidation Notes

[USER_INPUT]

The raw text to classify for hate speech or harassment

You people always ruin everything for the rest of us

Required. Must be non-null and non-empty string. Check for obfuscation before passing. Max 4096 chars unless chunking strategy is defined.

[TAXONOMY]

The hate speech category definitions and severity levels the model must use

{"categories": [{"name": "ethnic_slur", "severity": "high", "definition": "..."}]}

Required. Must be valid JSON. Schema check: array of category objects with name, severity, and definition fields. Missing taxonomy produces uncalibrated outputs.

[PROTECTED_CHARACTERISTICS]

List of protected characteristics to detect targeting against

["race", "religion", "sexual_orientation", "gender_identity", "disability", "national_origin"]

Required. Must be a non-empty array of strings. Validate against known characteristic list. Missing entries cause false negatives on targeted harassment.

[CONTEXT]

Optional surrounding conversation or metadata for contextual classification

{"previous_turns": [...], "channel": "public_forum", "locale": "en-US"}

Optional. If provided, must be valid JSON with previous_turns array and channel string. Null allowed. Context absence may increase ambiguity for coded language.

[SEVERITY_THRESHOLD]

The minimum severity level that triggers a positive classification

"medium"

Required. Must be one of: low, medium, high, critical. Controls false positive vs false negative trade-off. Validate enum membership before invocation.

[OUTPUT_SCHEMA]

The expected JSON structure for the classification output

{"is_hate_speech": boolean, "severity": string, "targeted_characteristics": [...], "evidence_spans": [...], "confidence": float}

Required. Must be valid JSON Schema or example object. Parse check before use. Schema mismatch causes downstream integration failures.

[ESCALATION_RULES]

Conditions that require human review regardless of automated classification

{"auto_escalate_if": ["severity >= high", "confidence < 0.7", "targeted_characteristics includes disability"]}

Required. Must be valid JSON with auto_escalate_if array. Each rule must be parseable as a boolean condition. Missing rules risk un-reviewed high-severity content.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the hate speech and harassment classification prompt into a production moderation pipeline with validation, retries, logging, and human review escalation.

This prompt is designed to sit at the ingress layer of a content moderation pipeline, receiving user-generated text and returning a structured classification payload. The harness must treat the model output as a signal, not a final decision. Every classification should be logged with the raw input, model response, confidence scores, and any override actions for auditability. Because hate speech detection carries high stakes—false negatives allow harm through, false positives silence legitimate speech—the implementation must include a mandatory human review path for mid-confidence and high-severity outputs.

Wire the prompt into an asynchronous processing queue rather than blocking the user request. When content is submitted, enqueue a moderation task that calls the LLM with the prompt template, passing [INPUT_TEXT] as the user content and [POLICY_TAXONOMY] as the hate speech categories your platform enforces. Parse the JSON response and validate it against a strict schema: require classification (enum of allowed labels), severity (integer 1-5), protected_characteristics (array of strings), confidence (float 0-1), and evidence_excerpts (array of strings with character offsets). Reject malformed responses and retry once with a repair prompt that includes the validation error. If the retry also fails, escalate to a human moderator with the raw input and both failed attempts attached.

For routing decisions, implement a threshold matrix. High-confidence (≥0.9) low-severity (1-2) classifications can auto-resolve with actions like hiding content or flagging for review. High-confidence high-severity (4-5) classifications should trigger immediate content removal and queue for human confirmation within your SLA window. Mid-confidence (0.6-0.89) outputs across any severity must route to the human review queue with the model's classification as a suggested label. Low-confidence (<0.6) outputs should be treated as ambiguous and routed for human decision without model suggestion to avoid anchoring bias. Log every routing decision with the model, prompt version, confidence, and final disposition for downstream eval and model improvement.

Model choice matters here. Use a model with strong instruction-following and low refusal rates on sensitive topics—classifiers that refuse to analyze hate speech are useless. Test against a golden dataset of known hate speech, edge cases (reclaimed slurs, counter-speech, academic discussion), and adversarial examples (coded language, dog whistles, obfuscated terms) before deployment. Run regular eval passes comparing model classifications against human moderator decisions to detect drift in sensitivity or emerging evasion patterns. Store all decisions in a structured format that supports recall, precision, and fairness audits across protected characteristic categories.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the exact fields, types, and validation rules for the Hate Speech and Harassment Classification output. Use this contract to build a post-processing validator before the result enters any database, queue, or review tool.

Field or ElementType or FormatRequiredValidation Rule

classification_id

string (UUID v4)

Must match UUID v4 regex. Generate if not provided by upstream system.

input_text_hash

string (SHA-256 hex)

Must be a 64-character lowercase hex string. Validate against the original input to ensure traceability.

is_hate_speech

boolean

Must be strictly true or false. Null or string values should fail validation.

severity_level

enum: [low, medium, high, critical]

Must be one of the four defined enum members. Reject any other value and log the raw output for review.

protected_characteristics_targeted

array of strings

Each element must be a non-empty string from the defined taxonomy (e.g., race, religion, gender). Reject if the array contains an unrecognized category.

primary_category

string

Must be a non-empty string matching a top-level category in the organization's hate speech taxonomy. If the model returns an unknown category, map it to 'other' and flag for human review.

confidence_score

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive. If the value is outside this range, clamp it and log a warning. If the field is missing, set to null and require human review.

requires_human_review

boolean

Must be true if severity_level is 'high' or 'critical', or if confidence_score is below the [CONFIDENCE_THRESHOLD] parameter. Automated systems must check this field before taking irreversible action.

PRACTICAL GUARDRAILS

Common Failure Modes

Hate speech and harassment classifiers fail in predictable ways. These are the most common production failure modes and the concrete guardrails that prevent them.

01

Coded Language and Dog Whistles

What to watch: The model misses in-group signals, memes, and euphemisms that carry hateful meaning to target communities but appear innocuous to outsiders. Examples include triple parentheses, number codes, and seemingly neutral phrases with known extremist connotations. Guardrail: Maintain a community-sourced glossary of known coded terms. Run periodic adversarial eval with members of targeted communities. Require contextual analysis of user history and thread context, not isolated message classification.

02

Dialect and Vernacular Over-Flagging

What to watch: The model misclassifies African American Vernacular English, drag culture slang, regional dialects, or in-group reclaimed terms as harassment. This produces disproportionate false positives against marginalized communities. Guardrail: Include diverse dialect samples in eval datasets. Calibrate thresholds separately for reclaimed versus weaponized usage. Require human review for any classification where the model confidence is below 0.85 and the detected group is a marginalized population.

03

Context Collapse Across Turns

What to watch: The model classifies a single message in isolation without the preceding conversation. A sarcastic quote of hate speech, a victim recounting abuse, or a moderator warning can all be flagged as violations. Guardrail: Always pass the surrounding conversation context into the prompt. Include speaker role labels. Add an explicit instruction to distinguish between quoting, recounting, and perpetrating. Test with multi-turn threads containing edge cases.

04

Severity Inflation Under Pressure

What to watch: When the prompt emphasizes safety, the model inflates severity scores on borderline content to avoid false negatives. This floods review queues with low-risk items and desensitizes human reviewers. Guardrail: Use a calibrated severity taxonomy with explicit criteria for each tier. Include low-severity and non-violation examples in few-shot prompts. Monitor severity distribution drift weekly and recalibrate when the median severity shifts upward without a corresponding real-world change.

05

Protected Characteristic Misattribution

What to watch: The model infers a target's protected characteristic from stereotypes or proxies rather than explicit evidence. It may classify a statement as anti-Semitic because it mentions finance, or as transphobic because it mentions sports participation. Guardrail: Require the model to cite explicit textual evidence for the protected characteristic it claims is targeted. If no explicit mention exists, flag as 'possible coded targeting' rather than confirmed. Route to human review with the evidence gap noted.

06

Adversarial Misspelling and Character Substitution

What to watch: Users bypass classifiers with intentional misspellings, leetspeak, Unicode homoglyphs, and zero-width characters that preserve human readability but break token-level detection. Guardrail: Preprocess input with Unicode normalization and a leetspeak decoder before classification. Include obfuscated examples in eval suites. Test against a library of known evasion patterns. If the input contains unusual character mixtures, flag for secondary review even if the primary classification is clean.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Hate Speech and Harassment Classification Prompt before deployment. Each criterion validates a specific failure mode common in production content moderation systems.

CriterionPass StandardFailure SignalTest Method

Protected characteristic targeting

Prompt correctly identifies the specific protected characteristic targeted (e.g., race, religion, gender identity) when present in [INPUT]

Output omits the targeted characteristic, misclassifies the characteristic, or returns null when targeting is clearly present

Run against a golden set of 50 examples with known targeted characteristics; require exact match on characteristic label

Severity level calibration

Severity score matches human-annotated ground truth within ±1 level on a 5-point scale for 90% of test cases

Systematic over-severity on borderline cases or under-severity on coded language and dog whistles

Compare model-assigned severity against 3 independent human annotator scores; measure mean absolute error and directional bias

Coded language and dog whistle detection

Prompt flags known coded terms, in-group slurs, and contextualized hate symbols with confidence ≥ 0.7

Model treats coded language as benign because surface text lacks explicit slurs; false negative rate exceeds 15% on dog whistle test set

Curate a test set of 30 dog whistle examples from community guidelines documentation; measure recall and flag confidence

Contextual factor integration

Prompt correctly adjusts classification when [CONTEXT] provides mitigating or aggravating information (e.g., quoted rebuttal, educational discussion)

Model ignores [CONTEXT] field and classifies based on [INPUT] alone; identical classification output regardless of context presence

Run paired tests: same [INPUT] with and without [CONTEXT]; measure classification change rate and direction correctness

Human-review escalation trigger

Prompt outputs escalation_flag: true when confidence < 0.85 OR severity ≥ 4 OR protected characteristic targeting is present

Model outputs high confidence on ambiguous cases; escalation_flag remains false when human review is clearly warranted by policy

Test against 20 borderline cases where 3 human reviewers disagree; require escalation_flag: true on at least 80% of these cases

False positive control on reclaimed language

Prompt classifies in-group reclaimed terms and intra-community speech as non-violating when speaker identity context is present

Model flags reclaimed language as hate speech; false positive rate exceeds 10% on community speech test set

Build a test set of 25 examples of in-group reclaimed language from community moderation appeals; measure false positive rate

Output schema compliance

Response validates against [OUTPUT_SCHEMA] on 100% of test cases with all required fields present and correctly typed

Missing fields, wrong types, or extra hallucinated fields appear in output; JSON parse fails in downstream routing logic

Schema-validate every test output programmatically; reject any response that fails JSON Schema validation against the defined contract

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base taxonomy and severity levels. Use a single model call without schema enforcement. Focus on getting the classification logic right before adding production harness.

code
Classify the following text for hate speech and harassment.

Taxonomy: [TAXONOMY]
Text: [INPUT]

Return JSON with:
- classification (violation/non-violation)
- severity (low/medium/high/critical)
- protected_characteristics_targeted (list)
- explanation (1-2 sentences)

Watch for

  • Missing schema checks leading to malformed JSON
  • Overly broad instructions that flag legitimate criticism
  • No handling of coded language or dog whistles
  • Single-turn evaluation missing conversational context
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.