Unsafe Output at a glance
When to use this metric
Configure Unsafe Output
Unsafe Output requires your own output-policy rules.1
Create a copy of the Unsafe Output metric
From the Metrics Hub, select Unsafe Output, then select
Duplicate metric. The copy is an editable custom LLM-as-a-judge metric.
2
Locate the user-defined rules section
Find this section in the prompt:
3
Add your output-policy rules
Replace These are examples, not built-in rules. Add only the rules that represent
the output contract for your application.
{{ Add your rules here }} with a numbered list of rules. Include
only requirements that apply to your application, and make each rule
specific enough to verify from the available context.For example:4
Save and test the metric
Save the duplicate, then test it on representative safe and violating
examples before enabling it for a Log Stream or experiment.
How it works
Unsafe Output evaluates rules in three stages:1
Determine applicability
The judge first determines whether each configured rule applies to the task
and output. An inapplicable rule passes by default.
2
Check concrete evidence
For each applicable rule, the judge looks for a visible or materially
implied violation in the output. It uses the complete LLM span context to
distinguish supplied facts from fabricated claims and to understand the
output format and downstream destination.
3
Return the classification
The result is
true when at least one applicable rule fails. The result is
false when every applicable rule passes. The generated explanation cites
the evidence used for the decision.Interpret the score
false/ No: The judge found no concrete violation of the configured rules.true/ Yes: The judge found a concrete violation of at least one applicable configured rule.
A
false result does not certify that an output is safe in every respect. It
means only that no violation was found for the rules and context supplied to
this metric.Best practices
- Write one verifiable requirement per numbered rule.
- State when a conditional rule applies. For example, start a JSON-specific rule with “When the response is JSON.”
- Name the downstream destination when representation matters. Escaping for a JSON value differs from escaping for HTML, Markdown, SQL, or a shell.
- Express requirements, not optional hardening or stylistic preferences.
- Include both passing and violating edge cases when you test the metric.
- Combine this metric with deterministic parsing or validation when exact syntax is security-critical.
Performance benchmarks
We evaluated the canonical Unsafe Output prompt against trusted labels on an internal dataset of 877 output-policy examples. Unresolved annotation cases were excluded from the evaluation. The positive class istrue (unsafe).
Gemini 3.5 Flash classification report
Accuracy: 0.9339 (819 of 877 examples).
Benchmarks are based on an internal evaluation dataset. Performance varies
with the model, rules, application context, and number of judges.