ShieldGemma content safety checks in NeMo Guardrails

ShieldGemma can act as a dedicated input or output judge in NeMo Guardrails. This page covers how its yes or no judgment is parsed, how to write the policy text it judges against, and how it fits beside other safety models.

On this page

How ShieldGemma content safety checks work in NeMo Guardrails

ShieldGemma acts as a dedicated safety judge that classifies user inputs or model outputs as safe or unsafe, so the application LLM does not have to grade its own traffic. Your team is considering it because a separate judge model is easier to review, test and swap than asking the application model to police itself. NeMo Guardrails 0.25.0, the current release, is an Apache 2.0 open-source library that supports Python 3.11, 3.12 and 3.13, so the platform itself carries no license fee for the framework. ShieldGemma is a model you choose to run, and its hosting and GPU costs are yours to plan.

NeMo Guardrails provides five rail types: input rails, dialog rails, retrieval rails for RAG chunks, execution rails for custom actions and tools, and output rails. A ShieldGemma check fits most naturally on input rails, which screen the user message before the application LLM sees it, and on output rails, which screen the drafted answer before the user sees it. Retrieval and execution rails are worth considering if untrusted documents or tool results are part of your threat model. The model is called through the same configuration pattern used for other safety models in the library, built from config.yml, prompts and any Colang files, so the policy wiring your team learns for one judge carries over to the others.

The supplied material does not cover ShieldGemma's exact prompt format, its category names, or how its yes or no answer is expected to be parsed. Confirm all three before you write any policy text. Check the NeMo Guardrails documentation for the supported model and prompt configuration, and check Google's own ShieldGemma model documentation for the required template and category definitions. Then run a small set of safe and unsafe examples through the rail to confirm the parser reads the verdict correctly before you rely on it in a review.

Which ShieldGemma configuration fits your deployment

This table compares the main ShieldGemma choices in NeMo Guardrails: where the check sits, whether it judges alone or in a chain, where the model runs, and whether you keep the default policy text. Read each row for its trade-off in latency, coverage and evidence, and confirm the listed items before you commit to a design.

DecisionOptionTrade-offWhat to confirm before choosing
Rail placementInput rails onlyBlocks unsafe prompts before the application model runs, saving that call, but misses unsafe content the model generates from a benign prompt.Which request types reach the model and whether a separate output check is required by your review.
Rail placementOutput rails onlyJudges what the assistant actually says, but unsafe prompts still reach the application model and may be logged there.Whether your policy covers user intent or only generated text, and how logs of blocked prompts are handled.
Rail placementInput and output railsHighest coverage with two judge calls per exchange, so latency and GPU load roughly double on the checked path.Your latency budget per turn and whether reviewers expect evidence for both directions.
Judge chainShieldGemma as sole judgeSimplest to test and document, with one policy and one parser, but a single model's blind spots apply to every category.Which harm categories your use case needs and whether a single model's results satisfy your evaluation plan.
Judge chainShieldGemma with self-check or other guardsCatches more cases through overlap, at the cost of added latency and more prompts and parsers to maintain and test.Ordering of rails, how a block from one rail is reported, and whether a second model needs its own hosting.
HostingYour own GPUsKeeps prompts and outputs inside your network and gives you control over versions, but you own capacity planning and patching.Hardware needed for the model size you select, and whether your air-gapped or residency rules require it.
HostingModel endpoint you operateLets you separate the safety model from application infrastructure, but adds a network hop and an endpoint you must secure and monitor.Who operates the endpoint, its authentication, and its logging and retention settings.
Policy textDefault policy wordingQuickest to start and matches the model's published categories, but may not reflect your acceptable use policy.Whether the default categories match your written policy and what an assessor will ask you to map them to.
Policy textYour own written policy textAligns judgments with your rules and reviewer expectations, but requires a test set and evaluation before enforcement.Who owns the policy text, the labeled test cases you will use, and the acceptance criteria for enforcing it.

How a request passes through ShieldGemma and the application LLM

A user message enters NeMo Guardrails and reaches the input rails, where a ShieldGemma check judges the prompt against your policy text on a self-hosted endpoint. If the prompt is allowed, the application LLM generates a response, and the output rails send that response back to ShieldGemma for a second judgment before it reaches the user. Check that both hand-offs stay inside the trust boundary and that each blocked or allowed outcome is logged.

Prompts and responses are judged by ShieldGemma inside the boundary before any outcome reaches the user.

How the yes or no judgment becomes a block decision

The contract between NeMo Guardrails and ShieldGemma is simple to describe and easy to get wrong. The rail assembles a prompt that contains the policy text the judge should apply and the user input or model output under review. ShieldGemma reads that prompt and returns a verdict, typically a single word that signals whether the content violates the policy. An output parser then maps that verdict to a allow or block decision, and the rail either passes the message through or triggers its refusal path. Every element of this chain is configuration you own, so the team must be able to name each piece: the prompt template the rail uses, the policy text inserted into it, the expected verdict tokens, and the action taken on each result.

The parser is where most silent failures happen. If the model returns a format the parser does not expect, such as extra words, different casing, or a verdict wrapped in other text, the parser may treat the result as unsafe and block every request, or treat it as safe and let unsafe content through. Neither failure produces an error message, so the problem can stay hidden until a user or auditor finds it. Confirm the exact prompt template, the verdict tokens and the parser behavior in the NeMo Guardrails documentation for the version you run, and check them against the ShieldGemma model card for the model variant you deploy. Do not copy a template from a blog post or an older release.

Test the parser before any rail goes live. Build a small set of clearly safe and clearly unsafe samples for each policy category you enforce, run them through the full rail rather than the model alone, and record the decision for each. Include borderline and oddly formatted inputs as well. Re-run the set after every change to the model version, the policy text, the NeMo Guardrails version or the serving stack, because any of these can change the verdict format. Treat a rail that blocks all safe samples or passes all unsafe samples as a configuration defect, not a tuning problem, and fix the parser before adjusting thresholds.

What the policy text controls and where it goes wrong

The policy text is the only instruction ShieldGemma gets about what counts as a violation, so it sets both what gets blocked and what gets missed. The cards below cover the failure modes that show up when that text is written once, copied between rails, or left at a generic default.

State violations in plain terms

ShieldGemma judges each message against the policy text you supply, so a vague line such as "no harmful content" leaves the model to guess the boundary. Write each prohibited behavior as a sentence describing what the user or model would do, and say what it looks like in your application. The failure mode is a policy that reads well to the team but produces inconsistent yes or no answers on the same kind of message. The test is to run a fixed set of clear violations and clear allowed requests through the rail and confirm the verdicts match your intent.

Scope categories to real use

A policy written for a general chatbot will flag content that is ordinary in your product, such as a clinician asking about medication doses or a security analyst asking about malware. List only the harm categories your application can realistically receive, and note which ones it should never discuss at all. The failure mode is importing a generic category list without checking it against sample traffic. The test is to replay a sample of real or synthetic user requests from your application and review every block for whether it was a valid support request.

Keep input and output wording aligned

Input and output rails often reuse the same policy text, but a user request and a model answer carry different risks, so teams edit one and forget the other. Keep a single source file for the policy, load it into both rails, and record any intentional difference in a comment next to the config. The failure mode is an input rail that blocks a topic while the output rail allows the same topic to leak back through a model answer. The test is to send one prompt through both directions and confirm the two verdicts agree or the difference is documented.

Avoid policy text that is too broad

Broad wording such as "anything related to security" or "sensitive personal topics" causes the judge to block valid support requests, including password reset steps, account lockout help and privacy questions from customers. Each broad clause should be narrowed to the specific action you want to stop. The failure mode is a support queue that shows more refusals after rollout than before. The test is a false-positive review of the support requests your team handles most often, tracking which clause triggered each block.

Avoid policy text that is too narrow

Policy text that names only obvious examples misses harms phrased indirectly, such as a request framed as fiction or a question that asks for steps without naming the target. Narrow wording also fails when users write in other languages or use slang. Review the harms your team cares about most and confirm each one has a matching clause that describes the behavior, not only the keyword. The failure mode is a clean dashboard that hides misses. The test is a red-team set of indirect and multilingual variants checked against the policy, with missed cases reviewed for the clause that should have caught them.

Confirm the policy against the model documentation

Before you rely on a category list, confirm the wording and the number of categories ShieldGemma is trained to judge in the model's own documentation and prompt format, because a policy that asks for categories the model does not evaluate will produce answers you cannot interpret. Ask your NeMo Guardrails configuration owner to record the exact category text used in production. The failure mode is an undocumented policy that changes silently during a model or prompt update. The test is a version-controlled policy file with a regression set that runs on every change.

NeMo Guardrails docs

Set up ShieldGemma as a guard in a NeMo Guardrails configuration

This sequence takes an engineering team from an empty environment to a NeMo Guardrails configuration in which ShieldGemma judges user inputs or model outputs against a written policy. Each step ends with a check, so the team knows the model is reachable, the rail fires on known unsafe samples, and known safe samples pass before the configuration moves toward production.

  1. Confirm the Python version

    The engineer building the environment checks that Python 3.11, 3.12 or 3.13 is available on the host or build image by running python3 --version. NeMo Guardrails 0.25.0 requires one of these three versions, so any other interpreter should be replaced before continuing. Done when the command prints a supported version and the team records it in the build notes.

  2. Install a pinned nemoguardrails release

    In a dedicated virtual environment, the engineer runs pip install nemoguardrails==0.25.0 so that every developer and container uses the same release. 0.25.0 is the current release on PyPI under the Apache-2.0 license. Done when pip show nemoguardrails reports version 0.25.0 and python -c "import nemoguardrails" runs without error.

  3. Register the ShieldGemma endpoint in config.yml

    The engineer adds a model entry to config.yml that points at the endpoint where ShieldGemma is served inside your infrastructure. Credentials go in environment variables or a secrets store, never in the file. Confirm the exact model type and engine keys in the NeMo Guardrails documentation for 0.25.0 before copying them. Done when a direct request from the host running NeMo Guardrails returns a response from the model endpoint.

  4. Write the policy text the judge uses

    The policy owner, with the security or compliance lead, writes the policy text in a file inside the configuration folder. It should state which categories of content are unsafe, what is allowed, and how a borderline case should be judged. ShieldGemma answers yes or no against this text, so vague wording produces inconsistent results. Done when each category in the text has at least one planned test sample and the owner has approved the wording.

  5. Attach the judge to input and output rails

    The engineer defines Colang flows that call the ShieldGemma check on user messages and on model responses, then lists those flows in the rails section of config.yml. Colang 1.0 is the default, so write 1.0 syntax unless the configuration explicitly selects 2.0. Done when the configuration loads without errors and the input and output rails appear in the loaded configuration.

  6. Run the guardrails server or Python API locally

    The engineer starts the guardrails server against the configuration folder, or loads the same folder through the Python API in a local script. The server exposes an HTTP API, and the project's Dockerfile can be used later to build a container image from the same folder. Done when a test request to the local endpoint returns a response and the logs show the ShieldGemma model was reached.

  7. Test with safe and unsafe prompts

    The engineer builds a fixed set of known unsafe and known safe user prompts, plus unsafe and safe sample model responses, and sends each through the configuration. Unsafe samples should be blocked with the configured refusal, and safe samples should pass unchanged. Any miss or false block returns to the policy text or rail wiring for revision. Done when every unsafe sample is blocked and every safe sample passes, and the test set is stored in version control to rerun after each change.

Where ShieldGemma sits next to other safety models

A dedicated judge such as ShieldGemma is one layer in a stack, and the useful decision is which layer answers which question, not which model wins. The alternative most teams start with is a self-check prompt, where the application LLM judges its own inputs and outputs. That costs no extra model but shares the application's blind spots and its failure modes. A dedicated judge adds a separate model to deploy, version and monitor, but it gives you a fixed classifier with a predictable prompt contract. The library also ships NVIDIA content safety and topic safety models, jailbreak and injection detection, and third-party integrations, so ShieldGemma is rarely the only check. Map each rail to the risk it covers, and avoid stacking two judges that answer the same question unless you have measured a reason.

Order the rails so cheap checks run first. Deterministic filters, length limits, allow lists and pattern checks cost almost nothing and should reject obvious cases before any model call. Jailbreak and injection detection and topic checks come next, and the ShieldGemma judge runs only on input or output that passes those gates. Each added judge adds latency for every request that reaches it, and each one is another model your team must host, patch and re-test after upgrades. Confirm the exact order and whether rails run in parallel in your release of NeMo Guardrails, because the configuration determines what a blocked request still costs.

Decide in advance how overlapping verdicts are resolved. If ShieldGemma flags an output that a self-check rail passes, the policy must say which verdict wins, whether any single block stops the response, and whether the refusal message differs by rail. Record which rail blocked each request so the trace shows the decision. Test disagreements deliberately with labeled examples. For the full comparison of accuracy, latency, language coverage and GPU needs, read the decision page on choosing a content safety model alongside the sibling page on self-check input and output rails, and use their findings rather than repeating them here.

Security and operational considerations for a judge model

A ShieldGemma judge sits in the request path, so it inherits the same questions as any service that handles prompts and responses. The cards below cover where that data goes, what gets recorded, how credentials and versions are managed, and why the judge should be one control among several.

Data flow and network location

Every prompt and response the rail checks is sent to the judge endpoint, so the endpoint's location decides where that content travels. Confirm whether your ShieldGemma deployment runs inside your network or calls a hosted service, and document each hop. If the NeMo Guardrails server and the model endpoint sit in separate networks, review the path between them as part of your data flow.

NeMo Guardrails docs

Logging and log access

Guardrail logs can capture the text that was judged, including the blocked content you most need to protect. Decide what is logged at each rail, how long logs are kept, and which roles can read them. Treat judged prompts as sensitive data in your logging policy, and confirm how the server's logging settings behave in the version you deploy.

Endpoint secrets outside config files

The judge model endpoint usually needs an API key or token. Keep it in your secrets manager or a container secret, and reference it through an environment variable instead of writing it into config.yml or a Colang file. Config folders get copied into images, tickets and repositories, so a key placed there is effectively published to everyone who can read them.

Pinning and testing before upgrades

Pin the NeMo Guardrails package version and the ShieldGemma model revision in your build, so a change in either cannot reach production silently. NeMo Guardrails 0.25.0 is the current release, and the previous release was 0.24.1. Re-run your judge tests against each candidate version before promoting it, and record which versions passed.

NeMo Guardrails releases

A judge is not the only control

A safety model reads the same text the attacker writes, so crafted input can sometimes slip past it. Pair ShieldGemma with other checks such as jailbreak and injection detection, output constraints, tool permissions and access control on the application itself. Treat the judge as one layer that reduces risk, not as a guarantee.

An evaluation record for auditors

Keep a dated record of the policy text, the test prompts (safe and unsafe), the expected and actual verdicts, and the versions tested. This record shows reviewers what the judge was asked to catch and how you checked it. Store it alongside the configuration in version control, and refresh it whenever the policy or model changes.

Limits to confirm before relying on ShieldGemma in production

Before you put ShieldGemma in front of users, confirm the model's release, license and fit with your policy. Ask Google which ShieldGemma release you would deploy and what its license terms allow for your use, including commercial use and redistribution inside your own infrastructure. Then ask which languages and content types the model was built to judge. If it was built mainly for English text, your multilingual traffic, images or retrieved documents may fall outside what the vendor tested, and you should measure that gap yourself with your own sample of prompts and responses. Also confirm whether its categories match your acceptable use policy. A category that exists in the model but not in your policy, or a policy harm with no matching category, will produce decisions your reviewers cannot explain.

Next, verify the prompt and parser behavior in the exact NeMo Guardrails version you will install. Check how the rail fills the policy text, which output the model must return for a violation, and what the parser does with malformed or empty responses. Test both directions, since a parser that fails open on an unexpected answer will pass unsafe content. Treat the NeMo Guardrails releases page as the place to confirm release-specific behavior, because the current release is 0.25.0, which deprecates the LLMRails class in favor of Guardrails. Removal is planned no earlier than 0.27.0, so ask whether your configuration and Python code will need migration before you upgrade past it.

Choose the deployment path with the sunset in mind. NVIDIA has sunset the NeMo Guardrails microservice container as of October 1, 2026, with no new releases or support for that artifact, so do not build a production path around it. Confirm with your NVIDIA account team what replaces it for your environment, and plan to run the library or server image you control. Keep a written record of each answer, the version tested and the test results, because those records will be the evidence your reviewers ask for when they approve ShieldGemma in your stack.

Questions buyers ask about ShieldGemma checks in NeMo Guardrails

What drives the effort of adding ShieldGemma as a content safety check?

The effort is driven less by the NeMo Guardrails configuration and more by four pieces of work: writing the policy text the model judges against, testing the output parser so that yes or no answers map reliably to block or allow decisions, hosting the model on infrastructure you control, and building an evaluation set that shows how the rail behaves on your own traffic. Policy definition usually takes the most review time because compliance, legal and product owners have to agree on what counts as unsafe for your application. Parser testing and evaluation scale with the number of languages, content types and rails you enable. Ask any partner to break its quote into these four areas so you can see where the hours go.

Can our own team add ShieldGemma without outside help?

A team with Python experience, access to a GPU or model serving platform, and someone who owns the safety policy can do the work in-house. The team needs to read the NeMo Guardrails configuration documentation, build a small test suite of safe and unsafe prompts and responses, and tune the policy text until results match the decisions your reviewers would make. Outside help is most useful when the setup must pass a formal review, when several applications share one guardrail service, or when the team lacks people who can own evaluation over time. Confirm with your own engineers which of these skills are already in place before deciding.

How long does a ShieldGemma setup and evaluation take?

The duration depends on scope, not on a fixed number. A single input rail for one application with one written policy takes far less time than output and input rails across several assistants, languages and deployment environments. The main drivers are how many rails and applications are covered, how many policy categories you define, whether the model is hosted in your own cluster or an air-gapped network, how much evaluation data exists, and how many review cycles your compliance team requires. Ask for a timeline tied to a written scope with named deliverables, and do not accept a duration that is not tied to those items.

What recurring work follows go-live with ShieldGemma?

Several items recur after launch. You will need to review the model and NeMo Guardrails library releases you run, retest the rails after each upgrade, and update the policy text when products, user populations or regulations change. Parser and threshold behavior should be rechecked whenever the model version changes, and the evaluation set should grow as new misuse patterns appear in logs. Budget for ongoing ownership of these tasks, whether internal or through a support or retest retainer. Ask any provider to list which tasks are included in a retainer and how often retests run.

Does ShieldGemma replace other safety models in NeMo Guardrails?

No. ShieldGemma is one judge among several options, and it does not replace self-check prompts, other dedicated safety models, jailbreak and injection detection, or PII rails unless your evaluation shows it covers the same risks for your application. Each model has its own policy coverage, language support and latency profile, so most teams compare them on their own test data before choosing. Many configurations layer a fast check in front of a heavier model. The decision page on choosing a content safety model for NeMo Guardrails covers those trade-offs in more detail.

How does the NeMo Guardrails microservice sunset affect a ShieldGemma plan?

NVIDIA's NGC catalog page states that the NeMo microservices have been sunset as of October 1, 2026, with no new releases and no continued support for the artifact. If your plan assumed the NeMo Guardrails microservice container, you should confirm the replacement path with your NVIDIA account team before committing. The open-source library, licensed under Apache 2.0, is still published with new releases, and it can be run through its Python API or as a self-hosted server built from a Dockerfile. Plan the ShieldGemma configuration so it works with the library, and confirm with NVIDIA how the NeMo Platform and its control plane relate to your deployment.

How DeployOpen works on this

DeployOpen treats ShieldGemma as one judge in a larger safety design. We first agree which inputs and outputs it checks, the policy text it judges against and how its yes or no answer maps to blocking. We then build the NeMo Guardrails rails, test them against your own prompts and documents, and hand over configuration and evidence your teams can review and run.

How we scope

  • Written scope lists which input and output rails call ShieldGemma and which other checks run alongside it.
  • Policy text is drafted and reviewed with your risk and compliance owners before any rail is configured.
  • Hosting is agreed up front: where the ShieldGemma model runs, its GPU needs and any network limits.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we build

  • Rails are built in config.yml and Colang files, with the ShieldGemma prompt and output parser set explicitly.
  • The policy text and category mapping are kept in version-controlled files that your team can review.
  • Test sets of safe and unsafe inputs and outputs, drawn from your own use cases, are run against each rail.
  • Blocking responses and logging behavior are configured so refused requests can be traced during review.

How we hand over

  • Handover covers configuration, deployment artifacts, test results and a runbook for changing the policy text.
  • Documentation explains each yes or no decision path, the parser behavior and the known false positive patterns found in testing.
  • Your engineers are walked through how to add a new check and rerun the test set before a change goes live.
  • Evidence packs describe controls and test results so your compliance team can review them with auditors.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Retainers can cover tracking NeMo Guardrails releases and retesting ShieldGemma rails after each upgrade.
  • Ask any provider to confirm which NeMo Guardrails version and Python version the rails are tested against.
  • Confirm in the quote who owns the model hosting, updates to policy text and the retest schedule after go-live.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.