Submit a model customization job
You can create a custom model by using Fine-tuning or Continued Pre-training in the Amazon Bedrock console or API. The customization job can take several hours. The duration of the job depends on the size of the training data (number of records, input tokens, and output tokens), number of epochs, and batch size. Choose the tab for your preferred method, and then follow the steps:
- Console
-
To submit a model customization job in the console, carry out the following steps.
-
Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at https://console.aws.amazon.com/bedrock/
. -
From the left navigation pane, choose Custom models under Foundation models.
-
In the Models tab, choose Customize model and then Create Fine-tuning job or Create Continued Pre-training job, depending on the type of model you want to train.
-
In the Model details section, do the following.
-
Choose the model that you want to customize with your own data and give your resulting model a name.
-
(Optional) By default, Amazon Bedrock encrypts your model with a key owned and managed by AWS. To use a custom KMS key, select Model encryption and choose a key.
-
(Optional) To associate tags with the custom model, expand the Tags section and select Add new tag.
-
-
In the Job configuration section, enter a name for the job and optionally add any tags to associate with the job.
-
(Optional) To use a virtual private cloud (VPC) to protect your training data and customization job, select a VPC that contains the input data and output data Amazon S3 locations, its subnets, and security groups in the VPC settings section.
Note
If you include a VPC configuration, the console cannot create a new service role for the job. Create a custom service role and add permissions similar to the example described in Attach VPC permissions to a model customization role.
-
In the Input data section, select the S3 location of the training dataset file and, if applicable, the validation dataset file.
-
In the Hyperparameters section, input values for hyperparameters to use in training.
-
In the Output data section, enter the Amazon S3 location where Amazon Bedrock should save the output of the job. Amazon Bedrock stores the training loss metrics and validation loss metrics for each epoch in separate files in the location that you specify.
-
In the Service access section, select one of the following:
-
Use an existing service role – Select a service role from the drop-down list. For more information on setting up a custom role with the appropriate permissions, see Create a service role for model customization.
-
Create and use a new service role – Enter a name for the service role.
-
-
Choose Fine-tune model or Create Continued Pre-training job to begin the job.
-
- API
-
Request
Send a CreateModelCustomizationJob (see link for request and response formats and field details) request with an Amazon Bedrock control plane endpoint to submit a model customization job. Minimally, you must provide the following fields.
-
roleArn
– The ARN of the service role with permissions to customize models. Amazon Bedrock can automatically create a role with the appropriate permissions if you use the console, or you can create a custom role by following the steps at Create a service role for model customization.Note
If you include a
vpcConfig
field, make sure that the role has the proper permissions to access the VPC. For an example, see Attach VPC permissions to a model customization role. -
baseModelIdentifier
– The model ID or ARN of the foundation model to customize. -
customModelName
– The name to give the newly customized model. -
jobName
– The name to give the training job. -
hyperParameters
– Hyperparameters that affect the model customization process. -
trainingDataConfig
– An object containing the Amazon S3 URI of the training dataset. Depending on the customization method and model, you can also include avalidationDataConfig
. For more information about preparing the datasets, see Prepare the datasets. -
outputDataConfig
– An object containing the Amazon S3 URI to write the output data to.
If you don't specify the
customizationType
, the model customization method defaults toFINE_TUNING
.To prevent the request from completing more than once, include a
clientRequestToken
.You can include the following optional fields for extra configurations.
-
jobTags
and/orcustomModelTags
– Associate tags with the customization job or resulting custom model. -
customModelKmsKeyId
– Include a custom KMS key to encrypt your custom model. -
vpcConfig
– Include the configuration for a virtual private cloud (VPC) to protect your training data and customization job.
Response
The response returns a
jobArn
that you can use to monitor or stop the job. -