All Products
Search
Document Center

MaxCompute:Automatically generate E-commerce product descriptions using a MaxCompute remote model

Last Updated:Mar 31, 2026

This tutorial shows how to classify e-commerce product images and generate promotional descriptions using SQL — no Python code or user-defined functions (UDFs) required. The pipeline reads images from Object Storage Service (OSS) through a MaxCompute Object Table, calls a multimodal large language model (MLLM) deployed in Elastic Algorithm Service (EAS) via the AI_GENERATE function, and returns structured results directly in SQL.

By the end of this tutorial, you will have completed the following:

  • Created an Object Table that maps OSS images into MaxCompute

  • Registered an MLLM hosted on Platform for AI (PAI) EAS as a remote model

  • Run SQL queries that classify each image by product category and generate a product description

Prerequisites

Before you begin, ensure that you have:

Step 1: Prepare the data

Upload your product images to OSS, then create an Object Table to make them accessible in MaxCompute.

This example uses 50 product poster images from the Alibaba Cloud Tianchi public dataset: Poster Design Text and Image Dataset.

  1. Create an Object Table pointing to your OSS bucket.

    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::1393************:role/aliyunodpsdefaultrole')
    LOCATION 'oss://oss-cn-shanghai-internal.aliyuncs.com/mllm-demo/jpg-test/';
  2. Refresh the table metadata so MaxCompute caches the image file list.

    ALTER TABLE image_demo REFRESH METADATA;
  3. Verify that all images are loaded.

    SELECT COUNT(*) AS ROW_COUNT FROM image_demo;

    Expected output:

    +------------+
    | row_count  |
    +------------+
    | 50         |
    +------------+

Step 2: Create the remote model

Register the Omni multimodal model from PAI EAS as a remote model in MaxCompute. Obtain the model service name, endpoint URL, and API key from the EAS console before running the following statements.

  1. Create the remote model with version v1, which accepts image URLs as input.

    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 = 'demo_remote_model',
        ENDPOINT = 'http://***********.cn-shanghai.pai-eas.aliyuncs.com',
        APIKEY = 'your-api-key',
        PAI_EAS_SYNC_MODE = 'true'
    )
    COMMENT "PAI EAS remote model";

    Replace your-api-key with the API key from your EAS service.

  2. Add version v2, which accepts raw binary image data. Use this version when you want to pass image bytes directly instead of a signed URL.

    ALTER MODEL PAI_EAS_Qwen25_Omni_3B ADD VERSION v2
    INPUT(data BINARY, promt STRING)
    WITH OPTIONS(
        MODEL_SOURCE_TYPE = 'REMOTE',
        MODEL_TYPE = 'MLLM',
        TASKS = 'text-generation',
        PAI_EAS_MODEL_NAME = 'Qwen2.5-Omni-3B',
        PAI_EAS_SERVICE_NAME = 'demo_remote_model',
        ENDPOINT = 'http://************.cn-shanghai.pai-eas.aliyuncs.com',
        APIKEY = 'your-api-key',
        PAI_EAS_SYNC_MODE = 'true'
    )
    COMMENT "PAI EAS remote model binary input";
  3. Verify the model registration.

    DESC MODEL PAI_EAS_Qwen25_Omni_3B;

    Expected output:

    ID = 20250909024319251glhmocwqddl
    +------------------------------------------------------------------------------------+
    |                  Model Information                                                 |
    +------------------------------------------------------------------------------------+
    | Owner:                    ALIYUN$***********************                           |
    | Project:                  pd_test_model                                            |
    | Schema:                   default                                                  |
    | Model Name:               PAI_EAS_Qwen25_Omni_3B                                   |
    | Model Type:               MLLM                                                     |
    | Source Type:              REMOTE                                                   |
    | Default Version:          v1                                                       |
    | CreateTime:               2025-09-04 10:29:28                                      |
    | LastModifiedTime:         2025-09-09 10:43:11                                      |
    | Model ID:                 46311b6397494a84ad23c5a4********                         |
    | Comment:                  PAI EAS remote model url input                           |
    +------------------------------------------------------------------------------------+
    |                Version Information                                                 |
    +------------------------------------------------------------------------------------+
    | Owner:                    ALIYUN$***********************                           |
    | Project:                  pd_test_model                                            |
    | Schema:                   default                                                  |
    | Model Name:               PAI_EAS_Qwen25_Omni_3B                                   |
    | Model Type:               MLLM                                                     |
    | Source Type:              REMOTE                                                   |
    | Version Name:             v1                                                       |
    | Version ID:               c389823cd0324b72b1c0d55***********                       |
    | Path:                                                                              |
    | CreateTime:               2025-09-04 10:29:28                                      |
    | LastModifiedTime:         2025-09-04 10:29:28                                      |
    | apikey:                   Yzc4*******mNzFkMGM********4YzEwZjY1NTA*********NzkyNw== |
    | endpoint:                 http://13933481********.cn-shanghai.pai-eas.aliyuncs.com |
    | pai_eas_model_name:       Qwen2.5-Omni-3B                                          |
    | pai_eas_service_name:     demo_eas_model                                           |
    | pai_eas_sync_mode:        true                                                     |
    | remote_service_type:      PAI-EAS                                                  |
    +------------------------------------------------------------------------------------+
    | Input           | Type       | Comment                                             |
    +------------------------------------------------------------------------------------+
    +------------------------------------------------------------------------------------+
    
    OK

Step 3: Classify images and generate descriptions

Use AI_GENERATE to run two prompts against each image: one to classify the product category and one to generate a promotional description. The function signature is AI_GENERATE(model, version, image_input, prompt).

Two input modes are supported:

Mode Version Input function When to use
URL v1 GET_SIGNED_URL_FROM_OSS Images stored in OSS (signed URL valid for 604,800 seconds)
Binary v2 GET_DATA_FROM_OSS Pass raw image bytes directly without generating a URL

URL mode (version v1)

SET odps.namespace.schema=true;

SELECT
  key,
  AI_GENERATE(
    PAI_EAS_Qwen25_Omni_3B, v1, image_url,
    "Recognize and extract the product category from the E-commerce product sales poster. The result must be one of the following six options: Cosmetics, Apparel, Daily Necessities, Food, Other, Electronics. Do not include any other text or information."
  ) AS item_catagory,
  AI_GENERATE(
    PAI_EAS_Qwen25_Omni_3B, v1, image_url,
    "You are a professional E-commerce copywriter. Generate a product description summary based on the provided E-commerce product sales poster. Output requirements: 1. The summary must accurately reflect key information from the poster, such as product features and promotional details. 2. The language must be fluent and readable, without any special symbols or garbled characters, and no longer than 50 characters. 3. The description must be in Chinese, except for English brand names. Do not include any other English words. Example: Limited-time offer on pure cotton T-shirts, buy one get one free, only 3 days left in the event!"
  ) AS item_description
FROM (
  SELECT
    GET_SIGNED_URL_FROM_OSS('pd_test_model.default.image_demo', key, 604800) AS image_url,
    key
  FROM pd_test_model.default.image_demo
) LIMIT 10;

Expected output (10 rows, completed in approximately 11.65 seconds):

+--------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------+
| key                | item_catagory     | item_description                                                                                                                |
+--------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------+
| alimamazszw-1.jpg  | Food              | Limited-time offer on steakhouse beef. Place an order to receive a gift. Served with fresh basil. A delicious experience not to be missed. |
| alimamazszw-10.jpg | Electronics       | New-feature fan on limited-time sale. Lowest price ever. Come and buy now!                                                      |
| alimamazszw-11.jpg | Electronics       | Cool helmets for sale online with MIPS protection technology. Get an instant discount of USD 40, bringing the price to USD 100. Limited-time event. Don't miss out! |
| alimamazszw-12.jpg | Cosmetics         | misspiggy "Ultra-fine Silky" eyeliner gel pencil. Soft, smooth, and long-lasting without smudging. Buy two and get USD 2 off. Limited-time offer. Act now. |
| alimamazszw-13.jpg | Electronics       | Special sale on IX35 wipers. Today's special offer. Buy now.                                                                    |
| alimamazszw-14.jpg | Daily Necessities | Biological tissue glue from Beijing Yoshida Biological Protection Technology Co., Ltd. Can seal wounds. For animal experiments only. Valid for 1 year. |
| alimamazszw-15.jpg | Cosmetics         | BodyAid hair growth serum. Awakens hair follicles, nurtures the scalp, and promotes new growth.                                   |
| alimamazszw-16.jpg | Cosmetics         | Limited-time offer on 3CE vitality blush. Buy one, get one free. Endless surprises on carnival day.                               |
| alimamazszw-17.jpg | Cosmetics         | La Mer HR skin cream in black and white packaging. Six-piece set with six great gifts. Order now and get gifts worth USD 330. SF Express delivery. Limited-time offer. Limited quantity. |
| alimamazszw-18.jpg | Daily Necessities | Listerine mouthwash in various flavors on sale. A USD 5 coupon is available. Limited quantity. Buy now!                          |
+--------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------+

Binary mode (version v2)

Use this mode to pass image data directly without generating signed URLs.

SELECT
  key,
  AI_GENERATE(
    PAI_EAS_Qwen25_Omni_3B, v2, image_binary,
    "Recognize and extract the product category from the E-commerce product sales poster. The result must be one of the following six options: Cosmetics, Apparel, Daily Necessities, Food, Other, Electronics. Do not include any other text or information."
  ) AS item_catagory,
  AI_GENERATE(
    PAI_EAS_Qwen25_Omni_3B, v2, image_binary,
    "You are a professional E-commerce copywriter. Generate a product description summary based on the provided E-commerce product sales poster. Output requirements: 1. The summary must accurately reflect key information from the poster, such as product features and promotional details. 2. The language must be fluent and readable, without any special symbols or garbled characters, and no longer than 50 characters. 3. The description must be in Chinese, except for English brand names. Do not include any other English words. Example: Limited-time offer on pure cotton T-shirts, buy one get one free, only 3 days left in the event!"
  ) AS item_description
FROM (
  SELECT
    GET_DATA_FROM_OSS('pd_test_model.default.image_demo', key) AS image_binary,
    key
  FROM pd_test_model.default.image_demo
) LIMIT 10;