FINETUNE ('CREATE') (SNOWFLAKE.CORTEX)¶

Creates a fine-tuning job. The tuned model is saved to the model registry of the schema.

Syntax¶

SNOWFLAKE.CORTEX.FINETUNE(
  'CREATE',
  '<name>',
  '<base_model>',
  '<training_data_query>',
  [ '<validation_data_query>' ]
)
Copy

Required parameters¶

'CREATE'

Specifies that you want to create a fine-tuning job.

'name'

The identifier of the fine-tuned model that is saved to the model registry. This must be unique to the model registry it is saved to. If more than one model attempts to save using the same name, a suffix is appended to the name of the latter one to make it unique.

Letters, underscores, decimal digits (0-9) are allowed in the identifier.

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.

'base_model'

A string specifying the base model to fine-tune. This must be one of the following values:

  • 'mistral-7b'

  • 'mixtral-8x7b'

  • 'llama3-8b'

  • 'llama3-70b'

'training_data_query'

The SQL query to get the training data. The result must include prompt and completion columns.

Optional parameters¶

'validation_data_query'

The SQL query to get the validation data. The result must include prompt and completion columns. If a query for validation data is not specified, your training data is automatically split into training and validation data.

Returns¶

Column

Type

Description

FINETUNE

STRING

When the tuning job is created, a generated unique job ID is returned.

Access control requirements¶

Privilege

Object

Notes

USAGE

DATABASE

The database that the training (and validation) data are queried from.

CREATE MODEL or OWNERSHIP

SCHEMA

The schema that the model is saved to.

Examples¶

Example with validation data:

SELECT SNOWFLAKE.CORTEX.FINETUNE(
  'CREATE',
  'my_tuned_model',
  'mistral-7b',
  'SELECT prompt, completion FROM train',
  'SELECT prompt, completion FROM validation'
);
Copy

Example without validation data:

SELECT SNOWFLAKE.CORTEX.FINETUNE(
  'CREATE',
  'my_tuned_model',
  'mistral-7b',
  'SELECT prompt, completion FROM train'
);
Copy

The output is the job ID of the fine-tuning job:

CortexFineTuningWorkflow_6556e15c-8f12-4d94-8cb0-87e6f2fd2299