A guide to improve your brand safety
Casey Justus
Forward Deployed AI Engineer
Defne Yazicioglu
Forward Deployed AI Engineer
As part of Google Cloud's forward deployed engineering (FDE) team, we build and launch consumer-facing AI agents with our enterprise customers.
Across these deployments, we consistently see customers face hurdles across industries. That’s why we’ve compiled this guide to help you identify ways to get ahead of potential issues. Ultimately, it comes down to:
-
Defining brand guidelines early: Agree on priority risks early, not at the end of the project.
-
Acknowledging system limits: Deterministic controls enforce explicit rules while instruction-based controls reduce failure probability. Pair guardrails with an incident response plan.
-
Accounting for latency: Every safety layer sits on the request path, so size your classifiers and filters for traffic spikes.
Outline what you can predict, versus what you can’t
Effective brand safety depends on multiple layers working together to address predictable threats. To be thorough, make sure you have all the right layers working together, for example:
-
Programmatic protection: Fast, deterministic checks that catch known attacks and obvious policy violations.
-
Generative logic: Custom checks for each application that handle nuance, domain-specific limits, and structured output.
-
Customizable controls: Fine-tuned classifiers and human review configured for specific operational risks.
For everything you can’t predict, continuous production monitoring is essential.
Implement multi-tier stratified sampling
At enterprise scale, reviewing every interaction isn't practical. Simple random sampling also falls short because it treats all traffic equally, leaving reviewers sorting through routine conversations while rare, damaging failures slip through.
Multi-tier stratified sampling moves production traffic into distinct tiers (strata) based on automated risk signals, and then assigns a different sampling rate to each tier. Stratified sampling routes flagged inputs to high-priority review while maintaining a baseline sample rate to catch unpredictable edge cases. Here’s a helpful table to visualize:
Tier 3 is where unexpected edge cases surface.
Find the outliers with embeddings
Random sampling alone can miss rare edge cases. To get ahead of this, map user queries into an embedding space and group them with unsupervised clustering (such as K-Means). This helps organize traffic around validated use cases, establishing baseline behavior patterns.
For each new interaction, calculate its cosine distance and local outlier factor against these baselines. Interactions exceeding three standard deviations (3σ) route directly to Tier 1 for full review.
Establish a measurable risk threshold
Determining the required sample size for Tier 3 human review depends on target confidence levels. If p represents the minimum failure rate you want to detect and n is your sample size, the probability of catching at least one issue is:
P(finding ≥ 1) = 1 − (1 − p)ⁿ
Solving for n aligns risk appetite with a predictable operational review workload:
Calculating a 95% confidence interval for the observed failure rate allows automated drift alerts to trigger if the upper bound exceeds defined thresholds.
Finally, close the feedback loop
Effective anomaly detection requires immediate action through two primary checkpoints:
-
Pre-deployment (CI/CD): Prompt changes and model updates are evaluated against a golden dataset using adaptive rubrics, safety and grounding rubrics, and computation-based metrics.
-
Post-deployment (online monitoring): Production traffic monitors score sampled interactions and send alerts to Cloud Monitoring when quality or safety metrics drop.
Confirmed anomalies are added to the golden dataset, converting production incidents into regression tests for future releases.
Get started
Passing pre-launch testing is the starting line, not the finish line. To make brand safety a continuous, measurable practice:
-
Try the three-tier anomaly detection notebook on GitHub. It uses Vector Search and Gemini to build brand-safe baselines, set thresholds, and send confirmed threats to human review.
-
Read the documentation on agent evaluation and continuous evaluation with online monitors.
-
Set up Model Armor and align your program with Google's Secure AI Framework (SAIF).
