Create and delete models
This topic describes the commands used to create and delete MaxCompute models.
|
Operation |
Function |
Role |
Entry points |
|
Create a MaxCompute model object in a project. |
Users with the CreateModel permission in the project. |
The commands in this topic can be run in the following tools: |
|
|
Delete an existing MaxCompute model object from a project. |
Users with the Drop permission on the model. |
Create a model
Create MaxCompute model and model version objects in a project. For more information about models and model versions, see Model types.
Usage notes
-
MaxCompute 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.
-
MaxCompute internally trained models can currently only be created by running
to_odps_modelin MaxFrame. SQL creation is not supported. For details, see to_odps_model.
Syntax
Create an imported model (IMPORT MODEL)
CREATE MODEL [ IF NOT EXISTS ] <model_name> WITH VERSION <version_name>
INPUT(<input_col_name> <input_data_type>, ... ) -- Required when MODEL_SOURCE_TYPE is IMPORT
OPTIONS(
MODEL_SOURCE_TYPE = '<model_source_type>', -- Set to IMPORT for an imported model
MODEL_TYPE = '<model_type>', -- Imported models support only BOOSTED_TREE_CLASSIFIER and BOOSTED_TREE_REGRESSOR for MODEL_TYPE
LOCATION = '<location>',
ROLEARN = '<rolearn>'
)
[COMMENT <model_comment>];
Create a remote model (REMOTE MODEL)
CREATE MODEL [ IF NOT EXISTS ] <model_name> WITH VERSION <version_name>
[INPUT(<input_col_name> <input_data_type>, ... )]
OPTIONS(
MODEL_SOURCE_TYPE = '<model_source_type>', -- Set to REMOTE for a remote model
MODEL_TYPE = '<model_type>', -- Remote models support LLM or MLLM for 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
General parameters
|
Parameter |
Required |
Description |
Remarks |
|
model_name |
Yes |
The model name. |
|
|
version_name |
Yes |
The model version name. |
|
|
input_col_name |
No |
The input column name of the model version. |
Case-insensitive. Accepts only letters (a–z, A–Z), digits, underscores (_), and Chinese characters. Starting with a letter is recommended. An error is returned if the name exceeds 128 bytes. Note: Required for imported models. |
|
input_data_type |
No |
The data type of the input column of the model version. |
Supports data types such as BIGINT, DOUBLE, STRING, and BINARY. For details, see Data type versions. Note: Required for imported models. |
|
model_source_type |
Yes |
The model source type. |
Cannot be modified after the model is created. Valid values:
|
|
model_type |
Yes |
The model type. |
Cannot be modified after the model is created. Valid values depend on the model source. For imported models, valid values are:
For remote models, valid values are:
|
|
comment |
No |
The model comment. |
A valid string of no more than 1,024 bytes. Otherwise, an error is returned. Note
The model comment specified at creation time is also applied to the first model version. |
Imported model parameters
|
Parameter |
Required |
Description |
Remarks |
|
location |
Yes |
The OSS path of the model file. |
The OSS path of the model file to import. Only OSS internal network endpoints are supported. Example: |
|
rolearn |
Yes |
The role used to authenticate access to OSS. |
The RAM role used to authenticate access to the OSS path that stores the model file. Example: Before using this parameter, make sure that the required OSS data permissions have been granted to the MaxCompute access account.
|
Remote model parameters
|
Parameter |
Required |
Description |
Remarks |
|
tasks |
Yes |
The task type. |
Valid values:
|
|
pai_eas_model_name |
Yes |
The name of the model deployed in PAI EAS. |
View the deployed model and service names in the PAI EAS console, and obtain the corresponding endpoint and token on the invocation information page. |
|
pai_eas_service_name |
Yes |
The name of the PAI EAS model service.
|
|
|
endpoint |
Yes |
Supports VPC endpoints (recommended) or EAS public endpoints.
|
|
|
apikey |
Yes |
The authentication token of the PAI EAS service. |
|
|
pai_eas_sync_mode |
Yes |
The mode used by the service to process requests. |
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 using the Qwen2.5-Omni-3B model service deployed in PAI EAS. The INPUT clause specifies that the model accepts image files (BINARY) for image-to-text tasks. For the complete example, 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, prompt STRING) -- Specify that the model accepts image files of the BINARY type
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 using a trained XGBoost classification model file that has been uploaded to the corresponding OSS path.
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
-
MaxCompute public models belong to public projects under the MaxCompute system account and cannot be manually deleted.
-
Deleting a model removes all its versions.
-
A deleted model cannot be restored. Proceed with caution. Before deleting a model, make sure that no inference tasks are running on any of its versions.
Syntax
DROP model [IF EXISTS] <model_name>;
Parameters
|
Parameter |
Required |
Description |
|
IF EXISTS |
No |
If IF EXISTS is omitted, an error is returned when the model does not exist. If specified, the statement succeeds regardless of whether the model exists. |
|
model_name |
Yes |
The name of the model to delete. Public models cannot be deleted. |
Example
DROP model PAI_EAS_Qwen25_Omni_3B;