Restricting topics with NemoGuard TopicControl in NeMo Guardrails

NemoGuard TopicControl checks whether a request falls inside the topics your assistant is allowed to discuss. This page covers how to write the topic rules, choose hosted or self-hosted NIM, and test borderline requests before enforcement.

On this page

When a NemoGuard TopicControl rule is the right way to keep an assistant on topic

NemoGuard TopicControl is a model-based topic rail that NeMo Guardrails can call to decide whether a user message stays inside the subjects your assistant is approved to discuss. Teams choose it when an assistant serves customers or staff in a regulated or public-facing setting and the approved scope is easier to describe in plain language than to enumerate as Colang flows. A Colang-only topical rail depends on the intents and example utterances you write and maintain, so off-topic phrasings you did not anticipate can slip through. A general moderation check answers a different question: whether content is harmful. A harmless question about a medical condition can still be out of scope for a banking assistant, and a moderation check will not catch that. Choose TopicControl when scope itself is the policy and you can test the boundary cases before enforcement.

Treat the rail's result as a contract. For each user message, the rail returns an on-topic or off-topic decision, and your configuration decides what happens next: the turn continues, or a refusal is sent. Your design should make that decision explicit and testable, including what the application does when the decision is off-topic and what it logs. The exact decision values, any score or label fields, and how the result is passed back through the configuration depend on the TopicControl model documentation for the release you run. The current NeMo Guardrails release is 0.25.0, so confirm those details in the NeMo Guardrails documentation before you write the rule set. Do not assume output fields carried over from an earlier release.

Before enforcement, decide three things: who writes and approves the allowed and disallowed topic descriptions, which borderline requests you will test, and what the off-topic reply says. Ask your compliance lead to review the approved scope in writing, since the rule text becomes evidence that assessors will ask to see. Plan tests on both sides of the boundary, including adjacent subjects your product should answer and subjects it should decline. Confirm, through the vendor documentation or your own tests, how the rail handles the languages your users write in, and retest whenever you change the topic descriptions or move to a new release.

Configuration options for topic rules and where each fits

This table compares the five settings a team decides before enforcing topic rules in NeMo Guardrails. Read each row as a choice: when it fits, what changes in a test run, and what to check in the configuration reference before you rely on it. Treat the reference as the final word on field names and behavior, since this table does not name configuration keys.

OptionWhen it fitsWhat changes in a test runConfirm in the configuration reference
Allowed topic listAssistant has a narrow remit, such as a single product or support queue, and every legitimate request maps to a named area.Requests outside the listed areas should classify as off-topic, so borderline questions near the edges need explicit test cases.How allowed topics are declared in config.yml, and whether an empty or missing list changes enforcement.
Disallowed topic listCertain subjects must be refused even when they sound related to the assistant, such as legal advice or pricing commitments.Requests on the listed subjects are refused, so test paraphrases and adjacent questions to find over-blocking.Whether disallowed topics are checked before or after allowed topics, and which response applies when both match.
Topic description wordingEach topic needs a short, specific description that a reviewer can apply to a sample request without guessing.Changing one sentence can move borderline requests across the line, so rerun the full borderline set after every edit.How descriptions are passed to the model, length guidance, and whether examples inside descriptions are supported.
Off-topic response handlingUse a fixed refusal when the assistant must not improvise, or route to a scripted or escalation reply for regulated support flows.Test runs show which reply the user sees, so check that refusals do not reveal the policy text or internal labels.Which response option exists for off-topic input, whether the refusal is customizable, and where it is set.
Hosted or self-hosted modelHosted fits quick evaluation; self-hosted fits data residency, air-gapped networks, or fixed model versions you must control.Latency, availability and output can differ between endpoints, so rerun the same test set on the target endpoint before enforcement.Which model endpoints are supported, what license and access terms apply, and how the endpoint is configured in config.yml.

How a user message passes the TopicControl rail before the assistant answers

The diagram starts when your application sends a user message to the NeMo Guardrails runtime, before any call to the main model. The input rail sends the message and your topic rules to the TopicControl model, which returns an on-topic or off-topic verdict. Off-topic messages get a refusal or are handed off to your fallback path and never reach the main LLM. On-topic messages are forwarded to the main model endpoint, and the answer returns to the user. Check which endpoint each box calls, where the runtime writes its logs, and which boundaries prompts cross.

Request path through the TopicControl input rail, with trust boundaries and log location marked.

Setup sequence for TopicControl rules from first config to enforcement

This sequence takes a NeMo Guardrails project from an empty folder to a TopicControl rail that refuses off-topic requests in your environment. Each step closes with a check, and the rail is enforced only after allowed and refused test prompts both behave as written. Most of the effort goes into writing and testing the topic definitions that the model judges requests against.

  1. Confirm the Python version and library release

    The engineer running the build confirms the runtime before writing any configuration. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, so check python --version and install the nemoguardrails package on PyPI into a clean virtual environment. Pin the release you test with and record it in your change log. Confirm you are installing the open-source library, because NVIDIA sunset the NeMo Guardrails microservice as of October 1, 2026, and the build should not depend on its container. Done when pip show nemoguardrails reports the pinned version on a supported interpreter.

  2. Create the config folder and config.yml

    The engineer creates a config folder containing config.yml, which holds the settings for the main LLM and the rails the assistant will use. Decide the Colang version now, since Colang 1.0 is the default, Colang 2.0 is also supported, and the two use different syntax. Group the TopicControl settings in one place so reviewers can find them in a diff. Done when the server or Python API loads the folder without a configuration error. A clean load proves the file structure is sound before any topic rules exist.

  3. Write the Colang file with topic rules

    The policy owner writes the allowed and disallowed topics in plain language, with a short description of what falls inside each one. TopicControl judges each request against these definitions, so vague wording produces inconsistent decisions. Add the refusal message the assistant returns to off-topic requests. Have a second reviewer read the lists and label which side each borderline example belongs on before any model test runs. Done when the reviewer's labels match your intent for every borderline example in the list.

  4. Connect the TopicControl model endpoint

    The platform engineer points the config at the TopicControl model, either a hosted NIM endpoint or a self-hosted NIM inside your network. A self-hosted endpoint keeps prompts inside your own infrastructure, which is often the reason regulated teams choose it. Keep API keys in environment variables or your secrets store, not in config.yml or the Colang files. Confirm the model name, endpoint URL and authentication settings in the NeMo Guardrails documentation for your pinned release, since these settings are version-specific. Done when one direct request from the guardrails host to the endpoint returns a valid model response.

  5. Test allowed and refused prompts before enforcement

    The QA engineer runs a fixed test set through the configuration before the rail is turned on for users. Include at least one on-topic prompt that must be allowed, one clearly off-topic prompt that must be refused, and the borderline examples the reviewer labeled. Record the output for every prompt. If an allowed prompt is refused or a disallowed prompt passes, adjust the topic definitions and rerun the full set so a fix cannot quietly break earlier cases. Done when every prompt in the set produces its expected result on a full rerun.

  6. Run the server or Python API for enforcement

    The platform engineer starts the guardrails server against the config folder, either directly or from a container built with the Dockerfile provided in the project, or wires the Python API into the application. New code should use the Guardrails class, because NeMo Guardrails 0.25.0 deprecates LLMRails in its favor, and the 0.25 migration guide covers the change. Run the same test set against the deployed instance, not only the local copy. Done when an allowed prompt gets a normal answer and a refused prompt gets the refusal message from the deployed instance. Only then should user traffic be routed to it.

Hosted versus self-hosted NIM for the TopicControl model

On the hosted path, each TopicControl check sends the user message and the topic rules from your runtime to an NVIDIA-operated endpoint, so that content leaves your infrastructure. On the self-hosted path, the same check runs in a NIM container you operate, so the classification call stays on hosts you control. The data flow diagram for your risk review should show both the request fields and the retention terms for each path.

  • Hosted payload: Confirm which fields leave your environment on each call, such as the current user turn, conversation history, system prompt and topic definitions.
  • Retention on the hosted side: Confirm whether NVIDIA stores or uses request content from the hosted endpoint, and for how long.
  • Self-hosted outbound calls: Confirm that the NIM container does not send prompt content to any external service during inference.
  • Logs on your side: Decide where your guardrail logs record the original prompt, since the message may contain personal data on either path.

Check the current NVIDIA documentation for the TopicControl model and its hosting terms before you finalize the data flow diagram.

Testing borderline requests before TopicControl blocks real users

Build the test set before enforcement is on, and split it into three groups: clearly allowed requests, clearly disallowed requests and borderline requests. The borderline group carries most of the risk. TopicControl makes its on-topic or off-topic call against the topic wording you write in config.yml, so failures that reach users usually sit near the edge of an allowed topic. For each allowed topic, include paraphrases that use different vocabulary, adjacent subjects that share terms with a disallowed topic, and multi-turn follow-ups, such as asking about the second plan after a product question. Confirm in the NVIDIA documentation whether the topic check sees earlier turns in the conversation. A follow-up that looks off-topic alone may be on-topic in context, and your cases should reflect the behavior that actually applies.

Record every case in a file kept in the same repository as your Colang and configuration files. Each row should hold the input, the preceding turns, the expected decision, the decision TopicControl returned, the bot response and the configuration revision that produced it. Record the model endpoint as well. Confirm that a hosted and a self-hosted NIM run the same model version before you compare their results, because a difference in the model can look like a difference in your wording. Tag each borderline row with the reason it is borderline, such as shared vocabulary or a follow-up. When a wording change lands, the rows that flipped show exactly which decisions moved, and the same file becomes the evidence for the review that follows.

Review false refusals with the business owners who know what the assistant is for, and with the engineers who wrote the rules. Show owners each allowed-set request that TopicControl refused and ask one question: should the assistant answer this? Where the answer is yes, change the allowed topic description to name that subject, then rerun the full set, since widening one topic often shifts borderline decisions in another. Where the answer is no, add the reason to the disallowed description. Agree on an acceptable number of false refusals with the owners before enforcement reaches users, and keep the sign-off in writing, tied to the test set and configuration revision it was based on.

Security and operational considerations for topic enforcement

Topic enforcement adds a model call, a configuration surface and a log trail to your assistant, and each one creates a decision for security and operations. The six concerns below cover where data goes, who holds credentials, who can change rules, what gets logged, how users work around rules and what to retest after upgrades.

Prompt and response exposure

TopicControl sends each user message to a model endpoint so the check can run, and any output rails you add send model responses there as well. Confirm whether that endpoint is hosted or self-hosted, and which network path the traffic takes. Ask the provider how long it keeps request data and who can see those payloads. Your security team needs these answers before it approves the data flow.

Credentials for NIM endpoints

Both hosted and self-hosted NIM endpoints need credentials, and the guardrails server must read them at startup. Keep keys in your secrets manager and pass them to the process through environment variables, keeping them out of config.yml and Colang files. Give each environment its own key, rotate on a schedule you can show an auditor, and confirm with NVIDIA which credential types your deployment model requires. A leaked key lets someone outside your team call the endpoint with your identity.

Config files and change control

The config.yml file, Python actions and Colang files decide what the assistant refuses, so anyone who can edit them can change enforcement. Keep these files in version control, require review for every topic rule change, and limit write access to the folder the guardrails server loads. Record which commit runs in each environment so an incident review can show which topic rules were active. Treat a topic rule edit as a release that passes the same test run as code.

Logging blocked requests safely

Blocked requests are your main evidence for tuning topic rules and for incident review, but the raw message can contain personal or confidential data. Log the rail that fired, the matched topic, a timestamp and a request identifier, and omit the full prompt text unless your policy permits it. Set a retention period for these logs and confirm who can read them. Review the NeMo Guardrails documentation for content capture settings before you turn them on.

NeMo Guardrails docs

Rephrasing around topic rules

Refused users often reword a request, switch languages or split a question across several turns. A topic rule is only as wide as its description and examples, so a reworded request can land on the allowed side. Build a set of paraphrases, translations and multi-turn attempts for each restricted topic, and log which ones pass. Use the misses to decide whether the topic definition, the examples or a second control needs work. Treat every passing rephrase as a defect to fix.

Retesting after each upgrade

Each library upgrade can change configuration handling, Colang behavior and Python APIs, so rerun the full topic test set before a new version handles production traffic. Confirm your runtime meets the Python requirement of 3.11, 3.12 or 3.13 before you start. Retest too whenever the TopicControl model or its serving endpoint changes. If you move from Colang 1.0 to 2.x, follow the migration guide and plan a manual review of every converted file.

Colang 2 migration guide

What buyers ask about cost, effort and doing TopicControl in-house

What drives the cost of a TopicControl implementation project?

The main cost driver is how many topics you must allow or block and how many borderline cases each topic generates. Outside help is paid for scoping the topic list, writing and reviewing the rule set, wiring the check into your NeMo Guardrails configuration, running the test set, and documenting the results. Costs rise when business owners dispute topic boundaries, when the assistant serves several languages or channels, or when the deployment must run in an air-gapped network where every component is yours to operate. Costs fall when policy owners have already written the allowed and disallowed topics. Ask for each phase to be itemized in the written scope, and mark which parts are one-time and which recur.

How long does it take to test a topic rule set?

The duration depends on how many topics the rule set covers, how many borderline requests you need to probe, and how many reviewers must sign off on the results. Ask a prospective partner to tie any timeline to a written test plan before agreeing a date. The test plan should cover on-topic examples, off-topic examples, near-miss requests that sit between two topics, adversarial phrasing, and a full retest after each rule change. Ask whether the test cases are handed over to your team, so you can rerun them when a topic changes.

What does the work need from our internal team?

The work needs decisions and access more than deep model expertise. Expect to provide:

  • Named policy owners who can decide which topics are allowed, disallowed and borderline.
  • Sample conversations from live users, cleared for use in testing under your data handling rules.
  • A test environment running Python 3.11, 3.12 or 3.13, which NeMo Guardrails 0.25.0 requires, plus a model endpoint and a hosting target.
  • A reviewer who can read Colang and configuration changes and approve them.

Confirm with your security team how test data and model traffic will be logged before work starts.

Can our internal team build and test TopicControl without outside help?

Yes, a team with Python and NeMo Guardrails experience can build it alone. The harder part is testing borderline cases independently of the people who wrote the rules, and keeping those rules current as the product changes. Decide before you start who writes the tests, who reviews them, and who approves a change to a topic. Outside help is most useful when that separation is hard to staff, or when an auditor will ask who tested the rules and how. Plan for ownership after handover as carefully as for the initial build.

What does a fixed-scope quote for topic control depend on?

A fixed-scope quote depends on the written scope: the number of topics, the models and deployment targets in scope, the languages and channels the assistant serves, the test cases and retest rounds included, and the deliverables such as configuration, test reports and runbooks. DeployOpen agrees scope, deliverables and timelines in writing before work starts and does not publish a price list, so a quote follows from that document. Ask for each deliverable to carry an acceptance check, and for exclusions to be written down, such as changes to your model hosting or to upstream applications. Changes to topics after sign-off should go through a separate change order.

Is there recurring work after TopicControl goes live?

Yes. Topic rules need upkeep after the first release because products change, new topics appear, and models are updated. Recurring work includes rerunning the test set after each rule or model change, reviewing blocked and missed requests from logs, keeping NeMo Guardrails on a supported version, and handling upgrades. NeMo Guardrails 0.25.0 deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0, so a version change can touch the code that calls the library. Ongoing support, upgrades and continuous testing are available as retainers from DeployOpen, and you can decide whether to run them yourself.

Should TopicControl run as a hosted or self-hosted NIM?

Choosing between a hosted and a self-hosted NIM is a cost, data and control decision, so settle it before you size the budget. A hosted endpoint moves hosting work to the provider but sends prompts outside your network, which may conflict with your data handling rules. A self-hosted NIM keeps traffic in infrastructure you control, but adds GPU capacity, container operations and patching to your costs. Ask NVIDIA for the current licensing and access terms for each option. The NeMo Guardrails library itself is licensed under Apache 2.0, and that license does not cover the model or NIM terms.

Is the NeMo Guardrails microservice still available for new projects?

No. NVIDIA has sunset the NeMo microservices, and its NGC catalog page says the Guardrails container has been sunset as of October 1, 2026, with no new releases and no continued support. Plan new projects around the open-source library instead, which NVIDIA still publishes. The current release is 0.25.0, published on 19 November 2026. If you already run the microservice, ask your NVIDIA account team about next steps, since NVIDIA's archived documentation asks existing users to do so. Include the migration off the microservice in your planning before any license or support discussion.

Limits to confirm in your environment before enforcing topic rules

Each item below can change whether a topic rule behaves the way your tests showed, or whether it can be deployed at all. Check them in your own environment, against the versions you plan to run, before you write enforcement rules. Confirm each answer with the owning source named on the card.

Model and NIM versions

Pin the release, model and NIM version together, then record all three in your change log. The current NeMo Guardrails release is 0.25.0, but that number says nothing about which TopicControl model and NIM pairing it was tested with. Check the model card and NIM documentation for the TopicControl model, and confirm that the exact combination you test is the one you deploy.

NeMo Guardrails docs

Microservice sunset and containers

NVIDIA has sunset the NeMo Guardrails microservice as of October 1, 2026, and it will receive no new releases. If your deployment pulls the microservice container from the NGC catalog, treat that image as unsupported and plan a move to the library or to a guardrails server you build and maintain yourself. NVIDIA's archived notice says all new development has moved to NeMo Platform and asks existing users to contact their account team, so ask in writing what applies to your agreement before you build on that path.

Sunset notice

Python version requirements

NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13. Check the interpreter in your base image, your build pipeline and any shared virtual environments, since an older default on a host can fail installation or run a build your tests never covered. Pin the interpreter version in the Dockerfile or environment definition, run your topic tests on that exact version before promoting a configuration, and ask your platform team which interpreter versions are approved for regulated workloads.

PyPI project page

Colang version and the rail

Colang 1.0 is the default and Colang 2.0 is also supported, so the version you choose changes how topic flows are written and how the rail executes. Decide the Colang version before writing on-topic and off-topic flows. Converting later with the nemoguardrails convert tool is possible, but NVIDIA says converted configurations still need manual review, so budget review time for every flow you migrate. Confirm that the inference path you plan to use accepts the version you chose.

Colang 2 migration guide

Language coverage and multi-turn

Whether the TopicControl model handles your languages and follow-up turns is a property you must measure before enforcement. Test each language and follow-up turn with a set that includes every language your users write in, plus borderline requests that depend on earlier turns, such as a short follow-up that is only on topic as a continuation of an allowed conversation. Ask the model provider for documented language coverage and any multi-turn evaluation results, and record every failing case before you set the rule to enforce.

Hardware and endpoint capacity

Self-hosted NIM needs accelerator memory and throughput sized for your traffic, and the check runs on every user turn, so it adds load in front of your main model. Confirm the minimum accelerator, driver and memory requirements for the TopicControl NIM in NVIDIA's documentation. Then load test at your expected concurrency, measure the added latency, and confirm how the endpoint scales and fails over, because a topic check that stalls blocks the whole assistant.

How DeployOpen scopes, delivers and supports TopicControl rules

DeployOpen plans and implements topic restrictions with NemoGuard TopicControl inside infrastructure you control, under a written scope agreed before work starts. Every stage, from drafting on-topic and off-topic rules to delivery, produces documented and testable artifacts that your security, platform and compliance teams can review and run after handover.

How we scope

  • The written scope names the applications, assistants and conversation paths that TopicControl rules will govern.
  • It lists allowed and disallowed topics, borderline categories to test, and the deployment path for the model.
  • Engagements are fixed-scope, and ongoing support, upgrades and continuous testing are available as retainers.

How we build

  • Rules are written as on-topic and off-topic descriptions, then mapped to the TopicControl model's contract for each assistant.
  • Borderline requests are tested before enforcement is switched on, and the results are documented for review.
  • The model's hosting choice, hosted or self-hosted NIM, is confirmed in writing with your team before build starts.

How we hand over

  • Deliverables include the rule files, test cases for borderline requests and a record of the test results.
  • Your engineers receive documentation covering how each rule was written, tested and changed.
  • Configuration is deployed in infrastructure you control, with the runbook for updating rules and retesting them.

How we support

  • Changes to rules after handover follow the same cycle: edit, retest borderline requests, then redeploy.
  • Retainers cover ongoing support, upgrades of the NeMo Guardrails version in use, and continuous testing.
  • Confirm which NeMo Guardrails release your environment will run, since 0.25.0 requires Python 3.11, 3.12 or 3.13.

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.