Configure custom data masking and restoration

Updated at:

AI Guardrails provides custom data masking and masked data restoration for large model calls. Custom data masking masks content that matches your masking keyword libraries before it reaches the model, and masked data restoration restores the masked content in model responses. This topic describes how to enable and configure these two capabilities in the console.

Features

You can configure the following two capabilities in the AI Guardrails console:

  • Custom Data Masking (Public Preview): Associates custom masking keyword libraries to mask sensitive enterprise information in a targeted and precise way. Custom data masking is a check item under a protection dimension and appears only in the check item list of text detection services.

  • Masked Data Revert (masked data restoration): Provides independent restoration configuration for the system default masking rules (protection dimension: sensitive content) and for user-defined custom masking. Restoration is provided as two separate switches by the sensitive content and custom data masking protection dimensions. The two switches are independent and can be enabled in any combination.

Note

Custom data masking in this topic is an independent check item. It is different from the Masking action among the Observe, Mask, and Block actions of sensitive content detection: the latter is a result handling action applied after sensitive content is detected. For the difference, see the FAQ in Configure check items. This topic covers only the configuration of the custom data masking check item and masked data restoration.

Limits

The following limits apply to custom data masking and masked data restoration:

  • Supported services — Custom data masking is available only for the text detection services of Content Moderation, such as AI Input Content Safety Detection and AI Output Content Safety Detection. This check item does not appear in the check item lists of image, file, multi-modal, or audio and video detection services. Masked data restoration applies to the masking results of the same text detection services.

  • Masking keyword libraries — Only one masking keyword library can be configured at present. The limit will be lifted later.

  • Keyword input — Masking keyword libraries support batch text input only. Importing keywords from files is not supported. You can enter up to 1,000 lines, and each keyword can contain up to 50 characters. Special characters are not supported.

  • Effect delay — After you turn on the custom data masking switch, the service takes effect within about 5 minutes.

  • Restoration dependency — Masked data restoration depends on the request parameter desensitizeId. If this field is not passed in the request, restoration does not take effect.

Before you begin

  • Custom data masking is in Public Preview. During the public preview period, you can use it for free. No application is required. Turn on the switch in the console to start using it.

Choose your configuration path

Custom data masking and masked data restoration are independent capabilities. The restoration switches do not require custom data masking to be enabled.

  • To restore only the data masked by the system default masking rules, you do not need a masking keyword library. Skip Step 1 and Step 2, and configure only the restoration switch for the sensitive content dimension in Step 3.

  • To mask custom keywords, complete Step 1 and Step 2. To also restore the masked content, configure the restoration switch for the custom data masking dimension in Step 3.

Step 1: Create a masking keyword library

Custom data masking depends on a masking keyword library. If you have already created one, skip this step.

  1. Log on to the AI Guardrails console.

  2. In the left-side navigation pane, choose Knowledge Base Management > Masking Library Management.

  3. Click Create Library. In the panel that opens, configure the following parameters.

    ParameterRequiredDescription
    Library nameYesThe name of the masking keyword library. Maximum length: 64 characters.
    Keyword contentYesEnter keywords in batch text. Separate each keyword with a line break. Each keyword can contain up to 50 characters, with a maximum of 1,000 lines. Special characters are not supported. Masking keyword libraries support batch text input only. Importing keywords from files is not supported.
    PropertiesNo (recommended)Supports Chinese characters, English letters, and digits only, with a maximum length of 10 characters. The Properties field preserves the semantics of masked content. Enter a category for each keyword, such as company name or product name.
  4. After you complete the configuration, submit the form. The library then appears in the selection list of the custom data masking configuration panel.

At the top of the Masking Library Management page, the following notice is displayed: This library is used only for the custom data masking and masked data restoration features. Associate the masking keyword library in the custom data masking feature. Currently, only one masking keyword library is supported. The limit will be lifted later.

Routine management operations such as viewing, editing, and deleting libraries are the same as those in the library management component. For more information, see Library management.

Step 2: Enable custom data masking and associate a masking keyword library

  1. In the left-side navigation pane, click Protection Config.

  2. On the Model Protection tab, find the row of the text detection service that you want to configure (such as AI Input Content Safety Detection or AI Output Content Safety Detection), and click Configuration Management in the Actions column of the row to go to the check item configuration page.

  3. In the check item list, find the Custom Data Masking card. The card shows the In public preview badge. Turn on the switch on the card. The confirmation dialog states that the service is in public preview, that you are welcome to try it for free, and that the service takes effect within about 5 minutes after the switch is turned on. Confirm to enable it.

  4. On the Custom Data Masking card, click Configuration Management to open the custom data masking configuration panel.

  5. In the Masking Library section, select the masking keyword library that you want to associate.

    • The panel lists all masking keyword libraries as check boxes. Each row has a Manage link that takes you to the keywords of that library.

    • If you have not created a masking keyword library, the panel shows No masking library configured. Click Go to Create. The system opens the Masking Library Management page in a new window. Create a library by following Step 1 first.

  6. Click Save. After the page shows a save success message, the selected library and the custom data masking configuration take effect.

The top of the custom data masking configuration panel also contains an important notice: Masked data restoration depends on the request parameter desensitizeId. This field is the unique identifier for the masking and restoration operations in a single execution. AI Guardrails uses this identifier to build the mapping between masking and restoration. If the field is not passed in the request, restoration does not take effect.

Step 3: Configure masked data restoration

Masked data restoration does not have its own check item card. The restoration switches are embedded in two configuration panels, one for each protection dimension. Enable them independently as needed.

Important

In addition to the restoration switch, restoration requires the request parameter desensitizeId in your API requests. This field is the unique identifier for the masking and restoration operations in a single execution. If the field is not passed, restoration does not take effect.

The following table describes the two restoration switches.

Protection dimensionSwitch locationSave methodPurpose
Sensitive contentOn the right side of the Sensitive Content Detection configuration panel, next to the Fine-grained Scenario Configuration titleSaved immediately after the switch is toggledControls whether to restore data masked by the system default masking rules (sensitive content dimension)
Custom data maskingAt the bottom of the custom data masking configuration panelSubmitted together with the Save button of the panelControls whether to restore data masked by custom data masking

Choose the switch based on the source of your masked data:

  • To restore data masked by the system default masking rules, turn on the switch for the sensitive content dimension.

  • To restore data masked by your masking keyword library, turn on the switch for the custom data masking dimension.

  • If both sources produce masked data, turn on both switches.

The title of the restoration section is Enable Masking Revert. The tooltip next to it states that you can separately configure whether to restore masked data for the two protection dimensions, sensitive content and custom data masking, and that masked data restoration depends on the request parameter desensitizeId. If this field is not passed, restoration does not take effect.

To enable restoration for the sensitive content dimension

This procedure does not require Step 1 or Step 2. Use it directly if you only want to restore data masked by the system default masking rules.

  1. On the Protection Config > Model Protection page, go to the check item configuration page of the target detection service, and click Configuration Management on the Sensitive Content Detection card.

  2. On the right side of the configuration panel, next to the Fine-grained Scenario Configuration title, turn on the restoration switch. The change is saved immediately.

To enable restoration for the custom data masking dimension

  1. Open the custom data masking configuration panel as described in Step 2.

  2. In the restoration section at the bottom of the panel, turn on the switch.

  3. Click Save. The restoration switch takes effect together with this save.

The restoration switches of the two dimensions are independent and do not affect each other: Enabling restoration for one dimension does not change the restoration state of the other dimension.

FAQ

What is the difference between custom data masking and the Masking action of sensitive content detection?

Custom data masking is an independent check item under a protection dimension. It masks specified content in a targeted way based on the masking keyword library that you created. The Masking action of sensitive content detection is one of the result handling actions (alongside Observe and Block) and is performed by the system default masking rules. The two can work together: Restoration for the sensitive content dimension corresponds to the system default masking rules, and restoration for the custom data masking dimension corresponds to the masking results of your keyword library. For the differences between the handling actions, see Configure check items.

How long does it take for custom data masking to take effect after I enable it?

After you turn on the switch, the service takes effect within about 5 minutes.

Why does restoration not take effect after I configure it?

Masked data restoration depends on the request parameter desensitizeId. This field is the unique identifier for the masking and restoration operations in a single execution. If the field is not passed, restoration does not take effect. When you integrate by API, make sure that the request includes this parameter.

References

  • To integrate the masking and restoration capabilities into your business system by API (inbound masking, model invocation, and outbound restoration), see Use the masking and restoration API (in preparation).

  • For routine management operations such as viewing, editing, and deleting libraries, see Library management.

  • For the overall operations of the check item configuration page and descriptions of other check items, see Configure check items.