This topic describes how to manage and configure libraries in the AI Guardrails console.
Library management
You can create libraries to customize moderation rules. Use these libraries to define risky keywords or keywords to exclude from text detection. Then, you can configure rules to detect the keywords in your libraries.
Log on to the AI Guardrails console.
In the navigation pane on the left, choose and follow these steps to configure a library.
On the Library Management tab, click Create Library.
In the Create Library panel, enter the required information for the library.
1. You can combine multiple keywords using logical operators. For example, `WeChat&part-time` is matched only when both keywords appear. The `&` operator represents AND, and the `~` operator represents NOT (exclude). The `&` operator must be used before the `~` operator.
2. Separate each keyword with a line break. Each keyword can be up to 50 characters in length.
3. A library can contain a maximum of 1,000 lines. To add more than 1,000 lines at a time, you can import them from a file.
4. Each account can have a maximum of 20 libraries and a total of 100,000 keywords.
Click the OK button.
If library creation fails, a detailed message is displayed. You can follow the instructions in the message to try again.
Library configuration
On the page, select the target service. In the ActionsOperation column, click Set keyword librarySet Thesaurus.
Select the Keyword blacklist tab or the Keyword whitelist tab to configure the library.
Keyword Blacklist: To add a library, click the Add keyword library button. To remove a library, click the Remove button.
Library Whitelist: To add a library, click the Add Library button. To remove a library, click the Remove From Whitelist button.
Library Blacklist description
If a keyword from a blacklist library is found in the text, the Text Moderation API returns
C_customizedin thelabelsparameter. This value indicates that a keyword from your custom library was matched. You can use this feature to detect specific violations in your text.For example, you add Small Loans and Door-to-door Service to a blacklist library. If the text submitted for moderation is Our School Offers Small Loans, Safe, Fast, Convenient, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service, the keywords Small Loans and Door-to-door Service are detected during risk analysis. When you call the Text Moderation API, the
labelsparameter returnsC_customizedand any other labels for built-in rules that were triggered.Library Whitelist description
If a keyword from a whitelist library is found in the text, the keyword is ignored during moderation. This feature helps prevent false positives by ensuring that specific keywords are not flagged.
For example, you add Convenient and Fast to a whitelist library. If the text submitted for moderation is Our School Offers Small Loans, Safe, Fast, Convenient, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service, the words Convenient and Fast are ignored. Only the remaining text, Our School Offers Small Loans, Safe, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service, is checked for risks.
After you add or remove libraries from the Keyword blacklist or Keyword whitelist, click OK to save the configuration for the service rule.