LLM Guard Ban Topics scanner explained

Ban Topics restricts prompts and responses by subject using zero-shot classifiers. This page explains how it decides a match, how topic wording affects accuracy, what the model adds to latency, and what to confirm before relying on it in an archived deployment.

On this page

What the LLM Guard Ban Topics scanner does and when teams still need it

If your LLM Guard deployment must keep blocking subjects such as religion or violence, the Ban Topics scanner is the input control doing that work, and it matters more now because the project is archived. The protectai/llm-guard repository was archived by its owner on 9 July 2026, and the README states that the project and its Hugging Face models are no longer under active development or maintained. DeployOpen does not recommend new LLM Guard rollouts. Keep Ban Topics running only to support an existing deployment until a maintained replacement covers the same subjects.

Ban Topics is an input scanner. It screens user prompts before they reach the model and restricts the topics you list. It does this with zero-shot classifiers drawn from the MoritzLaurer collection on Hugging Face, so the scanner does not depend on a fixed keyword list or a trained category set. Each configured topic is treated as a label the classifier scores prompts against. Before changing anything, inventory which topics are banned in your scanners configuration, which model each one loads, and whether your policy owners can name the exact subjects in writing. That inventory becomes the baseline for any replacement test.

Plan the replacement on the assumption that the classifier models will not be updated. Confirm with your security and policy owners which banned topics are legal, contractual or brand requirements and which are preferences, because the replacement must block at least the required ones. Record the Python version and model cache your deployment uses, since LLM Guard 0.3.16 on PyPI requires Python 3.10 or newer but below 3.13. Then test the current Ban Topics behavior against a fixed set of prompts that you agree are in scope, and keep the results as the acceptance baseline for the migration.

How a prompt moves through the Ban Topics classifier

The diagram starts at the client application, which sends the user prompt to the LLM Guard service, either as a Python call or through the API server. Inside the scanner chain, the Ban Topics scanner runs a zero-shot classifier from the MoritzLaurer collection on Hugging Face against the topic labels you configured, and the result either passes the prompt on or blocks it. Only passing prompts reach the model. Check where the model is loaded, since that memory and startup cost sits in the LLM Guard process, and confirm the order of the other input scanners in your chain.

Ban Topics runs inside the input chain, and only passing prompts reach the model.

Ban Topics options and when each fits

This table compares the configuration choices a team controls in the Ban Topics scanner, from the topic list to the model and threshold. Read each row as a decision: when the option fits and what to test before changing it. Because the project is archived, any change should be validated against the deployed configuration before it reaches users.

OptionWhen it fitsWhat to test before changing it
Topic listBlocking a short, well-defined set of subjects your policy names explicitly, such as religion or violence.Run a sample of prompts that should pass and prompts that should be blocked, and record which topics fire on each.
Topic wordingAdjusting labels when a topic fires on neutral text or misses clearly off-policy text.Compare results for the same prompts across two or three phrasings, since the docs recommend experimenting with wording.
Topic descriptionUsing a longer, more specific description when a short label is too broad for the subject you mean to block.Check whether the longer description reduces false positives without losing blocks on your test set.
Zero-shot modelKeeping the default model from the MoritzLaurer collection on Hugging Face unless your tests show a clear gap.Confirm which model is loaded, its license terms and whether it is available in your air-gapped or restricted environment.
Match thresholdTightening or loosening the cutoff when your test results show a consistent bias toward false blocks or misses.Measure the block rate and missed-block rate at each threshold you try, and document the chosen value and its reason.
Prompts onlySuitable when your main concern is users steering the model toward banned subjects in what they send.Confirm that off-topic model responses are acceptable to your policy, since this option does not check output.
Prompts with output scannersSuitable when a subject must also be blocked in model responses, alongside output scanners such as Toxicity or Sensitive.Test the combined pipeline end to end, because a prompt that passes can still produce a response that needs blocking.
Latency budgetAccepting the extra time the classification model adds when topic blocking is a hard requirement.Measure added latency on hardware matching your production sizing, and confirm the result meets your user-facing targets.

How zero-shot classification decides that a prompt matches a banned topic

Zero-shot classification scores a prompt against candidate labels without training on those labels. In LLM Guard's Ban Topics scanner, each banned topic you configure becomes a candidate label, and the classifier estimates how well the incoming prompt fits each one. The model was not trained on your list of subjects. It relies on what it learned from general language, so a topic such as religion or violence can be flagged even though no one fine-tuned the model on examples of those subjects. In practice, the scanner compares the prompt with each banned topic description and returns a score per topic. Your team does not write rules or collect labeled examples to make this work, but it does depend on how the classifier interprets the wording you choose.

Because the match comes from a language model, it is a probabilistic judgment, not a lookup. A prompt that mentions a banned subject in passing may score high, and a prompt that circles the same subject with different vocabulary may score low. The scanner applies a threshold to the score, so changing that threshold changes which prompts are blocked. The LLM Guard documentation for Ban Topics recommends experimenting with topic wording and choosing longer topic descriptions, which signals that the label text itself is a tuning input. Ask for a written test set covering paraphrases, borderline wording and benign prompts that share vocabulary with each banned topic, and record the scores before you accept the configuration.

Treat every score as a hypothesis to test, not a guarantee. Run the scanner against prompts that should be blocked, prompts that should pass and prompts that sit near the threshold, then check whether the decisions match your policy. Repeat the test when you change a topic description, the threshold, or the model that LLM Guard loads, because each of these alters the outcome. Confirm with the project documentation which model version your installed release loads and whether that model can still be obtained, since the LLM Guard project is archived and its models are no longer maintained. Your test results and their date are the evidence you will need in a security review, and they also show whether the scanner still matches your policy when the topic list changes.

Topic wording choices that change Ban Topics accuracy

Ban Topics classifies each prompt or output against the topic labels you write, so the wording is part of the control. The LLM Guard docs recommend experimenting with topic wording and choosing longer topic descriptions, and each card below is a decision you can test against your own traffic before it reaches production.

Short labels versus longer descriptions

A bare label such as religion gives the zero-shot classifier very little context about what belongs in the category. The LLM Guard docs recommend longer topic descriptions for this reason. Test a one-word label against a full sentence that states what is in scope and what is out, using a set of prompts you already know should match and should not match. Record both results before you choose.

Ban Topics docs

Single words versus phrases

A single word such as violence matches many unrelated uses, while a phrase such as graphic descriptions of physical harm narrows the intent. Phrases generally give the classifier a clearer target, but they can miss the everyday wording your users actually type. Build a small sample of real and synthetic prompts for each candidate form and compare misses and false positives side by side.

Synonyms and related terms

Users rarely write the category name. A topic written as weapons may need coverage for firearms, explosives or ammunition wording, and the classifier may not infer those links on its own. Add the related terms to the description and then test prompts that avoid the headline word. If recall improves without a jump in false positives, keep the expanded description.

Overlapping topics

When two banned topics share vocabulary, such as medical advice and drug use, one prompt can score as both and the outcome depends on the order and threshold you set. Decide which topic owns each borderline case and write the descriptions so their scopes do not overlap. Check that a prompt about one topic does not trigger the other by accident.

Neutral versus loaded phrasing

A description that uses charged language, such as extremist propaganda, can flag discussion, reporting or education that a policy intends to allow. Neutral phrasing describes the subject without judging the user. Write the topic in plain descriptive terms, then test with prompts that discuss the subject critically, historically or for safety reasons to see whether the scanner blocks them.

Versioning topic wording

Wording changes alter what the scanner blocks, so every edit to a topic list is a control change. Keep the prompt set and the expected outcome for each topic under version control, rerun it after each edit, and record which wording version was live during an incident review. Confirm with your change process how approvals and rollbacks should work for this scanner.

What the classifier adds to latency in the request path

Ban Topics runs a transformer classification model on every input it scans, so each prompt pays model inference time before it reaches the LLM. The cost is added to the request path, not run in the background, which means users wait for the scanner's verdict before the model is called. Your latency budget should therefore treat the scanner as a serial step, and the figure that matters is the end-to-end time of the scan under your real traffic, not the time of a single isolated call on a developer laptop.

Several factors drive that cost, and you control most of them. Model size and hardware placement matter most: a zero-shot classifier running on CPU behaves very differently from one placed on a GPU, and the choice of model from the zero-shot collection published by MoritzLaurer on Hugging Face changes both memory and compute needs. Concurrency and prompt length also push time up, because longer inputs take longer to classify and parallel requests compete for the same cores or accelerator memory. The number of topics checked adds to the work as well, since each configured topic is part of the classification the scanner performs. Confirm the model you load and the topic list you ship in your own configuration before you estimate anything.

Do not plan capacity from a published figure or a vendor claim. Measure latency on your own hardware, with your own model, your typical prompt lengths, your topic list and your expected concurrency, and record the p50 and tail percentiles separately, because tail latency is what users notice under load. Run the same test with the scanner disabled to isolate its share of the total. Ask your platform or hosting team to confirm the instance type, accelerator availability and memory limits you will run in, since those settings decide whether the measured numbers will hold in production.

Set up Ban Topics and test topic wording against your own prompts

This sequence gets Ban Topics running in a controlled environment and measures whether your topic wording blocks the prompts you intend to block without catching prompts you need to allow. The result is a tested configuration with recorded latency that your team can review before any decision to keep or replace the scanner.

  1. Confirm the Python version for the pinned release

    The engineer responsible for the deployment checks the interpreter that will run the scanner against the requirements of the last LLM Guard release on PyPI, 0.3.16, which requires Python 3.10 or newer but below 3.13. Create a virtual environment with that interpreter and record its version in the change ticket. Done when python --version inside the environment reports a supported version and the record is filed.

  2. Install LLM Guard into a pinned environment

    Install the library with pip, pinned to version 0.3.16 so that results can be repeated later, and record the full dependency list with pip freeze. Keep this environment separate from production services so that model downloads and package changes do not affect live traffic. Done when the import of the Ban Topics scanner succeeds and the frozen dependency file is stored with the test records.

  3. Load the zero-shot model with network or cache access

    Ban Topics uses zero-shot classifiers from the MoritzLaurer collection on Hugging Face, so the first run needs either outbound access to Hugging Face or a model cache copied in from an approved source. Have the platform team confirm which path your network policy allows, then instantiate the scanner once and time the load. Done when the scanner initializes without errors in an offline run from the cache, and the load time is written down for later comparison.

  4. Configure banned topics and the threshold

    Write the banned topic list in the form your policy owner approved, and set the scanner threshold to the value your team has chosen and documented. The LLM Guard Ban Topics documentation recommends experimenting with topic wording and choosing longer topic descriptions, so keep each topic as a short descriptive phrase rather than a single keyword. Done when the configuration file is committed to version control and a reviewer has signed off on each topic label.

  5. Build a labeled test set of allowed and blocked prompts

    Collect prompts from your own product logs or from the people who will use the application, then label each one as allowed or blocked according to the policy. Include near-miss prompts that mention a topic in passing, since these show whether the wording is too broad. Illustrative example: a prompt asking for a history of a religious festival should be allowed, while a prompt asking for ways to recruit people to violence should be blocked. Done when the labeled set is stored with a version number and each label has a named owner.

  6. Run the test set and measure the pass rate

    Run every labeled prompt through the scanner with the current configuration and record the result for each one. Calculate the share of allowed prompts that pass and the share of blocked prompts that are caught, reporting the two rates separately so that false positives and misses are visible. Done when the run produces a results file with both rates and the average scan time per prompt, recorded alongside the configuration version.

  7. Adjust topic wording and rerun the tests

    Change the topic descriptions or the threshold based on the misses and false positives from the previous run, then repeat the full test set rather than only the failing prompts. Keep each change in a separate commit so that the effect of each wording change can be traced. Done when the rerun results are recorded for every configuration tried and the chosen version has the best combined result that your policy owner accepts.

  8. Record latency and file the results

    Measure the time to load the model and the per-prompt scan latency under a load that resembles production, then compare those numbers against the response budget of the application. Store the configuration, test set version, pass rates and latency figures together so the decision can be reviewed later. Done when the record is filed, the latency is confirmed against the application budget, and the team has noted the model dependency for the migration plan.

Security and operational risks of Ban Topics in production

Ban Topics blocks subjects with a classifier, so its risks come from how well a model judges meaning, how the model and topic list are managed, and what the scanner records along the way. The cards below cover the risks a security or platform team should review before a Ban Topics deployment stays in service, even though the project itself is archived.

Missed subjects through false negatives

A zero-shot classifier can miss a prompt that covers a blocked subject in indirect words, another language or a quoted fragment. Ban Topics only blocks what its topic labels and threshold catch, so a blocked subject can pass without any error being raised. Test the scanner with paraphrases, translations and multi-sentence prompts that match each banned topic, and record the miss rate before relying on it as a control.

Ban Topics docs

Legitimate users blocked by false positives

A broad topic label such as a sensitive domain can flag ordinary questions that mention the same vocabulary, such as a history class asking about a religious holiday or a support agent asking about threats in a security ticket. Each false positive blocks a real user and generates support load. Review blocked requests from a sample of normal traffic and tune wording before widening enforcement.

Model download and integrity

Ban Topics loads zero-shot classifiers from the MoritzLaurer collection on Hugging Face. The model is fetched at runtime or during image build, so the artifact you run may not be the one you tested. Pin the exact model revision, store the files in an internal registry or mirror with checksums, and confirm the license of each model before it enters a production image.

Blocked prompts in logs

When Ban Topics rejects a prompt, the blocked text often contains the sensitive material the user was trying to send, such as personal details, internal project names or hostile content. Decide whether the API server and application logs keep the raw prompt, the score or neither. Apply the same retention and access controls you use for other user content, and confirm how your deployment logs scanner results.

Change control for topic lists

The banned topic list and its wording directly decide what the application refuses, so a casual edit can silently widen or narrow enforcement. Treat the topic list as configuration under version control, with a named owner, a reviewed change record and a test set that runs on every change. Documentation recommends experimenting with wording, which makes an unreviewed edit more likely unless you gate it.

Archived model without security updates

The LLM Guard project was archived on 9 July 2026, and its README states that the project and its Hugging Face models are no longer maintained. Ban Topics will not receive fixes for new bypass techniques, dependency issues or model weaknesses. Record the archive as a standing risk in your register, keep the scanner contained behind other controls, and plan a move to a maintained guardrail.

LLM Guard on GitHub

Questions teams ask before running or replacing Ban Topics

What does it cost to keep running the Ban Topics scanner?

Running Ban Topics has no license fee, since LLM Guard is MIT licensed, but the cost sits in your own infrastructure and staff time. The scanner loads a zero-shot classification model, so you pay for compute to host it, for the engineers who keep the Python environment working, and for the time spent maintaining topic lists. Because the project is archived and its models are no longer maintained, expect those costs to rise over time as dependencies age. Ask any partner for a quote built from a written scope that separates one-time migration work from recurring hosting, patching and review effort.

How long does testing a Ban Topics replacement take?

The duration depends on how many topics you block, how many test prompts you have, and how many approved and disallowed cases need review. Testing has to show that the replacement blocks at least what Ban Topics blocked, and that it does not block legitimate traffic about the same subjects. Teams with a small, stable topic list and an existing labeled test set usually finish faster than teams with broad topic coverage and no baseline. Confirm the timeline in writing against your own topic inventory before work starts.

What does the team need to supply for a Ban Topics assessment?

You need a labeled set of prompts that should be blocked and prompts that should pass, the list of banned topics with an owner for each, and a host that can run the scanner. Hardware matters because the classifier runs on each request, so GPU or CPU capacity should be sized from measured latency. You also need a Python environment that matches the supported range in the LLM Guard release, which requires Python 3.10 or newer but below 3.13. Name a person who can approve topic wording changes, because those decisions affect what users can ask.

Can our own team tune the topic wording without a partner?

Yes, a team can experiment with topic wording because the LLM Guard documentation recommends trying different phrasings and longer topic descriptions. The risk is in measuring the result. Each wording change can shift which prompts are caught, so changes should run against the same labeled test set and be compared with a record of earlier results. Without that discipline, a team can tighten one topic and quietly break another. Keep wording changes under version control so an approver can see what changed and why.

How does Ban Topics work alongside the other input scanners?

Ban Topics classifies whether a prompt falls into a subject you have restricted, which is a different check from the others. Anonymize handles personal data, Secrets handles credentials, Prompt Injection looks for attempts to override instructions, and Toxicity scores abusive language. A prompt can pass one scanner and fail another, so the scanners should be ordered and their results logged together. Review how the chain behaves on combined inputs, because a topic-based block may overlap with an injection or toxicity block and make the audit trail harder to read.

What engineering risks come with keeping Ban Topics in production?

The main risks are a model that no longer receives fixes, dependency drift in the Python stack, and classifier results that change when topic wording changes. Because the project and its models on Hugging Face are no longer maintained, a security or compatibility problem found later may have no upstream fix. Check the scanner's latency under realistic load, monitor false positives reported by users, and record which model version and topic list each request was evaluated against. Plan the decommission path while the deployment is still stable.

Should we replace Ban Topics now or keep it for a while?

For new deployments, replacement is the better choice, because LLM Guard is archived and no new rollouts are recommended. For existing deployments, the decision depends on how stable the setup is, how much topic logic you have built, and how exposed the application is. Keeping it temporarily is reasonable when you isolate it, pin versions and plan a migration. Start by inventorying your topic list and test cases, since those define what a maintained replacement such as NeMo Guardrails must match before you retire the scanner.

Limits to confirm before relying on Ban Topics

Ban Topics depends on a zero-shot classifier whose behavior shifts with language, domain and the exact model version you run. Each card below names one limit to confirm in your environment and the person who can answer it, before the scanner is allowed to block user traffic.

Accuracy in your languages and domains

Zero-shot classification judges a prompt against the topic labels you write, so results depend on the languages your users write in and the vocabulary of your domain. Build a labeled test set from real, anonymized traffic that covers each banned topic, including borderline phrasing and non-English prompts. Ask your data science or ML team to measure false positives and false negatives per topic before the scanner is enforced.

Behavior of the pinned model version

Ban Topics loads models from the MoritzLaurer collection on Hugging Face, and a model's behavior can change when its files change. Pin the exact model revision in your deployment, record its hash, and rerun your test set whenever it changes. Confirm with the platform owner that the pin is enforced in the image or cache, not just in documentation.

License for your use

Model licenses on Hugging Face are set by each model's publisher and can differ from the LLM Guard package license. For each classifier in the collection you use, read the license card and confirm with your legal or procurement team that commercial use, internal use and any redistribution inside your product are permitted. Keep a record of the license version you reviewed.

Offline operation of model files

If the scanner runs in an air-gapped or restricted network, the model files must be copied into your own artifact store ahead of time, because the scanner should not depend on live downloads at request time. Ask your platform team to confirm that the cache location is populated, that the service starts with outbound network access blocked, and that file integrity is checked on deployment.

Interaction with other scanners

Ban Topics runs alongside scanners such as Prompt Injection, Toxicity and Anonymize, and the order and combined decisions shape what users see. Test the full input chain together, not the scanner alone, to catch cases where one scanner blocks a prompt another would have redacted. Confirm with the application team which result takes precedence and how blocked requests are logged.

Archived upstream project

The LLM Guard repository was archived by its owner, and the project and its models are no longer maintained. Confirm with your security owner that no security fixes or model updates will arrive, and set a review date for replacing Ban Topics with a maintained guardrail. Treat any model issue you find as one you must fix yourself, or as a reason to move this control to a supported alternative.

LLM Guard repository

How DeployOpen scopes and supports LLM Guard replacement and support

DeployOpen works on the Ban Topics scanner as part of a wider LLM Guard replacement or support engagement, because the scanner's topic rules depend on the deployment around it. We scope the written work, build and test the replacement or stabilization in your infrastructure, and hand over the configuration and evidence your team needs.

How we scope

  • Inventory every place Ban Topics runs, including the topic list, threshold settings and the calling application.
  • Record which blocked topics must stay blocked and which business use cases must keep working.
  • Agree deliverables, timelines and exclusions in writing before any build work starts, since engagements are fixed-scope.

How we build

  • Replace the zero-shot topic rules with a maintained guardrail or a documented alternative, chosen with your team.
  • Build a labeled test set of prompts for each topic and measure blocks and false positives before cutover.
  • Run the scanner's model loading and latency in your environment, so the cost of each request is measured, not assumed.

How we hand over

  • Document topic definitions, wording decisions, threshold settings and the rationale behind each one.
  • Deliver the test set, results and runbook so your engineers can rerun the checks after future changes.
  • Walk your security and platform teams through the configuration, decommission steps and open risks.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, agreed separately from the fixed-scope work.
  • Retesting after topic wording changes, model changes or application releases can be included in a retainer.
  • Confirm with DeployOpen which support tier, response expectations and change process apply before signing.

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.