This prompt is designed for trust-and-safety engineers and platform operators who need to classify user-generated text before it triggers a model response or is published. It produces a structured, multi-label classification across hate speech, harassment, and discrimination categories, each with a severity score. Use this when you need upstream detection that is more granular than a binary safe/unsafe flag and when downstream actions depend on the specific harm category and intensity. This prompt belongs in a pre-processing safety layer, not as a conversational response. It assumes the input has already passed basic profanity or spam filters and needs deeper semantic analysis.
Prompt
Hate Speech and Harassment Classification Prompt Template

When to Use This Prompt
Defines the operational boundaries and ideal deployment context for the hate speech and harassment classification prompt.
Deploy this prompt when your platform requires audit-ready classification decisions that map to specific policy categories. The structured output enables configurable gating—you can block high-severity hate speech while flagging low-severity harassment for human review. Wire this into an API pre-processing step where the classification result determines routing: block, quarantine, escalate, or allow. The prompt is designed for single-turn classification, not multi-turn conversation analysis. For session-level risk evaluation, pair this with a multi-turn probing detection prompt that tracks cumulative risk across turns. Do not use this prompt as a standalone policy enforcement mechanism without human review for high-severity or ambiguous cases. The severity scoring provides a signal, not a final verdict.
Avoid using this prompt for real-time chat filtering where latency must stay under 100ms—the structured output and multi-category analysis add processing overhead. Do not use it to classify content in languages or dialects not represented in your evaluation dataset without additional testing for performance gaps. The prompt is not designed to detect novel, zero-day attack patterns; it classifies known harm categories. For adversarial input detection, pair this with a prompt injection or jailbreak classification prompt. Before deploying, run the prompt against a golden dataset that includes reclaimed language, in-group terminology, and dialect variations to measure false-positive rates. If your false-positive rate on benign minority-group speech exceeds your operational threshold, add few-shot examples or fine-tune rather than lowering the severity threshold.
Use Case Fit
Where this prompt works and where it does not. Understand the operational boundaries before deploying a hate speech and harassment classifier into a production AI system.
Good Fit: Upstream Content Filtering
Use when: you need to classify user inputs before they reach a generative model or public forum. This prompt is designed for trust-and-safety pipelines that require multi-label classification with severity scoring. Guardrail: Deploy as a pre-screen gate with a strict latency budget. Cache classifications for identical inputs to reduce cost.
Bad Fit: Real-Time Chat Moderation
Avoid when: you need sub-100ms decisions on streaming text. This prompt's detailed reasoning and multi-label output add latency unsuitable for live chat. Guardrail: Use a lighter, embedding-based classifier for real-time flagging and reserve this prompt for asynchronous review queues or batch analysis.
Required Inputs: Policy Taxonomy and Context
Risk: Without a defined policy taxonomy, the model applies its own vague safety standards, leading to inconsistent enforcement. Guardrail: Always supply a [POLICY_TAXONOMY] with explicit definitions for each hate speech and harassment category. Include [USER_CONTEXT] and [CONVERSATION_HISTORY] to reduce false positives on reclaimed language or in-group usage.
Operational Risk: Dialect and Cultural Edge Cases
Risk: The model will misclassify African American Vernacular English (AAVE), regional slang, and reclaimed terms as hate speech. This creates discriminatory outcomes at scale. Guardrail: Implement a mandatory human-review queue for all classifications where confidence is below 0.85. Run regular fairness audits segmented by dialect and demographic proxy.
Operational Risk: Over-Classification Drift
Risk: Without calibration, the classifier trends toward over-flagging, blocking legitimate criticism, debate, or educational content. This erodes user trust and creates unnecessary review queues. Guardrail: Track the false-positive rate weekly against a golden dataset of benign but edgy content. Implement a [SEVERITY_THRESHOLD] parameter that can be tuned without redeploying the prompt.
When to Escalate: Regulated or Crisis Content
Risk: This prompt may detect severe harassment or threats of violence but lacks the context to trigger mandatory reporting or crisis intervention. Guardrail: Define an [ESCALATION_POLICY] that routes high-severity classifications (e.g., doxxing, credible threats) to a human review queue within 5 minutes. Never let the model autonomously decide to contact authorities.
Copy-Ready Prompt Template
A reusable system prompt for classifying user inputs into hate speech, harassment, and discrimination categories with severity scoring and edge-case handling.
This prompt template is designed to be pasted directly into your system prompt or safety classifier harness. It instructs the model to act as a content safety classifier, producing structured, multi-label outputs for hate speech, harassment, and discrimination. The template uses square-bracket placeholders for your specific policy definitions, output schema, and risk thresholds, making it adaptable to different platform policies without rewriting the core classification logic.
codeSYSTEM: You are a content safety classifier. Your task is to analyze the user's input and classify it according to the provided policy for hate speech, harassment, and discrimination. [POLICY_DEFINITIONS] Analyze the following [INPUT] against the policy definitions above. Classify the input into one or more of the following categories only if the criteria are met. If no criteria are met, the classification should be 'none'. - hate_speech: Content that attacks or dehumanizes people based on protected characteristics. - harassment: Content intended to intimidate, bully, or silence a specific individual or group. - discrimination: Content that promotes unequal treatment or exclusion of a protected group. - none: The input does not violate any of the above policies. For each positive classification, provide a severity score from 1 to 5, where 1 is a microaggression or veiled reference and 5 is a direct, violent attack or call to action. [OUTPUT_SCHEMA] [CONSTRAINTS] - Do not classify reclaimed language used by members of the targeted group in a positive or neutral context as hate speech. - Consider the full context of the statement; do not flag single words in isolation. - If the input is a quote, a news report, or an educational discussion, flag it only if the user's framing endorses the harmful content. - If you are uncertain between two severity levels, choose the lower one and set the 'low_confidence' flag to true. [EXAMPLES] Return your analysis in the specified JSON format only. Do not include any other text.
To adapt this template, replace the placeholders with your specific content. [POLICY_DEFINITIONS] should contain your organization's exact policy language, including definitions of protected characteristics and prohibited conduct. [OUTPUT_SCHEMA] must be a strict JSON schema defining the structure of the classifier's response, including fields for categories, severity, confidence, and evidence. [EXAMPLES] should be populated with 5-10 few-shot examples that demonstrate edge cases like reclaimed language, educational context, and ambiguous intent. After adapting, run this prompt against a golden dataset of labeled examples to calibrate severity thresholds and measure inter-annotator agreement before production deployment.
Prompt Variables
Replace each placeholder with your policy-specific content. Validation notes describe how to verify the input before it reaches the model.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[POLICY_DEFINITIONS] | Defines hate speech, harassment, and discrimination categories with clear boundaries | Hate Speech: Content that attacks or dehumanizes people based on protected characteristics including race, ethnicity, religion, gender identity, sexual orientation, disability, or national origin. | Schema check: must be a JSON object with category keys and string definitions. Null not allowed. Minimum 3 categories required. |
[SEVERITY_LEVELS] | Maps severity tiers to criteria for consistent scoring across classifications | CRITICAL: Direct threats of violence or calls for harm against protected groups. HIGH: Slurs, dehumanizing language, or targeted harassment. MEDIUM: Stereotyping or derogatory generalizations. LOW: Microaggressions or coded language. | Schema check: must be a JSON object with level keys and string criteria. At least 3 levels required. Each level must define distinct escalation criteria. |
[CONTEXT_WINDOW] | Provides surrounding conversation or metadata for disambiguation | Previous 3 user messages and assistant responses. User account region: US. Content language: en. Platform: public forum. | Parse check: must be valid JSON or structured text. Null allowed when no prior context exists. Max 4000 tokens to avoid context dilution. |
[INPUT_TEXT] | The user message or content to classify | You people always come here and take our jobs. Go back where you came from. | Parse check: non-empty string required. Max 8000 characters. Pre-screen for PII before passing to model. Null not allowed. |
[OUTPUT_SCHEMA] | Defines the exact JSON structure the model must return | {"classifications": [{"category": string, "detected": boolean, "severity": string, "confidence": float, "evidence": string}], "overall_severity": string, "requires_escalation": boolean, "explanation": string} | Schema check: validate against JSON Schema before deployment. Must include required fields: classifications, overall_severity, requires_escalation. Confidence must be 0.0-1.0 range. |
[RECLAIMED_LANGUAGE_RULES] | Instructions for handling in-group reclamation and context-dependent terms | Terms reclaimed by specific communities should not be classified as hate speech when used by in-group members in non-hostile contexts. Flag as AMBIGUOUS when group membership cannot be determined. | Parse check: must be a string or array of strings. Null allowed if no reclaimed language policy exists. Human review required when AMBIGUOUS flag is raised. |
[ESCALATION_THRESHOLD] | Confidence and severity combination that triggers human review | Escalate when confidence < 0.7 AND severity >= HIGH. Also escalate when overall_severity == CRITICAL regardless of confidence. | Parse check: must be valid JSON with threshold rules. At least one escalation condition required. Test against known edge cases before deployment. |
[DIALECT_AND_CULTURAL_NOTES] | Guidance for handling dialect variations, slang, and cultural context that may affect classification | AAVE usage of reclaimed terms should not be classified as hate speech. Regional slang that appears aggressive but is benign in context should lower severity by one level. | Parse check: must be a string or array of strings. Null allowed. Human review required for any classification where dialect notes were applied to downgrade severity. |
Implementation Harness Notes
How to wire the Hate Speech and Harassment Classification prompt into a production safety workflow with validation, retries, logging, and human review.
This prompt is designed as the first stage in a content safety pipeline, not a standalone classifier. In production, you should wrap it in an application harness that validates the output schema, enforces confidence thresholds, and routes low-confidence or high-severity results to human review. The prompt returns a structured JSON payload with categories, severity, confidence, and flags fields—your harness must verify that every field is present, correctly typed, and within expected ranges before any downstream system acts on the classification. A missing confidence field or a severity value outside the defined enum is a harness-level failure, not a model behavior issue, and should trigger a retry or fallback.
Implement a validation layer immediately after the model response that checks: (1) the response is valid JSON, (2) all required keys exist (categories, severity, confidence, flags, rationale), (3) severity is one of none, low, medium, high, or critical, (4) confidence is a float between 0.0 and 1.0, and (5) categories is a non-empty array of strings from the defined taxonomy. If validation fails, retry once with the same prompt plus the validation error message appended as a [CORRECTION_REQUEST]. If the second attempt also fails, log the raw response and route to a human review queue. For high-risk applications, configure a confidence threshold (e.g., 0.85) below which classifications are automatically escalated regardless of severity. This prevents the system from acting on uncertain hate speech or harassment classifications that could generate false positives and unnecessary user sanctions.
Log every classification decision with the original input, the full model response, validation status, retry count, and final routing decision. This audit trail is essential for tuning thresholds, investigating false positives, and demonstrating due diligence to trust-and-safety reviewers. When deploying, choose a model with strong instruction-following and structured output capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable starting points. Avoid smaller or older models that may struggle with the nuanced distinctions between hate speech, reclaimed language, and legitimate critique. For dialect and reclaimed-language edge cases identified in the eval framework, maintain a separate test suite that runs weekly against production prompts to catch regression. Never let the classification result directly trigger an automated user ban or content removal without a human-in-the-loop checkpoint for high and critical severity outputs.
Expected Output Contract
Fields, data types, and validation rules for the JSON response produced by the Hate Speech and Harassment Classification Prompt Template. Use this contract to validate model output before downstream routing or logging.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
classification_id | string (UUID v4) | Must be a valid UUID v4 generated by the model for idempotency tracking. | |
primary_category | enum: hate_speech | harassment | discrimination | none | Must match exactly one of the four enum values. Reject on any other string. | |
secondary_categories | array of enum strings | If present, each element must be a valid enum value and must not duplicate the primary_category value. | |
severity_score | number (0.0 - 1.0) | Must be a float between 0.0 and 1.0 inclusive. Null is not allowed. Reject if out of range. | |
confidence | number (0.0 - 1.0) | Must be a float between 0.0 and 1.0 inclusive. Values below 0.7 should trigger human review if severity_score > 0.5. | |
targeted_groups | array of strings | If present, each string must be non-empty and match a recognized protected characteristic from the policy taxonomy. | |
rationale_summary | string (max 300 chars) | Must be a non-empty string not exceeding 300 characters. Must not contain the original user input verbatim. | |
requires_human_review | boolean | Must be true if confidence < 0.7 and severity_score > 0.5, or if primary_category is not 'none'. Otherwise false. |
Common Failure Modes
What breaks first when classifying hate speech and harassment in production, and how to guard against it.
Dialect and Reclaimed Language Misclassification
What to watch: The classifier flags in-group language, reclaimed slurs, or dialect-specific terms as hate speech. This is the most common false-positive driver and erodes trust with the communities you aim to protect. Guardrail: Include dialect context markers and reclaimed-language examples in few-shot prompts. Route high-confidence hate speech classifications that contain known reclaimed terms to a human review queue with community-context annotators.
Context Window Truncation of Critical Evidence
What to watch: Long messages or multi-turn conversations get truncated, removing the qualifying context that makes a statement satire, quotation, or counter-speech rather than harassment. The classifier sees only the flagged phrase and over-reacts. Guardrail: Always prepend the full conversation turn or message to the classification prompt. If truncation is unavoidable, flag the classification with a context_incomplete marker and downgrade confidence by one tier.
Severity Inflation on Ambiguous Inputs
What to watch: The model defaults to high-severity labels when uncertain, treating sarcasm, hyperbole, or poorly worded criticism as severe harassment. This creates an unmanageable escalation queue and over-censors legitimate speech. Guardrail: Require the prompt to output an ambiguity_flag boolean. When true, cap the severity score at medium and route to human review rather than automated action. Calibrate severity thresholds against a labeled ambiguity dataset.
Adversarial Misspelling and Token Smuggling Evasion
What to watch: Users bypass classifiers with intentional misspellings, zero-width characters, homoglyph substitution, or splitting harmful terms across tokens. The classifier sees benign text and returns a clean score. Guardrail: Add a pre-processing normalization step that strips zero-width characters, normalizes homoglyphs, and re-joins split tokens before classification. Include obfuscated examples in the eval suite and measure recall against a known evasion benchmark.
Policy Drift Between Classification and Enforcement
What to watch: The classification taxonomy drifts from the actual enforcement policy. The prompt flags content that the policy team no longer considers actionable, or misses new categories added after the prompt was authored. Guardrail: Version the classification taxonomy alongside the enforcement policy document. Run a weekly regression test comparing classifier output against a golden set labeled by policy reviewers. Flag any category with precision or recall below 0.85 for prompt update.
Multi-Turn Context Collapse in Harassment Campaigns
What to watch: Individual messages appear benign in isolation, but the user is running a coordinated harassment campaign across multiple turns, accounts, or channels. Single-turn classification misses the pattern entirely. Guardrail: Maintain a session-level risk score that accumulates across turns. When the cumulative score crosses a threshold, escalate the entire session for review even if individual messages score low. Include session-level features in the classification prompt when available.
Evaluation Rubric
How to test output quality before shipping. Run these checks against a held-out test set that includes dialect variations, reclaimed language, quoted content, and adversarial examples.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Multi-label precision | Precision >= 0.90 for each label on clean test set | False positive rate > 0.10 for any individual label | Run against 500 hand-labeled examples with known ground truth per label |
Severity score calibration | Predicted severity within ±1 of human label for 85% of cases | Systematic over-severity on reclaimed-language examples | Compare predicted severity to 3-human-annotator median on dialect-variant test set |
Reclaimed language handling | Zero false positives on AAE drag-culture terms and in-group reclamation phrases | Any flag of [RECLAIMED_TERM_EXAMPLE] as hate speech | Curated 200-example reclaimed-language test set with community reviewer sign-off |
Quoted content discrimination | Quoted hate speech classified as non-violative when attribution is clear | Quoted slurs flagged as original hate speech without quote context | 50-example test set mixing quoted hate speech, paraphrase, and original hate speech |
Adversarial robustness | Recall >= 0.85 on obfuscated hate speech (leet-speak, word splitting, emoji substitution) | Recall < 0.70 on adversarial test set | Run against 300-example adversarial test set with known obfuscation patterns |
Cross-dialect consistency | F1 score difference < 0.05 between AAE and SAE test subsets | F1 gap > 0.10 between dialect groups | Stratified test set with 250 AAE and 250 SAE examples, matched for harm severity |
Null input handling | Returns empty classification array with confidence 0 for empty or whitespace-only input | Non-empty classification output for null or whitespace input | Unit test with empty string, whitespace-only, and null inputs |
Confidence threshold gating | Low-confidence predictions (< 0.70) correctly routed to human review queue | High-confidence false positives or low-confidence false negatives exceeding 5% | Measure human-review routing rate against ground-truth error rate at each confidence band |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base classification prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Focus on getting the taxonomy right before adding infrastructure. Start with single-turn classification on a small labeled dataset.
- Remove severity scoring and confidence calibration fields initially
- Use a simplified output schema:
{"categories": [], "is_hate_speech": boolean} - Test with 20-30 clear examples before adding edge cases
- Log raw model outputs for later schema refinement
Watch for
- Over-classification of reclaimed language and in-group terminology
- Missing dialect and cultural context causing false positives
- Model refusing to classify entirely instead of returning a structured result
- Inconsistent category assignment across similar inputs

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us