AI data inference solution
Manual deployment
Solution overview
Integrate EventBridge with AI services to run intelligent inference on real-time event bus data, strengthening data processing and unlocking innovative applications.
Using EventBridge as a data hub, you can distribute real-time data streams from various sources to different AI models for inference. EventBridge then routes the inference results to downstream business systems or data stores. Adding AI inference to the ETL Transform step makes data transformation more intelligent, boosts processing efficiency and accuracy, and provides your business with powerful data integration and analysis.
Solution architecture
The following diagram shows the system that this solution deploys on Alibaba Cloud with the default settings. You can adjust some settings during actual deployment, but the overall system remains similar.
This tutorial uses sensitive information filtering as an example to demonstrate data cleaning and desensitization for downstream data. AI automatically identifies business-sensitive keywords to safeguard downstream business and data compliance.
The solution works as follows: an input containing sensitive information, such as ["Customer John Doe (+1-555-0100) reported an issue..."], is processed to produce a sanitized output, such as ["Customer *** (+1-***-0100) reported an issue..."]. Because large models can produce non-deterministic results, the output format may vary during testing. In production, you can use prompt engineering to obtain more deterministic outputs.
This solution uses the following cloud services and infrastructure:
Resource | Description |
1 event flow | Used to build a data pipeline. |
2 Lightweight Message Queue (formerly MNS) queues | Serve as the data source and sink. |
Alibaba Cloud Model Studio | Calls a large-model service to process data. |
Prerequisites
Before you deploy, follow these instructions to prepare your account.
Prepare your account
If you do not have an Alibaba Cloud account, register on the Alibaba Cloud account registration page. An Alibaba Cloud account is the billing entity for your cloud resources and a prerequisite for this deployment solution.
Top up your Alibaba Cloud account. This deployment solution uses the pay-as-you-go billing method by default. If you deploy any cloud resource using pay-as-you-go, your account balance must be at least 100 CNY.
Enable services
Log on to Model Studio. After you read and agree to the Terms of Service, Model Studio is automatically activated. If the Terms of Service do not appear, this indicates that you have already activated Model Studio.
When you activate Model Studio for the first time, the platform automatically grants you a free quota for new users for each model. For more information, see Free quota for new users.
NoteOnly models in the China (Beijing) region with the service deployment scope set to China (Mainland) are eligible for a free quota. Models in other regions or with different service scopes are not eligible.
If you are prompted that identity verification has not been completed when activating the service, first complete Individual identity verification.
If you are using ApsaraMQ for MNS for the first time, activate the service as follows.
Log in to the ApsaraMQ for MNS console.
On the Overview page, click Activate for Free and follow the on-screen instructions.
To activate EventBridge for the first time, follow these steps.
Log on to the EventBridge console.
On the Overview page, in the Activate EventBridge wizard, click Enable For Free and follow the on-screen instructions.
EventBridge requires authorization to receive events. On the Overview page, in the Access Authorization wizard, click Authorize Now.
Get an API key
Get a Model Studio API key
Go to the API Key page of Model Studio.
Click Create API Key. In the dialog box, confirm the Workspace, enter a Description, and select Permissions as needed.
NoteA RAM user requires authorization from the Alibaba Cloud account before creating an API key.
Do not expose your API key. Unauthorized use can cause security risks and financial losses.
Click OK.
After the API key is created, immediately copy or download the full API key from the result dialog box and store it securely.
The API key is displayed only once. After you close the dialog box, the list shows only a masked value and you cannot view or copy the full key again. If you did not save the key, reset it or create a new one.
Create the source and sink
Create two queues in Lightweight Message Queue (formerly MNS) to serve as the source and sink for the event flow.
Create MNS queues
Log on to the Lightweight Message Queue (formerly MNS) console.
In the left-side navigation pane, click Queues. From the Region drop-down list, select China (Shenzhen).
Click Create Queue, set Name to
eventbridge-dev, and leave the other parameters at their default values.Click Confirm and wait for the queue to be created.
Repeat the preceding steps to create another queue named
eventbridge-online.
If duplicate message consumption occurs, set the Visibility Timeout Period to a value between 60 seconds and 300 seconds.
Build the data processing pipeline
Create and configure an EventBridge event flow to act as the data processing pipeline.
Create event flow and configure source
Log on to the EventBridge console.
In the left-side navigation pane, click Event Streams. From the Region drop-down list, select China (Shenzhen).
Click Create Event Stream.
Enter a custom value for Task Name.
For Metering Method, select Pay-by-event.
On the Task Creation tab, in the Source area, configure the following settings:
For Data Provider, select Lightweight Message Queue (formerly MNS).
For Queue Name, select
eventbridge-dev. Leave the other settings as default.
Click Next Step.
Configure filtering
In the Filtering area, configure the following settings:
For Pattern Content, select All Events Match. In real business scenarios, you can also select other filtering rules, or select custom matching to define filtering rules flexibly.
Click Next Step.
Configure transformation
In the Transformation area, configure the following settings:
For Alibaba Cloud Service, select Model/Agent Call (Alibaba Cloud Model Studio). This tutorial uses Model Call as an example.
For Model Name, enter
qwen-max.Configure the Model Context as follows:
SYSTEM
Fixed Value
You are a data compliance officer. You must ensure that all data entering the analysis system complies with GDPR/CCPA regulations and does not contain any personally identifiable information (PII). During the ETL process, your task is to automatically identify and sanitize text containing names, phone numbers, and ID numbers. You must also block sensitive content related to religion, sexuality, and politics.
USER
Partial Event
$.data.messageBody
For Structured Output, select Enable, click Add Field, and then add fields as described in the following table:
data
string
The sanitized data content.
Required
cause
string
The reason the data was filtered. The value must be in English.
Optional
For API Key, enter the Model Studio API key that you obtained.
Click Next Step.
Configure sink
In the Sink area, configure the following settings:
For Service Type, select SMQ.
For Queue Name, select the created queue
eventbridge-online.For Message Body, select Partial Event, and enter
$.transform0.structuredoutput.
Click Save. Wait for the event flow to be created. The Status changes to Running.
Verify the solution
To verify the model's data sanitization, send a message containing sensitive information from the source queue and then check the processed message in the sink queue.
Send a message
Log on to the Lightweight Message Queue (formerly MNS) console. In the left-side navigation pane, click Queues.
Find the
eventbridge-devqueue, and click Send Messages in the Actions column.In the Send Message area, configure the following settings:
For Message Content, enter
Customer John Doe (+1-555-0100) reported an issue.Set Message Delay Period to
0 seconds.
Click Send Message.
Receive a message
Log on to the Lightweight Message Queue (formerly MNS) console. In the left-side navigation pane, click Queues.
Find the created queue
eventbridge-online, and click Send Messages in the Actions column.In the Receive Message area, click Receive Message.
The received message appears in the list. In the Actions column, click Details and view the Base64-decoded Message. A result similar to the one shown in the following figure indicates that the data has been processed.
Clean up resources
After you finish testing, delete the EventBridge event flow and the two Lightweight Message Queue (formerly MNS) queues to avoid additional charges:
Delete the EventBridge event flow: Log on to the EventBridge console. In the left-side navigation pane, click Event Streams. Find the event flow that you created, click Delete in the Actions column, and then follow the on-screen instructions.
Delete the message queues: Log on to the Lightweight Message Queue (formerly MNS) console. In the left-side navigation pane, click Queues. Find the queues that you created. In the Actions column, click the rightmost icon, click Delete, and then follow the on-screen instructions.
Free trial
Solution overview
Integrate EventBridge with AI services to run intelligent inference on real-time event bus data, strengthening data processing and unlocking innovative applications.
Using EventBridge as a data hub, you can distribute real-time data streams from various sources to different AI models for inference. EventBridge then routes the inference results to downstream business systems or data stores. Adding AI inference to the ETL Transform step makes data transformation more intelligent, boosts processing efficiency and accuracy, and provides your business with powerful data integration and analysis.
Solution architecture
The following diagram shows the system that this solution deploys on Alibaba Cloud with the default settings. You can adjust some settings during actual deployment, but the overall system remains similar.
This tutorial uses sensitive information filtering as an example to demonstrate data cleaning and desensitization for downstream data. AI automatically identifies business-sensitive keywords to safeguard downstream business and data compliance.
The solution works as follows: an input containing sensitive information, such as ["Customer John Doe (+1-555-0100) reported an issue..."], is processed to produce a sanitized output, such as ["Customer *** (+1-***-0100) reported an issue..."]. Because large models can produce non-deterministic results, the output format may vary during testing. In production, you can use prompt engineering to obtain more deterministic outputs.
This solution uses the following cloud services and infrastructure:
Resource | Description |
1 event flow | Used to build a data pipeline. |
2 Lightweight Message Queue (formerly MNS) queues | Serve as the data source and sink. |
Alibaba Cloud Model Studio | Calls a large-model service to process data. |
One-click deployment
Click the Try Now button on the right side of the page to start creating the resources. Deployment completes in a few minutes.
NoteIf the page indicates that your account has fewer trial points than the estimated amount required, you must obtain more trial points before you can try this solution. To get more trial points, go to Solution Center Free Trial.
After the deployment is complete, click Next on the RAM User Logon page in the browser pane on the right.
In the left-side pane, under , copy the Logon Password. Paste it into the Password field in the right-side browser pane, and then click Logon.
After you log on, on the Select MFA Type to Bind page, click Skip Binding in the upper-right corner.
After the deployment is complete, you can view information about all created cloud resources by clicking the Cloud Resources menu on the left side of the page.
During the trial, if your trial period is about to reach the maximum allowed for this solution, the system prompts you to renew. You can check the Remaining Duration in the upper-right corner of the page. You can also click Renew in the upper-right corner to extend the trial period. When the remaining time reaches zero, all created resources are released automatically.
In the following steps, if you need to access a cloud resource, copy the corresponding address from the Cloud Resources pane on the left and paste it into the browser pane on the right.
Enable services
Log on to Model Studio. After you read and agree to the Terms of Service, Model Studio is automatically activated. If the Terms of Service do not appear, this indicates that you have already activated Model Studio.
When you activate Model Studio for the first time, the platform automatically grants you a free quota for new users for each model. For more information, see Free quota for new users.
NoteOnly models in the China (Beijing) region with the service deployment scope set to China (Mainland) are eligible for a free quota. Models in other regions or with different service scopes are not eligible.
If you are prompted that identity verification has not been completed when activating the service, first complete Individual identity verification.
If you are using ApsaraMQ for MNS for the first time, activate the service as follows.
Log in to the ApsaraMQ for MNS console.
On the Overview page, click Activate for Free and follow the on-screen instructions.
To activate EventBridge for the first time, follow these steps.
Log on to the EventBridge console.
On the Overview page, in the Activate EventBridge wizard, click Enable For Free and follow the on-screen instructions.
EventBridge requires authorization to receive events. On the Overview page, in the Access Authorization wizard, click Authorize Now.
Get an API key
Get a Model Studio API key
Go to the API Key page of Model Studio.
Click Create API Key. In the dialog box, confirm the Workspace, enter a Description, and select Permissions as needed.
NoteA RAM user requires authorization from the Alibaba Cloud account before creating an API key.
Do not expose your API key. Unauthorized use can cause security risks and financial losses.
Click OK.
After the API key is created, immediately copy or download the full API key from the result dialog box and store it securely.
The API key is displayed only once. After you close the dialog box, the list shows only a masked value and you cannot view or copy the full key again. If you did not save the key, reset it or create a new one.
Create the source and sink
Create two queues in Lightweight Message Queue (formerly MNS) to serve as the source and sink for the event flow.
Create MNS queues
Log on to the Lightweight Message Queue (formerly MNS) console.
In the left-side navigation pane, click Queues. From the Region drop-down list, select China (Shenzhen).
Click Create Queue, set Name to
eventbridge-dev, and leave the other parameters at their default values.Click Confirm and wait for the queue to be created.
Repeat the preceding steps to create another queue named
eventbridge-online.
If duplicate message consumption occurs, set the Visibility Timeout Period to a value between 60 seconds and 300 seconds.
Build the data processing pipeline
Create and configure an EventBridge event flow to act as the data processing pipeline.
Create event flow and configure source
Log on to the EventBridge console.
In the left-side navigation pane, click Event Streams. From the Region drop-down list, select China (Shenzhen).
Click Create Event Stream.
Enter a custom value for Task Name.
For Metering Method, select Pay-by-event.
On the Task Creation tab, in the Source area, configure the following settings:
For Data Provider, select Lightweight Message Queue (formerly MNS).
For Queue Name, select
eventbridge-dev. Leave the other settings as default.
Click Next Step.
Configure filtering
In the Filtering area, configure the following settings:
For Pattern Content, select All Events Match. In real business scenarios, you can also select other filtering rules, or select custom matching to define filtering rules flexibly.
Click Next Step.
Configure transformation
In the Transformation area, configure the following settings:
For Alibaba Cloud Service, select Model/Agent Call (Alibaba Cloud Model Studio). This tutorial uses Model Call as an example.
For Model Name, enter
qwen-max.Configure the Model Context as follows:
SYSTEM
Fixed Value
You are a data compliance officer. You must ensure that all data entering the analysis system complies with GDPR/CCPA regulations and does not contain any personally identifiable information (PII). During the ETL process, your task is to automatically identify and sanitize text containing names, phone numbers, and ID numbers. You must also block sensitive content related to religion, sexuality, and politics.
USER
Partial Event
$.data.messageBody
For Structured Output, select Enable, click Add Field, and then add fields as described in the following table:
data
string
The sanitized data content.
Required
cause
string
The reason the data was filtered. The value must be in English.
Optional
For API Key, enter the Model Studio API key that you obtained.
Click Next Step.
Configure sink
In the Sink area, configure the following settings:
For Service Type, select SMQ.
For Queue Name, select the created queue
eventbridge-online.For Message Body, select Partial Event, and enter
$.transform0.structuredoutput.
Click Save. Wait for the event flow to be created. The Status changes to Running.
Verify the solution
To verify the model's data sanitization, send a message containing sensitive information from the source queue and then check the processed message in the sink queue.
Send a message
Log on to the Lightweight Message Queue (formerly MNS) console. In the left-side navigation pane, click Queues.
Find the
eventbridge-devqueue, and click Send Messages in the Actions column.In the Send Message area, configure the following settings:
For Message Content, enter
Customer John Doe (+1-555-0100) reported an issue.Set Message Delay Period to
0 seconds.
Click Send Message.
Receive a message
Log on to the Lightweight Message Queue (formerly MNS) console. In the left-side navigation pane, click Queues.
Find the created queue
eventbridge-online, and click Send Messages in the Actions column.In the Receive Message area, click Receive Message.
The received message appears in the list. In the Actions column, click Details and view the Base64-decoded Message. A result similar to the one shown in the following figure indicates that the data has been processed.
Clean up resources
Click
End Trial in the upper-right corner of the solution page, and then click OK in the confirmation dialog box to end the trial and release all resources.
After the solution trial ends, the system deletes the trial account and automatically releases all trial resources.