Content moderation in the decision engine

Updated at:

The Fraud Detection decision engine integrates Alibaba Cloud's Text Moderation 2.0

Background information

The decision engine integrates two common text moderation services from Content Moderation, with each service provided through four variables that correspond to the following return parameters: labels (labels), riskTips (subcategory labels), adNums (hit advertising numbers), and riskWords (hit risk words)(For more information, see Text Moderation 2.0 General Service API).

Service

Business scenarios

Description

Parameter

nickname_detection

User nicknames, official account names, and live stream titles.

Focuses on identifying baseline violations, brand impersonation, and prohibited marketing activities. It helps you manage fraudulent accounts.

Text Moderation_2.0_Nickname_Label

Text Moderation_2.0_Nickname_Subcategory Label

Text Moderation_2.0_Nickname_Hit Advertising Number

Text Moderation_2.0_Nickname_Hit Risk Words

comment_detection

Comments, live chat messages, public posts, and reposts.

This scenario often involves a high risk rate and diverse, evolving risk types. This service detects baseline violations, advertisements, traffic diversion, and other restricted content.

Text Moderation_2.0_Public Chat Comment_Label

Text Moderation_2.0_Public Chat Comment_Subcategory Label

Text Moderation_2.0_Public Chat Comment_Hit Advertising Number

Text Moderation_2.0_Public Chat Comment_Hit Risk Words

Use cases

You can configure Content Moderation variables in the decision engine to adjust the scope and details of risk detection to meet your business requirements. You can also convert the labels returned by the service into entity-level risk features (for entities such as accounts, devices, or IP addresses) to improve the accuracy and efficiency of your risk management.

Use case

Description

Pass Content Moderation results through the decision engine

If you are already integrated with the decision engine, you can perform content moderation directly without a separate integration with the Content Moderation API.

Convert text-level risks into entity-level risk features

You can aggregate text-level risks into features associated with an entity, such as an account, device, or IP address. This allows for more accurate and efficient risk handling.

For example, you can set a threshold for the number of ad-related messages sent by an account and apply a penalty when the threshold is exceeded.

Passthrough moderation results

If you have an active Fraud Detection subscription, you can call the two Content Moderation services through the API without any additional configuration.

  1. In the common parameters, set the service parameter to either nickname_detection or comment_detection.

  2. In the serviceParameter object, add the content field and pass the text that you want to moderate.

    The following code shows a sample request to moderate public chat comments:

    https://saf.cn-shanghai.aliyuncs.com/
        ?Format=JSON
        &Version=2020-07-06
        &Signature=vpEEL0zFHfxXYzSFV0n7%2FZiFL9o%3D
        &SignatureMethod=Hmac-SHA1
        &SignatureNonce=15215528852396
        &SignatureVersion=1.0
        &Action=ExecuteRequest
        &AccessKeyId=123****saf
        &Timestamp=2018-06-01T12:00:00Z
        &Service=comment_detection
        &ServiceParameters={"content":"add me for great deals"}
  3. The moderation results are returned in the extend field of the response. The structure of this field is identical to the response from the Content Moderation API.

    1. Label: labels.

    2. Subcategory label: riskTips.

    3. Hit advertising number: adNums.

    4. Hit risk words: riskWords.

    The following code shows a sample response:

    {
      "Message": "OK",
      "RequestId": "62383C45-5DC3-5A25-AD6C-3F7AB61FDE59",
      "Data": {
        "extend": "{\"riskTips\":\"ad_wechat_variant,ad_traffic_diversion\",\"adNums\":\"\",\"riskWords\":\"add contact,Add contact\",\"labels\":\"ad\"}"
      },
      "Code": 200
    }

Convert text-level risks to entity-level features

This example shows how to count the number of ad-related messages sent from the same account within a specific period. If the count reaches a threshold, such as 3, the system returns a high-risk tag.

  1. Log on to the Fraud Detection console.

  2. In the left-side navigation pane, click Event Management and then click New Event. Create a content moderation event and add a field for the content. In this example, the field is named content.

    image.png

  3. Configure the Content Moderation variable. Navigate to Variable Center > Variable Selection and click Add Associated Variable. Select the Content Moderation service. The system automatically adds the four variables associated with the selected service.

    1. Select variable: To use the public chat moderation service (comment_detection), select Content Moderation > Text Moderation > 2.0 > Public Chat Comment.

    2. Select event: Choose the event for this variable.

    3. Associate variable field: Map the field from your event to the variable's input field. In this example, map the content field.

    4. Click OK.

    image.png

  1. Navigate to Variable Center > Variable Management > Velocity Variable, and then click New Velocity Variable.

  2. Configure the Velocity Variable.

    1. Write event: Select the target event.

    2. Variable Type: Select Count.

    3. Variable Name: Enter a descriptive name. For this example, use Number of ad-related messages from account in last 1 day.

    4. Time Window: Select Last 1 day.

    5. Main object: Select Account ID.

    6. Cumulative object: Empty.

    7. Add Trigger Condition.

      1. Left variable: Select Text Moderation > 2.0 > Public Chat Comment > label.

      2. Operator: Select Contains.

      3. Right variable: Enter the label value to count. In this example, enter ad.

      image.png

  3. In the left-side navigation pane, click Scenario-specific Risk Control > Policy Management to create a policy. This example policy states: If the Number of ad-related messages from account in last 1 day is greater than or equal to 3, then output the high-risk tag highRisk_ad.

    image

    1. Left variable: In the custom variables section, select the Number of ad-related messages from account in last 1 day Velocity Variable that you created.

    2. Operator: Select Greater than or equal to.

    3. Right variable: Enter 3.

    4. Rules Expression: Enter 1.

    5. Tags: Enter highRisk_ad.

    6. Click Save, and then publish the policy to complete the configuration.

    7. Verify the policy.

      1. You can test the policy in OpenAPI Explorer.

      2. Sample request parameters:

        {
          "eventCode": "de_example",
          "accountId": "jack",
          "content": "add me for great deals"
        }
        Note

        Replace eventCode with the code of your configured event.

      3. Sample response:

        After you call the API three times with content that triggers the ad label, the policy is triggered and the tags field returns highRisk_ad.

        {
          "Message": "OK",
          "RequestId": "9AF58AD8-6816-59D8-AFC9-6602B52A242D",
          "Data": {
            "extend": "",
            "tags": "highRisk_ad"
          },
          "Code": 200
        }