Submit a model customization job for fine-tuning or continued pre-training
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.
Prerequisites
-
Create an AWS Identity and Access Management (IAM) service role to access the S3 bucket where you want to store
your model customization training and validation data. You can create this
role automatically by using the AWS Management Console or manually. For more information on the manual option, see Create an IAM service role for model customization.
-
(Optional) Encrypt input and output data, your customization job, or inference
requests made to custom models. For more information, see Encryption of custom models.
-
(Optional) Create a virtual private cloud (VPC) to protect your customization
job. For more information, see (Optional) Protect your model customization jobs
using a VPC.
Submit your job
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 with an IAM identity that has permissions to use the Amazon Bedrock console. Then, 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.
-
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 dropdown 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.
-
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 a validationDataConfig
. For more information about preparing the datasets, see Prepare your training datasets for fine-tuning and continued
pre-training.
-
validationDataconfig
– An object containing the Amazon S3 URI of the validation dataset.
-
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 to FINE_TUNING
.
To prevent the request from completing more than once, include a clientRequestToken
.
You can include the following optional fields for extra configurations.
Response
The response returns a jobArn
that you can use to monitor or stop the job.
See code examples