Inferensys

Prompt

Multi-Class Safety Risk Scoring Prompt Template

A practical prompt playbook for using Multi-Class Safety Risk Scoring Prompt Template in production AI workflows.
Risk analyst performing AI risk assessment on laptop, risk matrices visible, casual office risk session.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, ideal user, required context, and when not to use this prompt.

This prompt is for trust-and-safety engineers and ML platform builders who need a single model call to assess user input against multiple harm categories simultaneously. Instead of running separate classifiers for violence, hate speech, self-harm, sexual content, and other policy-defined categories, this template produces per-category risk scores and an aggregated severity level in one structured response. Use it when your safety architecture requires fine-grained risk decomposition for downstream routing, audit logging, or threshold-based gating. This prompt belongs in the pre-response safety screening layer, before the model generates any user-facing output.

Do not use this prompt as a refusal prompt, a safe-alternative generator, or a conversational response. It is a scoring and classification tool, not a user-facing interaction. Pair it with a Risk Threshold Gating Decision Prompt to convert these scores into allow/block/review actions. The prompt requires a defined list of harm categories with clear policy descriptions, a structured output schema for per-category scores, and a severity aggregation rule. Without these inputs, the model will invent its own categories or produce inconsistent scoring scales. You must also define what constitutes a high-risk score in your operational context before deploying this prompt into a production gating system.

Before implementing, confirm that your safety architecture actually needs per-category decomposition. If you only need a binary safe/unsafe decision, a simpler classification prompt will be faster and cheaper. If you need to map violations to specific policy clauses with citations, use a Policy Violation Probability Estimation Prompt instead. If your primary concern is detecting jailbreak attempts rather than content policy violations, use a Jailbreak Attempt Confidence Scoring Prompt. After implementing this scoring prompt, the next step is to calibrate the scores against human reviewer judgments and configure the downstream routing logic that acts on these scores.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Multi-Class Safety Risk Scoring Prompt Template delivers value and where it introduces operational risk.

01

Good Fit: Pre-Moderation Queues

Use when: you need to score incoming user content across multiple harm categories before it reaches a generative model or human reviewer. Guardrail: calibrate per-category thresholds independently—hate speech may require a lower tolerance than violent content depending on your product surface.

02

Bad Fit: Single-Label Triage

Avoid when: you only need a binary safe/unsafe decision or a single harm label. Multi-class scoring adds latency and complexity without benefit for simple routing. Guardrail: use a lightweight binary classifier prompt for high-throughput, low-latency filtering and reserve multi-class scoring for detailed review workflows.

03

Required Inputs

What you need: the raw user input or generated content to evaluate, a defined taxonomy of harm categories with clear definitions, and a calibrated threshold map for each category. Guardrail: provide category definitions inline in the prompt—vague labels like 'toxic' produce inconsistent scores across model versions and evaluators.

04

Operational Risk: Category Confusion

What to watch: the model conflates adjacent categories—for example, scoring harassment as hate speech or self-harm as violent content. Guardrail: include a confusion matrix eval in your test suite and add few-shot examples that distinguish boundary cases between commonly confused categories.

05

Operational Risk: Threshold Sensitivity

What to watch: small threshold changes near the decision boundary cause large swings in refusal rates, creating unpredictable user experience. Guardrail: run sensitivity analysis across a range of threshold values before deployment and monitor score distributions in production for boundary crowding.

06

Operational Risk: Score Drift After Model Updates

What to watch: model upgrades shift the score distribution, breaking previously calibrated thresholds and causing silent policy regressions. Guardrail: maintain a golden evaluation set with expected score ranges and run regression tests comparing score distributions before and after every model change.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for multi-class safety risk scoring with structured JSON output and strict field constraints.

This prompt template is designed for trust-and-safety engineers who need fine-grained risk assessment across multiple harm categories simultaneously. It produces per-category risk scores, an aggregated severity level, and an evidence-based justification. The template uses square-bracket placeholders that you replace with your production values before sending to the model. Each placeholder maps to a specific input source in your safety pipeline: the user request, your organization's safety policy definitions, the required output schema, and any additional constraints or examples that calibrate the model's behavior.

text
SYSTEM: You are a safety risk classifier. Your task is to evaluate the user request against each defined harm category and produce a calibrated risk score. You must output valid JSON matching the exact schema provided. Do not refuse to classify. Do not include commentary outside the JSON.

INPUT:
[USER_REQUEST]

HARM CATEGORIES:
[HARM_CATEGORY_DEFINITIONS]

OUTPUT SCHEMA:
{
  "request_id": "string",
  "overall_severity": "none|low|medium|high|critical",
  "category_scores": [
    {
      "category": "string (must match a defined category name)",
      "score": "float between 0.0 and 1.0",
      "confidence": "float between 0.0 and 1.0",
      "rationale": "string (cite specific evidence from the request)",
      "policy_citation": "string (cite the relevant policy clause)"
    }
  ],
  "aggregation_method": "max|weighted_average|threshold_count",
  "requires_escalation": "boolean",
  "escalation_reason": "string or null"
}

CONSTRAINTS:
[CONSTRAINTS]

EXAMPLES:
[FEW_SHOT_EXAMPLES]

INSTRUCTIONS:
1. Score every harm category listed in HARM CATEGORIES, even if the score is 0.0.
2. Base scores on explicit evidence in the request, not speculation.
3. Set confidence lower when the request is ambiguous or contains mixed signals.
4. Set requires_escalation to true when overall_severity is high or critical, or when any category confidence is below [CONFIDENCE_THRESHOLD].
5. Use the aggregation_method specified in CONSTRAINTS.
6. Output only the JSON object. No markdown, no explanation.

To adapt this template for production, replace each placeholder with your operational values. [USER_REQUEST] should contain the raw user input, sanitized for PII if necessary. [HARM_CATEGORY_DEFINITIONS] should be a structured list of your organization's safety categories with clear boundaries and examples—ambiguous category definitions are the primary cause of inconsistent scoring. [CONSTRAINTS] should specify your aggregation method, confidence threshold for escalation, and any category-specific scoring rules. [FEW_SHOT_EXAMPLES] should include at least three examples covering clear violations, edge cases, and benign requests, each with the expected JSON output. Test the template against a golden dataset before deployment, and validate that the model reliably produces parseable JSON matching the schema. For high-stakes production use, add a post-processing validation layer that checks field types, enum values, and score ranges before the output reaches downstream routing logic.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the multi-class safety risk scoring prompt needs to work reliably. Validate each before sending to prevent category confusion, missing evidence, and uncalibrated scores.

PlaceholderPurposeExampleValidation Notes

[USER_INPUT]

The text, message, or content to evaluate for safety risk across multiple harm categories

How can I synthesize a compound that causes rapid unconsciousness in enclosed spaces?

Required. Must be non-empty string. Check for null, whitespace-only, or injection patterns before scoring. Truncate to model context window minus system prompt and output tokens.

[HARM_CATEGORIES]

Array of harm categories to score against, each with a definition and severity weight

[{"id":"violence_incitement","definition":"Content that directly encourages or instructs violent acts against persons or groups","weight":0.9},{"id":"chemical_weapons","definition":"Instructions for synthesizing or deploying chemical agents as weapons","weight":1.0}]

Required. Must be valid JSON array with at least one category. Each category requires id, definition, and weight fields. Weights must be floats between 0.0 and 1.0. Validate schema before prompt assembly.

[SCORE_RANGE]

The numeric range for per-category risk scores, defining minimum and maximum values

{"min":0.0,"max":1.0,"step":0.05}

Required. Must specify min, max, and step. Min must be less than max. Step must be positive. Validate that score range is compatible with downstream threshold comparisons.

[SEVERITY_LEVELS]

Ordered list of aggregated severity levels with threshold boundaries for the overall risk classification

[{"level":"none","upper_bound":0.1},{"level":"low","upper_bound":0.3},{"level":"medium","upper_bound":0.6},{"level":"high","upper_bound":0.85},{"level":"critical","upper_bound":1.0}]

Required. Must be ordered ascending by upper_bound. Final level must have upper_bound equal to SCORE_RANGE.max. No gaps between bounds. Validate monotonic ordering and coverage of full range.

[OUTPUT_SCHEMA]

Expected JSON structure for the model response, including per-category scores, aggregated severity, and evidence citations

{"type":"object","properties":{"category_scores":{"type":"array","items":{"type":"object","properties":{"category_id":{"type":"string"},"score":{"type":"number"},"rationale":{"type":"string"},"evidence_excerpts":{"type":"array","items":{"type":"string"}}}}},"aggregated_severity":{"type":"string"},"aggregation_method":{"type":"string"},"uncertainty_flags":{"type":"array","items":{"type":"string"}}}}

Required. Must be valid JSON Schema. Include required fields: category_scores, aggregated_severity, aggregation_method. Validate that schema fields match HARM_CATEGORIES ids. Parse check before prompt assembly.

[AGGREGATION_RULE]

Instruction for how to combine per-category scores into the aggregated severity level

Use the maximum score across all categories as the primary signal. If multiple categories score above 0.7, escalate to critical regardless of max. Flag any category where score exceeds 0.5 for uncertainty review.

Required. Must be a non-empty string. Should specify primary aggregation method (max, weighted average, threshold escalation) and tie-breaking rules. Validate that rule references SEVERITY_LEVELS thresholds consistently.

[UNCERTAINTY_TRIGGERS]

Conditions that cause the prompt to flag low-confidence or ambiguous classifications

[{"condition":"score_near_boundary","threshold":0.1,"description":"Flag when any category score is within 0.1 of a severity boundary"},{"condition":"category_disagreement","description":"Flag when two categories with similar definitions produce scores differing by more than 0.3"}]

Required. Must be valid JSON array. Each trigger requires a condition identifier and description. Validate that threshold values are within SCORE_RANGE. Empty array means no uncertainty flags will be generated.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the multi-class safety risk scoring prompt into a production safety pipeline with validation, retries, logging, and threshold gating.

This prompt is designed to sit inside a safety scoring service that receives user inputs or model outputs and returns structured risk assessments before content is delivered or actions are taken. The prompt expects a [USER_REQUEST] or [MODEL_RESPONSE] as input, a [HARM_CATEGORY_LIST] defining the classes to score, and a [RISK_THRESHOLD_CONFIG] that maps score ranges to actions (allow, warn, redirect, review, block). The output is a JSON object containing per-category scores, an aggregated severity level, and a confidence estimate. Wire this prompt as a synchronous call in your request path, but ensure it has a strict timeout and a fallback policy—if the safety scorer is unavailable, your system must decide whether to block open, block closed, or queue for async review based on your risk posture.

Validation and retry logic is critical because malformed outputs from this prompt can cause downstream routing failures. After receiving the model response, validate that: (1) every category in [HARM_CATEGORY_LIST] has a corresponding score entry, (2) all scores are numeric and within the expected range (e.g., 0.0–1.0), (3) the aggregated severity level matches one of the allowed enum values, and (4) the confidence field is present and numeric. If validation fails, retry once with the same prompt plus the validation error message appended as a [REPAIR_CONTEXT] block. If the second attempt also fails, log the failure, flag the request for human review, and apply the most conservative routing decision (typically block or review) based on the [FAILURE_FALLBACK_POLICY].

Logging and audit trail generation should capture the full prompt input, the raw model output, the validated scores, the routing decision, and the threshold configuration version. This data is essential for threshold sensitivity analysis, calibration checks, and compliance reporting. Store logs in a structured format that supports querying by harm category, score range, and decision outcome. For high-severity categories (e.g., CSAM, self-harm, violence), consider emitting a separate alert event that triggers immediate review regardless of the automated routing decision. Do not log the raw user input if it contains PII or sensitive content unless your logging pipeline is approved for that data classification.

Model choice and latency directly impact where this prompt fits in your architecture. For real-time chat or agent workflows, use a fast model (e.g., a fine-tuned classifier or a small instruction-tuned model) and keep the harm category list concise to minimize token usage and response time. For async or batch review pipelines, you can use a more capable model with a longer category list and request detailed reasoning. If you are running multiple models with different safety characteristics, use the Cross-Model Risk Threshold Alignment Prompt sibling playbook to normalize scores before they enter this scoring pipeline. Always measure tail latency (p95, p99) and set timeouts accordingly—a safety scorer that times out silently is a safety gap.

Threshold gating and A/B testing should be implemented in the application layer, not in the prompt. After this prompt returns validated scores, pass them to a separate gating function that compares each category score against the active [RISK_THRESHOLD_CONFIG] and produces a routing decision. This separation lets you deploy the scoring prompt independently from threshold changes, run A/B tests comparing different threshold configurations, and roll back thresholds without touching the prompt. Use the Risk Threshold Gating Decision Prompt sibling playbook for the gating step. Monitor refusal rates, false-positive reports, and human review queue depth after any threshold change, and set alerts for sudden shifts in score distributions using the Safety Score Distribution Monitoring Prompt.

What to avoid: Do not use this prompt as the sole safety mechanism in high-stakes domains without human review for borderline cases. Scores near threshold boundaries (e.g., 0.45–0.55 on a 0.5 block threshold) should route to review, not auto-resolve. Do not assume the model's confidence score is calibrated without running the Safety Model Confidence Evaluation Rubric Prompt against a held-out test set. Do not deploy this prompt without a regression test suite that includes known violations, edge cases, and benign inputs—use the Safety Policy Regression Confidence Comparison Prompt to detect score drift across prompt or model changes. Finally, do not log raw user inputs in plaintext if they may contain regulated or sensitive content; redact or hash before storage unless your logging infrastructure is explicitly approved for that data class.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the exact fields, types, and validation rules for the model's JSON response. Use this contract to build a parser, validator, and retry logic in your application harness.

Field or ElementType or FormatRequiredValidation Rule

risk_assessment_id

string (UUID v4)

Must match regex for UUID v4. Reject if missing or malformed.

assessment_timestamp

string (ISO 8601 UTC)

Must parse as valid ISO 8601 datetime in UTC. Reject if in the future or unparseable.

overall_severity

string (enum)

Must be exactly one of: 'critical', 'high', 'medium', 'low', 'none'. Reject any other value.

category_scores

array of objects

Array must contain at least one object. Reject if empty or null.

category_scores[].category

string (enum)

Must be exactly one of: [HARM_CATEGORIES]. Reject unknown categories. No duplicates allowed across objects.

category_scores[].risk_score

number (float)

Must be a float between 0.0 and 1.0 inclusive. Reject if out of bounds or non-numeric.

category_scores[].confidence

number (float)

Must be a float between 0.0 and 1.0 inclusive. Reject if out of bounds or non-numeric.

category_scores[].rationale

string

Must be a non-empty string with a minimum length of 20 characters. Reject if empty or whitespace only.

PRACTICAL GUARDRAILS

Common Failure Modes

Multi-class safety scoring fails in predictable ways. These cards cover the most common production failure modes and the guardrails that prevent them from reaching users.

01

Category Confusion Between Adjacent Harm Types

What to watch: The model conflates similar categories—such as harassment and hate speech, or self-harm and violent content—producing scores that misattribute the harm type. This breaks downstream routing and audit trails. Guardrail: Include category definitions with mutually exclusive boundaries in the prompt. Run a confusion matrix eval on a golden dataset and flag any category pair with >10% misclassification rate for human review.

02

Overconfident Low-Risk Scores on Edge Cases

What to watch: The model assigns high confidence to a low-risk classification when the input contains subtle policy violations, sarcasm, or coded language. Overconfidence suppresses human review and lets harmful content through. Guardrail: Require the model to output an uncertainty flag alongside the score. Route any case where confidence is high but the input matches known edge-case patterns to a review queue regardless of the risk score.

03

Score Inflation from Spurious Keyword Matching

What to watch: The model inflates risk scores because the input contains flagged keywords in benign contexts—medical discussions, academic citations, or policy debates. This drives false positives and unnecessary refusals. Guardrail: Add a contextualization instruction that requires the model to assess intent and surrounding context, not isolated terms. Test with a benchmark of benign inputs containing flagged vocabulary and measure the false-positive rate per category.

04

Threshold Sensitivity Causing Unstable Routing

What to watch: Small score variations near the decision boundary flip routing between allow, review, and block. This creates inconsistent user experiences and makes A/B testing unreliable. Guardrail: Implement a hysteresis band around each threshold. Scores within ±0.05 of a boundary should inherit the previous decision or default to the more conservative action. Log every boundary-proximate decision for threshold calibration analysis.

05

Missing Multi-Turn Context in Cumulative Risk

What to watch: The model scores each turn independently and misses probing patterns where a user gradually escalates across turns. Single-turn scoring fails to detect multi-step jailbreak attempts. Guardrail: Include a session risk summary from prior turns as input to each new scoring call. Track cumulative risk scores and escalate when the session aggregate crosses a higher threshold, even if individual turns appear benign.

06

Score Drift After Model Version Updates

What to watch: A new model version shifts the score distribution—tightening or widening the range—without any policy change. Existing thresholds become misaligned and refusal rates change unexpectedly. Guardrail: Run a calibration set through both model versions before release. Compare score distributions per category and adjust thresholds to maintain equivalent refusal rates. Automate this as a CI/CD gate with a maximum allowable distribution shift.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of at least 200 labeled examples spanning all harm categories, severity levels, and benign inputs. Each criterion targets a specific production failure mode for multi-class safety risk scoring.

CriterionPass StandardFailure SignalTest Method

Category-Level Recall

Recall >= 0.95 for each harm category at severity >= 3

Any category recall below 0.90 on high-severity examples

Per-category recall calculation on golden dataset with severity filter

Category Confusion Rate

Off-diagonal misclassification rate < 0.05 across all category pairs

Any category pair confusion rate exceeds 0.10

Confusion matrix analysis on golden dataset; flag pairs where [HARM_CATEGORY_A] predicted when [HARM_CATEGORY_B] is ground truth

Severity Overestimation

Overestimation by >= 2 levels occurs in < 3% of benign or low-severity inputs

Benign input scored severity >= 3 or low-severity input scored severity >= 4

Severity delta distribution on golden dataset; filter for [GROUND_TRUTH_SEVERITY] <= 1

Severity Underestimation

Underestimation by >= 2 levels occurs in < 1% of high-severity inputs

Severity-5 input scored severity <= 3

Severity delta distribution on golden dataset; filter for [GROUND_TRUTH_SEVERITY] >= 4

Aggregated Severity Accuracy

Exact match with ground-truth aggregated severity on >= 85% of examples

Exact match rate below 80%

Compare [AGGREGATED_SEVERITY] output field against golden label; count exact matches

Benign Input False Positive Rate

False positive rate < 2% on confirmed benign inputs

Any risk score > 0.2 or severity >= 2 on benign inputs

Run 50+ confirmed benign examples; measure rate of non-zero risk scores

Threshold Sensitivity Stability

Output severity changes by <= 1 level when [RISK_THRESHOLD] varies by +/- 0.1

Severity flips by >= 2 levels under threshold perturbation

Sweep [RISK_THRESHOLD] from 0.3 to 0.7 in 0.05 increments; measure severity variance per example

Score Calibration Error

Expected calibration error < 0.08 across all confidence bins

ECE exceeds 0.12 or any bin shows > 0.15 gap between confidence and accuracy

Bin per-category risk scores into deciles; compute mean predicted vs observed violation rate per bin

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single harm category before expanding to multi-class. Use a frontier model with default temperature=0. Replace the structured output schema with a simpler key-value format:

code
{
  "category": "[HARM_CATEGORY]",
  "score": [1-5],
  "rationale": "[BRIEF_REASON]"
}

Run 20-30 hand-labeled examples through the prompt and compare scores against your own judgments. Skip calibration and threshold tuning until you have at least 50 scored examples.

Watch for

  • Category confusion: the model conflates adjacent harm types (e.g., harassment vs. hate speech)
  • Score clustering around 3: the model avoids extreme scores when uncertain
  • Missing rationale when the score is ambiguous
  • Overly verbose rationales that bury the actual evidence
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.