Process Unstructured Data with AI Function and Object Table
This article shows how to use an Object Table with a MaxCompute AI Function to call a remote model for speech content extraction. After an upstream system stores unstructured data in a specified Object Storage Service (OSS) directory, MaxCompute maps the files by creating an Object Table. This feature supports both full and incremental metadata extraction to retrieve file metadata. This approach eliminates data migration from OSS to MaxCompute and uses metadata to improve the MaxCompute SQL engine's performance in data reads, file filtering, and distributed computing. You can then use the SQL engine with an AI Function to call a multimodal model that reads data from the Object Table to process and analyze unstructured data.
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. For more information, see Quick start for the OSS console.In the new bucket, create a directory named
/object_table/voice_demo/and upload the audio data from voice_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.sql.type.system.odps2=true;
SET odps.namespace.schema=true; -- Enable the tenant-level schema syntax.
CREATE OBJECT TABLE IF NOT EXISTS voice_demo
WITH SERDEPROPERTIES ('odps.properties.rolearn'='acs:ram::<uid>:role/aliyunodpsdefaultrole')
LOCATION 'oss://oss-cn-<region>-internal.aliyuncs.com/object-table/voice_demo/';
ALTER TABLE voice_demo REFRESH METADATA;
-- After you refresh the metadata, you can query the table and find five audio objects.
SET odps.namespace.schema=true;
SELECT COUNT(*) AS ROW_COUNT FROM voice_demo; Step 4: Create a 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 5: Register the Omni multimodal remote model
When defining a model with Binary input, declare input parameters as INPUT(data BINARY, promt STRING).
When using a String URL as input, use the default values without declaring input parameters.
For more information about the syntax and parameters, see CREATE MODEL.
SET odps.namespace.schema=true;
SET odps.session.networklink=<your_vpc_name>;
CREATE MODEL PAI_EAS_Qwen25_Omni_3B WITH VERSION v1
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 = 'https://*****.vpc.cn-beijing.pai-eas.aliyuncs.com/',
APIKEY = '*****==',
PAI_EAS_SYNC_MODE = 'true'
)
COMMENT "PAI EAS remote model";Step 6: Process speech data with AI_GENERATE
Use the MaxCompute AI_GENERATE function to extract text from the speech data and translate it into English.
SET odps.namespace.schema=true;
SET odps.mcqa.disable=true;
SET odps.session.networklink=<your_vpc_name>;
SELECT
key,
AI_GENERATE(
PAI_EAS_Qwen25_Omni_3B, v1, audio_url,
"Transcribe the audio content. Output only the transcribed text and no extra information.",
"AUDIO"
) AS voice2text,
AI_GENERATE(
PAI_EAS_Qwen25_Omni_3B, v1, audio_url,
"Translate the audio content into English. Do not output any extra information.",
"AUDIO"
) AS voice2text2english
FROM (
SELECT GET_SIGNED_URL_FROM_OSS(
'<project_name>.<schema>.voice_demo', key, 604800
) AS audio_url, key AS key
FROM <project_name>.<schema>.voice_demo
);
+------+------------+--------------------+
| key | voice2text | voice2text2english |
+------+------------+--------------------+
| 3d111ad2-3708-492b-a99c-8621e852964d.wav | 听到的信息:教育改革措施需要更多时间来观察效果 | Educational reform measures require more time for observation and assessment of their effectiveness. |
| 3f46aaf1-7b70-4ac7-a3b1-f574ff884ac7.wav | 这家餐厅的服务态度很好,菜品也很美味,值得推荐。 | The service at this restaurant is excellent, and the food is delicious. I highly recommend it. |
| b222aabf-7f2e-4909-b774-5e762eb75a0a.wav | 科技发展日新月异,人工智能改变生活。 | Technology is advancing rapidly, and artificial intelligence is revolutionizing our lives. |
| bbc84f7d-dcf6-45eb-a129-34df3ec9c612.wav | 今天天气真好,心情很不错,阳光明媚,适合出去散步。 | The weather is great today, and I'm in a good mood. It's sunny and perfect for a walk. |
| d8caf7ef-4489-403a-94e9-86d83bcf1966.wav | 环保意识需要进一步提高,保护我们的地球家园。 | Environmental awareness needs to be raised to protect our planet. |
+------+------------+--------------------+