CREATE MODEL

statementsupportedAI & ML

docs.snowflake.com ↗

Object: MODEL

Creates a new machine learning model in the current/specified schema or replaces an existing model. Note Use the Snowflake Model Registry Python API to create models from scratch. In SQL, you can only create models from other models. Models are versioned. All models must have at least one version, and one version must be designated as the default. To add a version to a model, use ALTER MODEL … ADD VERSION. Some properties of a model can be modified (see ALTER MODEL), and multiple versions can be added. This command also supports the following variant: - CREATE MODEL … FROM internalStage (creates a model from files in an external stage)

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] MODEL [ IF NOT EXISTS ] <name> [ WITH VERSION <version_name> ]
    FROM MODEL <source_model_name> [ VERSION <source_version_or_alias_name> ]

This variant is used by the Snowflake Model Registry Python API. It is not possible to create models from scratch in SQL.

CREATE [ OR REPLACE ] MODEL [ IF NOT EXISTS ] <name> [ WITH VERSION <version_name> ]
  FROM internalStage

Where

internalStage ::=
    @[<namespace>.]<int_stage_name>[/<path>]
  | @[<namespace>.]%<table_name>[/<path>]
  | @~[/<path>]

Parameters

NameRequiredDescription
namerequiredString that specifies the identifier (i.e. name) for the new model; must be unique for the schema in which the model is created. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
FROM MODEL source_model_namerequired
Required if not using FROM internalStage variantSpecifies the name of the model from which to create the new model.
FROM internalStagerequired
Required if using FROM internalStage variantSpecifies the internal stage that contains the model’s files. The required layout of these files is not currently documented.
WITH VERSION version_nameoptional
For use with FROM MODEL variantSpecifies the name of the version to create in the new model.
VERSION source_version_or_alias_nameoptional
For use with FROM MODEL variantSpecifies the name or alias of the version to be copied from the source model. If not specified, uses the default version from the source model.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE MODEL | Schema | Implied by OWNERSHIP on schema OWNERSHIP | Model | A role must be granted or inherit the OWNERSHIP privilege on the object to create a temporary object that has the same name as the object that already exists in the schema. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

See also

Referenced by