All Products
Search
Document Center

AI Guardrails:Custom text libraries

Last Updated:Mar 31, 2026

Content Moderation's built-in classifiers cover most moderation needs. When you need to screen for terms or text patterns specific to your business — such as domain-specific slang, brand-sensitive phrases, or industry jargon — custom text libraries let you extend those classifiers to return results that match your exact requirements.

Custom text libraries apply to text anti-spam, text violation detection in images, ad violation detection, file anti-spam, and audio anti-spam.

Library types

Content Moderation provides two types of custom text libraries:

TypeDescriptionManagement
Feedback-basedCreated automatically from content that goes through human review. Applies to all moderation scenarios of the same type by default. Named in the SCENARIO_FEEDBACK_WHITE or SCENARIO_FEEDBACK_BLACK format (for example, ANTISPAM_FEEDBACK_BLACK).Add or remove terms only. Cannot be disabled or deleted.
Self-managedLibraries you create for a specific scenario or scenario type. Maximum 10 libraries.Full control: create, edit, disable, and delete.

For details on human review, see Review machine-assisted moderation results.

Text types

Each library stores one of two text types:

Terms

Terms match content that contains a specific word or phrase. If moderated text contains the term, it is a hit.

In Content Moderation, keyword-based detection can be applied to ad violation detection and text anti-spam. The configuration details may vary slightly across scenarios.

Terms support Chinese characters and alphanumeric combinations. English words or phrases are not supported. Each combination of letters and digits is treated as a single word during word-breaking.

Logical operators for Chinese terms:

OperatorSyntaxHit condition
ANDA&BText contains both A and B
NOTA~BText contains A but not B

When combining both operators, AND (&) must appear before NOT (~). For example, A&B~C is valid; A~C&B is not.

Text patterns

Text patterns match content that is semantically similar to stored patterns, even if the wording differs. They apply to text anti-spam and support block lists, review lists, and trust lists.

For a text pattern to work, it must have clear Chinese semantic content. Patterns consisting mostly of meaningless letters, digits, or emoticons may be ignored by the system.

Limits

ItemLimit
Self-managed text librariesUp to 10
Library name lengthUp to 20 characters
Terms per libraryUp to 10,000
Term lengthUp to 50 characters, including logical operators
Term encodingUTF-8
Term formatThe following special characters are not supported (full-width and half-width): @, #, $, %, ^, *, (), <>, /, ?, ,, ., ;, _, +, -, =, ', ", spaces, and tabs
Text pattern length20–4,000 characters; 200 characters recommended for best accuracy
Text patterns per libraryUp to 10,000
Text pattern encodingUTF-8

Create a text library

Add terms carefully. Improper terms can reduce the accuracy of moderation results. You can create up to 10 self-managed text libraries.
  1. Log on to the Content Moderation console.

  2. In the left-side navigation pane, choose Machine audit V1.0 > Risk Libraries.

  3. Click Create Text Library.

  4. In the Create Custom Text Library dialog box, configure the following parameters, then click OK. After creating the library, it appears in the text library list.

    ParameterDescription
    NameA name for the library. Names do not have to be unique, but a unique name makes libraries easier to identify. Maximum 20 characters.
    Scene

    The moderation scenario: Text Anti-spam (for requests where scene contains antispam) or Ad (for requests where scene contains ad).

    • Text Anti-spam: Applies to text anti-spam where the scenes parameter in your API request contains antispam.

    TypeKeyword — matches text containing specific terms. Similar Text — matches text that is semantically similar to stored patterns. Similar Text is only available when Scene is set to Text Anti-spam.
    Match modeRequired when Type is Keyword. Precise matches the exact term. Check after Preprocess Texts preprocesses both the term and the content before matching — converting uppercase letters to lowercase, traditional Chinese characters to simplified, and similar words to a standard form. For example, "bitCoin" would hit the term "bitcoin". Text pattern libraries always use Check after Preprocess Texts by default.
    List categoryDetermines the suggestion value returned when a hit occurs. For Keyword libraries: Block list (returns block), Review List (returns review), or Filter List (excludes matching content from moderation). For Similar Text libraries: Block list (returns block), Review List (returns review), or Trust list (returns pass).
    bizType(Optional) Scopes the library to a specific business scenario. If a moderation request sets bizType to a value, only libraries with that same bizType value are applied (provided they are enabled). If no bizType is set in the request, all enabled libraries are applied.

Add and remove terms

The Custom Text Library tab lists all libraries. Libraries labeled System with names in the SCENARIO_FEEDBACK_WHITE or SCENARIO_FEEDBACK_BLACK format are feedback-based text libraries — for example, ANTISPAM_FEEDBACK_BLACK is the block list for text anti-spam.

  1. Find the library and click Manage in the Actions column.

  2. On the Text Libraries page, add or remove terms: The Detected in Last Seven Days column shows how many times each term was matched in the last seven days, not including the current day.

    Changes to terms take effect within about 15 minutes.
    ActionSteps
    Add a single termClick Add Keyword and follow the prompts.
    Add terms in bulkClick Import and upload your list.
    Delete selected termsSelect the terms, then click Batch Delete.
    Delete a single termFind the term and click Delete in the Actions column.

Edit, disable, or delete a text library

On the Custom Text Library tab, find the library and use the Actions column:

  • Click Edit to rename the library or change its settings.

  • Click Disable to stop the library from being applied during moderation.

  • Click Delete to permanently remove the library.

These actions are only available for self-managed text libraries. Feedback-based text libraries cannot be disabled or deleted.

What's next