Use CREATE MODEL to register an imported or remote model in a MaxCompute project, and DROP MODEL to remove a model and all its versions.
Prerequisites
Before you begin, make sure you have:
A MaxCompute project with the CreateModel permission to create models, or the Drop permission on a specific model to delete it
Access to one of the following entry points: MaxCompute client, SQL analysis, Cloud Shell (odpscmd), or DataWorks
Create a model
MaxCompute supports two model sources:
Imported model — an XGBoost model file stored in Object Storage Service (OSS) and imported into MaxCompute
Remote model — a large language model (LLM) or multimodal large language model (MLLM) deployed in PAI EAS and referenced from MaxCompute
For an overview of model types and versions, see Model types.
Usage notes
Public models belong to public projects under the MaxCompute system account. They are available directly for inference without creation. For the list of public models and usage instructions, see MaxCompute models.
Internally trained models can only be created by running
to_odps_modelin MaxFrame. SQL creation is not supported. For details, see to_odps_model.MODEL_SOURCE_TYPEandMODEL_TYPEcannot be modified after the model is created.The version specified at creation time becomes the default version (
DEFAULT_VERSION) of the model.The model comment specified at creation time is also applied to the first version.
Syntax
Imported model
CREATE MODEL [ IF NOT EXISTS ] <model_name> WITH VERSION <version_name>
INPUT(<input_col_name> <input_data_type>, ... )
OPTIONS(
MODEL_SOURCE_TYPE = 'IMPORT',
MODEL_TYPE = '<model_type>',
LOCATION = '<location>',
ROLEARN = '<rolearn>'
)
[COMMENT <model_comment>];Remote model
CREATE MODEL [ IF NOT EXISTS ] <model_name> WITH VERSION <version_name>
[INPUT(<input_col_name> <input_data_type>, ... )]
OPTIONS(
MODEL_SOURCE_TYPE = 'REMOTE',
MODEL_TYPE = '<model_type>',
TASKS = '<tasks>',
PAI_EAS_MODEL_NAME = '<pai_eas_model_name>',
PAI_EAS_SERVICE_NAME = '<pai_eas_service_name>',
ENDPOINT = '<endpoint>',
APIKEY = '<apikey>',
PAI_EAS_SYNC_MODE = 'true'
[,PAI_EAS_SYNC_REQUEST_TIMEOUT = '5000']
)
[COMMENT <model_comment>];Parameters
Required parameters
| Parameter | Description |
|---|---|
model_name | The model name. Case-insensitive. Accepts letters (a–z, A–Z), digits, and underscores (_). Must start with a letter. Maximum length: 256 bytes. Must be unique within the same project or schema. |
version_name | The model version name. Same naming rules as model_name. Cannot be set to default_version. Maximum length: 256 bytes. |
MODEL_SOURCE_TYPE | The model source. Valid values: IMPORT (imported model), REMOTE (remote model). Cannot be modified after creation. |
MODEL_TYPE | The model type. Cannot be modified after creation. For imported models: BOOSTED_TREE_CLASSIFIER (XGBoost classification model) or BOOSTED_TREE_REGRESSOR (XGBoost regression model). For remote models: LLM (large language model) or MLLM (multimodal large language model). |
Optional parameters
| Parameter | Description |
|---|---|
IF NOT EXISTS | If omitted, an error is returned when a model with the same name already exists. If specified, the statement succeeds without error. |
input_col_name | The input column name. Case-insensitive. Accepts letters (a–z, A–Z), digits, underscores (_), and Chinese characters. Must start with a letter. Maximum length: 128 bytes. Required when MODEL_SOURCE_TYPE is IMPORT. |
input_data_type | The data type of the input column. Supported types: BIGINT, DOUBLE, STRING, BINARY. For details, see Data type versions. Required when MODEL_SOURCE_TYPE is IMPORT. |
COMMENT | A description of the model. Maximum length: 1,024 bytes. Also applied to the first model version. |
Imported model parameters
| Parameter | Required | Description |
|---|---|---|
LOCATION | Yes | The OSS path of the model file. Only OSS internal network endpoints are supported. Example: oss://oss-cn-shanghai-internal.aliyuncs.com/test-mode-bucket/ |
ROLEARN | Yes | The RAM role used to authenticate access to OSS. Example: acs:ram::139******728:role/aliyunodpsdefaultrole. Before using this parameter, grant the required OSS permissions to MaxCompute: use one-click authorization to grant the default AliyunODPSDefaultRole permission, or create a custom role as described in Authorize in STS mode for OSS. |
Remote model parameters
| Parameter | Required | Description |
|---|---|---|
TASKS | Yes | The task type. Valid values: text-generation, chat, sentence-embedding. |
PAI_EAS_MODEL_NAME | Yes | The name of the model deployed in PAI EAS. View the deployed model and service name in the PAI EAS console. |
PAI_EAS_SERVICE_NAME | Yes | The name of the PAI EAS model service. If the service belongs to a service group, use the GroupName.ServiceName format (for example, group.service_name). Otherwise, specify only the service name. |
ENDPOINT | Yes | The endpoint of the PAI EAS service. Example: http://1*************70.cn-shanghai.pai-eas.aliyuncs.com. Only public endpoints are supported. Add the endpoint to the allowed external network addresses for MaxCompute before calling AI functions. For configuration steps, see Edit external network addresses through project management. |
APIKEY | Yes | The authentication token of the PAI EAS service. |
PAI_EAS_SYNC_MODE | Yes | The request processing mode. Only true (synchronous mode) is supported. |
PAI_EAS_SYNC_REQUEST_TIMEOUT | No | The timeout for synchronous requests. Unit: milliseconds. Default: 5000. Range: 5000–1800000. |
Examples
Example 1: Create a remote model
This example registers the Qwen2.5-Omni-3B model service deployed in PAI EAS as a remote model. The INPUT clause specifies that the model accepts image files (BINARY) for image-to-text tasks. For the complete end-to-end workflow, see Use a MaxCompute remote model to automatically generate e-commerce product descriptions.
CREATE MODEL PAI_EAS_Qwen25_Omni_3B 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 = 'test_remote_model',
ENDPOINT = 'http://11261230********.cn-shanghai.pai-eas.aliyuncs.com',
APIKEY = '<YOUR-API-KEY>',
PAI_EAS_SYNC_MODE = 'true'
)
COMMENT "PAI EAS remote model binary input";Example 2: Create an imported model
This example imports a trained XGBoost classification model from OSS.
CREATE MODEL test_xgboost_classifier WITH VERSION V1
INPUT (f1 int, f2 int, f3 int, f4 int)
OPTIONS(
MODEL_SOURCE_TYPE = 'IMPORT',
MODEL_TYPE = 'BOOSTED_TREE_CLASSIFIER',
LOCATION = 'oss://oss-cn-shanghai-internal.aliyuncs.com/********/xgboost_classifier/',
ROLEARN = 'acs:ram::11261230********:role/aliyunodpsdefaultrole'
)
COMMENT 'Import XGBoost model v1';After creating a model, use SHOW and DESC statements to view the model list and model details.
Delete a model
Usage notes
Public models cannot be deleted.
Deleting a model removes all its versions. This action cannot be undone. Before deleting, confirm that no inference tasks are running on any version of the model.
Syntax
DROP MODEL [IF EXISTS] <model_name>;Parameters
| Parameter | Required | Description |
|---|---|---|
model_name | Yes | The name of the model to delete. Public models cannot be deleted. |
IF EXISTS | No | If omitted, an error is returned when the model does not exist. If specified, the statement succeeds regardless of whether the model exists. |
Example
DROP MODEL PAI_EAS_Qwen25_Omni_3B;What's next
View models: List all models in a project or inspect the details and versions of a specific model.
MaxCompute models: Browse available public models and learn how to use them for inference.