Submit a model customization job - Amazon Bedrock

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. Select the tab corresponding to your method of choice and follow the steps.

Console

To submit a model customization job in the console, carry out the following steps.

  1. In the Amazon Bedrock console, choose Custom models under Foundation models from the left navigation pane.

  2. 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.

  3. In the Model details section, do the following.

    1. Choose the model that you want to customize with your own data and give your resulting model a name.

    2. (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.

    3. (Optional) To associate tags with the custom model, expand the Tags section and select Add new tag.

  4. In the Job configuration section, enter a name for the job and optionally add any tags to associate with the job.

  5. (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.

  6. In the Input data section, select the S3 location of the training dataset file and, if applicable, the validation dataset file.

  7. In the Hyperparameters section, input values for hyperparameters to use in training.

  8. 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.

  9. 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.

  10. 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.

  • hyperParametersHyperparameters 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 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 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