How to use AI Guardrails in Alibaba Cloud Model Studio
This topic describes how to integrate AI Guardrails in Alibaba Cloud Model Studio to add content moderation for the input and output of large language models (LLMs).
Model Studio now supports enabling AI Guardrails by workspace. New users must use this mode. The original Header mode no longer accepts new integrations, and existing users are not affected. To switch to the workspace mode, contact your account manager.
Prerequisites
Before you start, make sure that the following preparations are complete:
Activate AI Guardrails: Go to the AI Guardrails purchase page, create a service-linked role, and click Buy Now to activate the service.
Complete the SLR authorization: Log on to the Alibaba Cloud Model Studio console, choose Security Management in the left-side navigation pane, and follow the on-screen instructions to allow Model Studio to access AI Guardrails.
When you activate AI Guardrails, the system displays the Self-Built Security Mechanism Commitment Letter. Read and agree to it before you continue.
Billing
AI Guardrails is a paid service that uses pay-as-you-go billing. You are charged only for actual calls; no calls, no charges. For billing details, see Billing overview.
Integration guide
AI Guardrails supports different security policies for each Model Studio workspace.
Step 1: Enable AI Guardrails in a Model Studio workspace
Log on to the Alibaba Cloud Model Studio console. Make sure that the region is China (Beijing), and go to the target workspace.
In the workspace settings, find the AI Guardrails option.
Turn on Check Request and Check Response as needed. You can turn them on independently.
Model Studio enables AI Guardrails at the workspace level. After you enable it, all model calls in the workspace are automatically checked and use the default protection configuration. Model Studio currently supports only the China (Beijing) region.
Step 2 (optional): Create a custom configuration
AI Guardrails provides a default configuration (ID: bailian_default) for all workspaces in the Model Studio. Workspaces that are not associated with a custom configuration use this default configuration. To apply a different security policy to a specific workspace, create a custom configuration and associate it with that workspace.
Create a configuration
Log on to the AI Guardrails console, choose Overview in the left-side navigation pane, and make sure that the region in the upper part of the page is China (Shanghai).
In the Access Management panel, find the Model Studio icon and click + Create Configuration in the popup that appears on hover.
In the Create Configuration dialog box, specify the following information:
Parameter
Description
Configuration Name
A custom name that identifies the purpose of the configuration.
Model Studio Workspace
The Model Studio workspace (Workspace ID) to associate.
Check Request - Mapped Service
The service used for input moderation, such as
query_security_check_pro. You can click + Add Modality to add more modality mappings.Check Response - Mapped Service
The service used for output moderation, such as
response_security_check_pro. You can click + Add Modality to add more modality mappings.Click Save.
The China (Beijing) region of Model Studio corresponds to the China (Shanghai) region of AI Guardrails. Other regions are not supported.
Configuration rules
A workspace can be associated with only one custom configuration.
After a workspace is associated with a custom configuration, the protection policies of the workspace use the custom configuration and no longer use the default configuration.
Workspaces that are not associated with a custom configuration continue to use the default configuration (
bailian_default).You can modify the protection policies for each service, such as risk tag switches and check dimensions, on the Protection Configuration page in the AI Guardrails console. The procedure is unchanged.
Manage existing configurations
On the Overview page of the AI Guardrails console, click Access Management to view the integrated products and configurations. Click Edit for a configuration to modify its associated workspace and service mappings.
Edit a protection configuration
Except for some red-line control tags, you can turn risk tags on or off in the console. Example: the Model Studio input content security guardrail (query_security_check_pro).
Log on to the AI Guardrails console, and in the left-side navigation pane, choose Protection Configuration > Model Protection.
Find the target service and click Configure in the Actions column.
Select the target protection dimension and click Configuration Management. On the Configuration Management page, select the check types to adjust.
Click Edit to enter edit mode, change the Check Status of the target scenario configuration, and then click Save.
The configuration takes effect in about 2 to 5 minutes.