This tutorial demonstrates how to use the MaxCompute AI_GENERATE function to call a multimodal model deployed on PAI EAS, read unstructured data from a BLOB column, and process images directly with SQL. The workflow reads image data from OSS through an object table, writes it to a MaxCompute BLOB column for higher I/O bandwidth on repeated computation, and then invokes the multimodal model via SQL AI Functions.
Prerequisites
Activate MaxCompute and Create a MaxCompute project. Skip if already done.
PAI-EAS (Elastic Algorithm Service) is activated. Skip if already done.
OSS is activated. Skip if already done.
Step 1: Create an OSS bucket and upload data
Log in to the OSS console.
Create a bucket named
ot-demoin OSS. OSS console quick start.Create the directory
/object_table/image_demo/in the bucket and upload the image data image_demo.zip.
Step 2: Create and deploy a PAI EAS model service
Log on to the PAI console, select a region in the upper-left corner, and create a workspace.
Go to the workspace details page, click Model Gallery on the left, select
Qwen2.5-Omni-3B, and click Deploy.Select an instance type with an L20 GPU (48 GB VRAM) and click Deploy. Check the deployment status in Task Management. The status shows Running when deployment completes.
In the left-side navigation pane, click Model Deployment to open EAS. Locate the deployed service, click View Call Information, and note the endpoint and token.
-- The following information is required for creating the remote model in Step 3. Model name (subject to the actual EAS service name):quickstart_deploy_*****_apdf Endpoint (VPC address):http://*****.cn-beijing.pai-eas.aliyuncs.com (use only the part before aliyuncs.com) apikey(Token):****************************************==
Step 3: Create an object table
Create an object table and view its metadata.
SET odps.namespace.schema=true; -- Enable tenant-level schema syntax
CREATE OBJECT TABLE IF NOT EXISTS image_demo
WITH SERDEPROPERTIES ('odps.properties.rolearn'='acs:ram::<uid>:role/aliyunodpsdefaultrole')
LOCATION 'oss://oss-cn-<region>-internal.aliyuncs.com/object_table/image_demo/';
-- Refresh metadata
ALTER TABLE image_demo REFRESH METADATA;
-- Query image count
SET odps.namespace.schema=true;
SELECT COUNT(*) AS ROW_COUNT FROM image_demo;
-- Sample output:
+------------+
| row_count |
+------------+
| 10 |
+------------+Step 4: Create a table with a BLOB column and insert data
-- Create a table with a BLOB column
CREATE TABLE IF NOT EXISTS speech_segments_table (
image_name STRING COMMENT 'Image identifier',
image_desc blob COMMENT 'Image data'
)
COMMENT 'SQL image data table'
TBLPROPERTIES (
"table.format.version"="2"
);
-- Insert data
SET odps.namespace.schema=true;
INSERT INTO speech_segments_table
SELECT
t.key AS image_name,
to_blob(image_binary) AS image_desc
FROM (
SELECT key, GET_DATA_FROM_OSS('<project_name>.<schema>.image_demo', key) AS image_binary
FROM <project_name>.<schema>.image_demo
) t;
SELECT * FROM speech_segments_table;
-- Sample output:
+------------+------------+
| image_name | image_desc |
+------------+------------+
| test01.png | CAEQ**Mg== |
| test02.png | CAEQ**Mg== |
| test03.png | CAEQ**Mg== |
| test04.png | CAEQ**Mg== |
| test05.png | CAEQ**Mg== |
| test06.png | CAEQ**Mg== |
| test07.png | CAEQ**Mg== |
| test08.png | CAEQ**Mg== |
| test09.png | CAEQ**Mg== |
| test10.png | CAEQ**Mg== |
+------------+------------+Step 5: Create a VPC network connection
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
Create a network connection between MaxCompute and the target VPC. The VPC ID can be any VPC, and the vSwitch can be in any zone.
Step 6: Register the Omni multimodal remote model
SET odps.namespace.schema=true;
SET odps.session.networklink=<your vpc name>;
CREATE MODEL PAI_EAS_Qwen25_Omni_3B_blob_image WITH VERSION v1
INPUT(data BINARY, promt STRING)
OPTIONS(
MODEL_SOURCE_TYPE = 'REMOTE',
MODEL_TYPE = 'MLLM',
TASKS = 'text-generation',
PAI_EAS_MODEL_NAME = 'Qwen2.5-Omni-3B',
PAI_EAS_SERVICE_NAME = 'quickstart_deploy_*****',
ENDPOINT = 'http://*****.vpc.cn-<region>.pai-eas.aliyuncs.com',
APIKEY = '*****',
PAI_EAS_SYNC_MODE = 'true'
)
COMMENT "PAI EAS remote model";Step 7: Process image data with the AI_GENERATE function
SET odps.namespace.schema=true;
SET odps.mcqa.disable=true; -- Disable Query Acceleration mode. AI Functions do not support Query Acceleration mode.
SET odps.session.networklink=<your vpc name>;
SELECT
image_name,
AI_GENERATE(
PAI_EAS_Qwen25_Omni_3B_blob_image, DEFAULT_VERSION, speech_data,
"Extract all text from the image. Output only the text content, with no introduction,explanation, Markdown formatting, or additional comments."
) AS sql_dml
FROM (
SELECT image_name, read_blob(image_desc) AS speech_data
FROM <project name>.<schema>.speech_segments_table
) ;