Amazon Bedrock

2023/11/28 - Amazon Bedrock - 7 updated api methods

Changes  This release adds support for customization types, model life cycle status and minor versions/aliases for model identifiers.

CreateModelCustomizationJob (updated) Link ¶
Changes (request)
{'customizationType': 'FINE_TUNING | CONTINUED_PRE_TRAINING'}

Creates a fine-tuning job to customize a base model.

You specify the base foundation model and the location of the training data. After the model-customization job completes successfully, your custom model resource will be ready to use. Training data contains input and output text for each record in a JSONL format. Optionally, you can specify validation data in the same format as the training data. Amazon Bedrock returns validation loss metrics and output generations after the job completes.

Model-customization jobs are asynchronous and the completion time depends on the base model and the training/validation data size. To monitor a job, use the GetModelCustomizationJob operation to retrieve the job status.

For more information, see Custom models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.create_model_customization_job(
    jobName='string',
    customModelName='string',
    roleArn='string',
    clientRequestToken='string',
    baseModelIdentifier='string',
    customizationType='FINE_TUNING'|'CONTINUED_PRE_TRAINING',
    customModelKmsKeyId='string',
    jobTags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ],
    customModelTags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ],
    trainingDataConfig={
        's3Uri': 'string'
    },
    validationDataConfig={
        'validators': [
            {
                's3Uri': 'string'
            },
        ]
    },
    outputDataConfig={
        's3Uri': 'string'
    },
    hyperParameters={
        'string': 'string'
    },
    vpcConfig={
        'subnetIds': [
            'string',
        ],
        'securityGroupIds': [
            'string',
        ]
    }
)
type jobName

string

param jobName

[REQUIRED]

Enter a unique name for the fine-tuning job.

type customModelName

string

param customModelName

[REQUIRED]

Enter a name for the custom model.

type roleArn

string

param roleArn

[REQUIRED]

The Amazon Resource Name (ARN) of an IAM role that Amazon Bedrock can assume to perform tasks on your behalf. For example, during model training, Amazon Bedrock needs your permission to read input data from an S3 bucket, write model artifacts to an S3 bucket. To pass this role to Amazon Bedrock, the caller of this API must have the iam:PassRole permission.

type clientRequestToken

string

param clientRequestToken

Unique token value that you can provide. The GetModelCustomizationJob response includes the same token value.

This field is autopopulated if not provided.

type baseModelIdentifier

string

param baseModelIdentifier

[REQUIRED]

Name of the base model.

type customizationType

string

param customizationType

The customization type.

type customModelKmsKeyId

string

param customModelKmsKeyId

The custom model is encrypted at rest using this key.

type jobTags

list

param jobTags

Assign tags to the job.

  • (dict) --

    Definition of the key/value pair for a tag.

    • key (string) -- [REQUIRED]

      Key for the tag.

    • value (string) -- [REQUIRED]

      Value for the tag.

type customModelTags

list

param customModelTags

Assign tags to the custom model.

  • (dict) --

    Definition of the key/value pair for a tag.

    • key (string) -- [REQUIRED]

      Key for the tag.

    • value (string) -- [REQUIRED]

      Value for the tag.

type trainingDataConfig

dict

param trainingDataConfig

[REQUIRED]

Information about the training dataset.

  • s3Uri (string) -- [REQUIRED]

    The S3 URI where the training data is stored.

type validationDataConfig

dict

param validationDataConfig

Information about the validation dataset.

  • validators (list) -- [REQUIRED]

    Information about the validators.

    • (dict) --

      Information about a validator.

      • s3Uri (string) -- [REQUIRED]

        The S3 URI where the validation data is stored.

type outputDataConfig

dict

param outputDataConfig

[REQUIRED]

S3 location for the output data.

  • s3Uri (string) -- [REQUIRED]

    The S3 URI where the output data is stored.

type hyperParameters

dict

param hyperParameters

[REQUIRED]

Parameters related to tuning the model.

  • (string) --

    • (string) --

type vpcConfig

dict

param vpcConfig

VPC configuration (optional). Configuration parameters for the private Virtual Private Cloud (VPC) that contains the resources you are using for this job.

  • subnetIds (list) -- [REQUIRED]

    VPC configuration subnets.

    • (string) --

  • securityGroupIds (list) -- [REQUIRED]

    VPC configuration security group Ids.

    • (string) --

rtype

dict

returns

Response Syntax

{
    'jobArn': 'string'
}

Response Structure

  • (dict) --

    • jobArn (string) --

      ARN of the fine tuning job

GetCustomModel (updated) Link ¶
Changes (response)
{'customizationType': 'FINE_TUNING | CONTINUED_PRE_TRAINING'}

Get the properties associated with a Amazon Bedrock custom model that you have created.For more information, see Custom models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.get_custom_model(
    modelIdentifier='string'
)
type modelIdentifier

string

param modelIdentifier

[REQUIRED]

Name or ARN of the custom model.

rtype

dict

returns

Response Syntax

{
    'modelArn': 'string',
    'modelName': 'string',
    'jobName': 'string',
    'jobArn': 'string',
    'baseModelArn': 'string',
    'customizationType': 'FINE_TUNING'|'CONTINUED_PRE_TRAINING',
    'modelKmsKeyArn': 'string',
    'hyperParameters': {
        'string': 'string'
    },
    'trainingDataConfig': {
        's3Uri': 'string'
    },
    'validationDataConfig': {
        'validators': [
            {
                's3Uri': 'string'
            },
        ]
    },
    'outputDataConfig': {
        's3Uri': 'string'
    },
    'trainingMetrics': {
        'trainingLoss': ...
    },
    'validationMetrics': [
        {
            'validationLoss': ...
        },
    ],
    'creationTime': datetime(2015, 1, 1)
}

Response Structure

  • (dict) --

    • modelArn (string) --

      ARN associated with this model.

    • modelName (string) --

      Model name associated with this model.

    • jobName (string) --

      Job name associated with this model.

    • jobArn (string) --

      Job ARN associated with this model.

    • baseModelArn (string) --

      ARN of the base model.

    • customizationType (string) --

      The type of model customization.

    • modelKmsKeyArn (string) --

      The custom model is encrypted at rest using this key.

    • hyperParameters (dict) --

      Hyperparameter values associated with this model.

      • (string) --

        • (string) --

    • trainingDataConfig (dict) --

      Information about the training dataset.

      • s3Uri (string) --

        The S3 URI where the training data is stored.

    • validationDataConfig (dict) --

      Array of up to 10 validators.

      • validators (list) --

        Information about the validators.

        • (dict) --

          Information about a validator.

          • s3Uri (string) --

            The S3 URI where the validation data is stored.

    • outputDataConfig (dict) --

      Output data configuration associated with this custom model.

      • s3Uri (string) --

        The S3 URI where the output data is stored.

    • trainingMetrics (dict) --

      The training metrics from the job creation.

      • trainingLoss (float) --

        Loss metric associated with the custom job.

    • validationMetrics (list) --

      The validation metrics from the job creation.

      • (dict) --

        The metric for the validator.

        • validationLoss (float) --

          The validation loss associated with this validator.

    • creationTime (datetime) --

      Creation time of the model.

GetFoundationModel (updated) Link ¶
Changes (response)
{'modelDetails': {'customizationsSupported': {'CONTINUED_PRE_TRAINING'},
                  'modelLifecycle': {'status': 'ACTIVE | LEGACY'}}}

Get details about a Amazon Bedrock foundation model.

See also: AWS API Documentation

Request Syntax

client.get_foundation_model(
    modelIdentifier='string'
)
type modelIdentifier

string

param modelIdentifier

[REQUIRED]

The model identifier.

rtype

dict

returns

Response Syntax

{
    'modelDetails': {
        'modelArn': 'string',
        'modelId': 'string',
        'modelName': 'string',
        'providerName': 'string',
        'inputModalities': [
            'TEXT'|'IMAGE'|'EMBEDDING',
        ],
        'outputModalities': [
            'TEXT'|'IMAGE'|'EMBEDDING',
        ],
        'responseStreamingSupported': True|False,
        'customizationsSupported': [
            'FINE_TUNING'|'CONTINUED_PRE_TRAINING',
        ],
        'inferenceTypesSupported': [
            'ON_DEMAND'|'PROVISIONED',
        ],
        'modelLifecycle': {
            'status': 'ACTIVE'|'LEGACY'
        }
    }
}

Response Structure

  • (dict) --

    • modelDetails (dict) --

      Information about the foundation model.

      • modelArn (string) --

        The model ARN.

      • modelId (string) --

        The model identifier.

      • modelName (string) --

        The model name.

      • providerName (string) --

        he model's provider name.

      • inputModalities (list) --

        The input modalities that the model supports.

        • (string) --

      • outputModalities (list) --

        The output modalities that the model supports.

        • (string) --

      • responseStreamingSupported (boolean) --

        Indicates whether the model supports streaming.

      • customizationsSupported (list) --

        The customization that the model supports.

        • (string) --

      • inferenceTypesSupported (list) --

        The inference types that the model supports.

        • (string) --

      • modelLifecycle (dict) --

        Contains details about whether a model version is available or deprecated

        • status (string) --

          Specifies whether a model version is available ( ACTIVE ) or deprecated ( LEGACY .

GetModelCustomizationJob (updated) Link ¶
Changes (response)
{'customizationType': 'FINE_TUNING | CONTINUED_PRE_TRAINING'}

Retrieves the properties associated with a model-customization job, including the status of the job. For more information, see Custom models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.get_model_customization_job(
    jobIdentifier='string'
)
type jobIdentifier

string

param jobIdentifier

[REQUIRED]

Identifier for the customization job.

rtype

dict

returns

Response Syntax

{
    'jobArn': 'string',
    'jobName': 'string',
    'outputModelName': 'string',
    'outputModelArn': 'string',
    'clientRequestToken': 'string',
    'roleArn': 'string',
    'status': 'InProgress'|'Completed'|'Failed'|'Stopping'|'Stopped',
    'failureMessage': 'string',
    'creationTime': datetime(2015, 1, 1),
    'lastModifiedTime': datetime(2015, 1, 1),
    'endTime': datetime(2015, 1, 1),
    'baseModelArn': 'string',
    'hyperParameters': {
        'string': 'string'
    },
    'trainingDataConfig': {
        's3Uri': 'string'
    },
    'validationDataConfig': {
        'validators': [
            {
                's3Uri': 'string'
            },
        ]
    },
    'outputDataConfig': {
        's3Uri': 'string'
    },
    'customizationType': 'FINE_TUNING'|'CONTINUED_PRE_TRAINING',
    'outputModelKmsKeyArn': 'string',
    'trainingMetrics': {
        'trainingLoss': ...
    },
    'validationMetrics': [
        {
            'validationLoss': ...
        },
    ],
    'vpcConfig': {
        'subnetIds': [
            'string',
        ],
        'securityGroupIds': [
            'string',
        ]
    }
}

Response Structure

  • (dict) --

    • jobArn (string) --

      The ARN of the customization job.

    • jobName (string) --

      The name of the customization job.

    • outputModelName (string) --

      The name of the output model.

    • outputModelArn (string) --

      The ARN of the output model.

    • clientRequestToken (string) --

      The token that you specified in the CreateCustomizationJob request.

    • roleArn (string) --

      The ARN of the IAM role.

    • status (string) --

      The status of the job. A successful job transitions from in-progress to completed when the output model is ready to use. If the job failed, the failure message contains information about why the job failed.

    • failureMessage (string) --

      Information about why the job failed.

    • creationTime (datetime) --

      Time that the resource was created.

    • lastModifiedTime (datetime) --

      Time that the resource was last modified.

    • endTime (datetime) --

      Time that the resource transitioned to terminal state.

    • baseModelArn (string) --

      ARN of the base model.

    • hyperParameters (dict) --

      The hyperparameter values for the job. For information about hyperparameters for specific models, see Guidelines for model customization.

      • (string) --

        • (string) --

    • trainingDataConfig (dict) --

      S3 Location of the training data.

      • s3Uri (string) --

        The S3 URI where the training data is stored.

    • validationDataConfig (dict) --

      Array of up to 10 validators.

      • validators (list) --

        Information about the validators.

        • (dict) --

          Information about a validator.

          • s3Uri (string) --

            The S3 URI where the validation data is stored.

    • outputDataConfig (dict) --

      Output data configuration

      • s3Uri (string) --

        The S3 URI where the output data is stored.

    • customizationType (string) --

      The type of model customization.

    • outputModelKmsKeyArn (string) --

      The custom model is encrypted at rest using this key.

    • trainingMetrics (dict) --

      Metrics associated with the custom job.

      • trainingLoss (float) --

        Loss metric associated with the custom job.

    • validationMetrics (list) --

      The loss metric for each validator that you provided in the createjob request.

      • (dict) --

        The metric for the validator.

        • validationLoss (float) --

          The validation loss associated with this validator.

    • vpcConfig (dict) --

      VPC configuration for the custom model job.

      • subnetIds (list) --

        VPC configuration subnets.

        • (string) --

      • securityGroupIds (list) --

        VPC configuration security group Ids.

        • (string) --

ListCustomModels (updated) Link ¶
Changes (response)
{'modelSummaries': {'customizationType': 'FINE_TUNING | '
                                         'CONTINUED_PRE_TRAINING'}}

Returns a list of the custom models that you have created with the CreateModelCustomizationJob operation.

For more information, see Custom models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.list_custom_models(
    creationTimeBefore=datetime(2015, 1, 1),
    creationTimeAfter=datetime(2015, 1, 1),
    nameContains='string',
    baseModelArnEquals='string',
    foundationModelArnEquals='string',
    maxResults=123,
    nextToken='string',
    sortBy='CreationTime',
    sortOrder='Ascending'|'Descending'
)
type creationTimeBefore

datetime

param creationTimeBefore

Return custom models created before the specified time.

type creationTimeAfter

datetime

param creationTimeAfter

Return custom models created after the specified time.

type nameContains

string

param nameContains

Return custom models only if the job name contains these characters.

type baseModelArnEquals

string

param baseModelArnEquals

Return custom models only if the base model ARN matches this parameter.

type foundationModelArnEquals

string

param foundationModelArnEquals

Return custom models only if the foundation model ARN matches this parameter.

type maxResults

integer

param maxResults

Maximum number of results to return in the response.

type nextToken

string

param nextToken

Continuation token from the previous response, for Amazon Bedrock to list the next set of results.

type sortBy

string

param sortBy

The field to sort by in the returned list of models.

type sortOrder

string

param sortOrder

The sort order of the results.

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'modelSummaries': [
        {
            'modelArn': 'string',
            'modelName': 'string',
            'creationTime': datetime(2015, 1, 1),
            'baseModelArn': 'string',
            'baseModelName': 'string',
            'customizationType': 'FINE_TUNING'|'CONTINUED_PRE_TRAINING'
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      Continuation token for the next request to list the next set of results.

    • modelSummaries (list) --

      Model summaries.

      • (dict) --

        Summary information for a custom model.

        • modelArn (string) --

          The ARN of the custom model.

        • modelName (string) --

          The name of the custom model.

        • creationTime (datetime) --

          Creation time of the model.

        • baseModelArn (string) --

          The base model ARN.

        • baseModelName (string) --

          The base model name.

        • customizationType (string) --

          Specifies whether to carry out continued pre-training of a model or whether to fine-tune it. For more information, see Custom models.

ListFoundationModels (updated) Link ¶
Changes (request, response)
Request
{'byCustomizationType': {'CONTINUED_PRE_TRAINING'}}
Response
{'modelSummaries': {'customizationsSupported': {'CONTINUED_PRE_TRAINING'},
                    'modelLifecycle': {'status': 'ACTIVE | LEGACY'}}}

List of Amazon Bedrock foundation models that you can use. For more information, see Foundation models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.list_foundation_models(
    byProvider='string',
    byCustomizationType='FINE_TUNING'|'CONTINUED_PRE_TRAINING',
    byOutputModality='TEXT'|'IMAGE'|'EMBEDDING',
    byInferenceType='ON_DEMAND'|'PROVISIONED'
)
type byProvider

string

param byProvider

A Amazon Bedrock model provider.

type byCustomizationType

string

param byCustomizationType

List by customization type.

type byOutputModality

string

param byOutputModality

List by output modality type.

type byInferenceType

string

param byInferenceType

List by inference type.

rtype

dict

returns

Response Syntax

{
    'modelSummaries': [
        {
            'modelArn': 'string',
            'modelId': 'string',
            'modelName': 'string',
            'providerName': 'string',
            'inputModalities': [
                'TEXT'|'IMAGE'|'EMBEDDING',
            ],
            'outputModalities': [
                'TEXT'|'IMAGE'|'EMBEDDING',
            ],
            'responseStreamingSupported': True|False,
            'customizationsSupported': [
                'FINE_TUNING'|'CONTINUED_PRE_TRAINING',
            ],
            'inferenceTypesSupported': [
                'ON_DEMAND'|'PROVISIONED',
            ],
            'modelLifecycle': {
                'status': 'ACTIVE'|'LEGACY'
            }
        },
    ]
}

Response Structure

  • (dict) --

    • modelSummaries (list) --

      A list of Amazon Bedrock foundation models.

      • (dict) --

        Summary information for a foundation model.

        • modelArn (string) --

          The ARN of the foundation model.

        • modelId (string) --

          The model Id of the foundation model.

        • modelName (string) --

          The name of the model.

        • providerName (string) --

          The model's provider name.

        • inputModalities (list) --

          The input modalities that the model supports.

          • (string) --

        • outputModalities (list) --

          The output modalities that the model supports.

          • (string) --

        • responseStreamingSupported (boolean) --

          Indicates whether the model supports streaming.

        • customizationsSupported (list) --

          Whether the model supports fine-tuning or continual pre-training.

          • (string) --

        • inferenceTypesSupported (list) --

          The inference types that the model supports.

          • (string) --

        • modelLifecycle (dict) --

          Contains details about whether a model version is available or deprecated.

          • status (string) --

            Specifies whether a model version is available ( ACTIVE ) or deprecated ( LEGACY .

ListModelCustomizationJobs (updated) Link ¶
Changes (response)
{'modelCustomizationJobSummaries': {'customizationType': 'FINE_TUNING | '
                                                         'CONTINUED_PRE_TRAINING'}}

Returns a list of model customization jobs that you have submitted. You can filter the jobs to return based on one or more criteria.

For more information, see Custom models in the Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

client.list_model_customization_jobs(
    creationTimeAfter=datetime(2015, 1, 1),
    creationTimeBefore=datetime(2015, 1, 1),
    statusEquals='InProgress'|'Completed'|'Failed'|'Stopping'|'Stopped',
    nameContains='string',
    maxResults=123,
    nextToken='string',
    sortBy='CreationTime',
    sortOrder='Ascending'|'Descending'
)
type creationTimeAfter

datetime

param creationTimeAfter

Return customization jobs created after the specified time.

type creationTimeBefore

datetime

param creationTimeBefore

Return customization jobs created before the specified time.

type statusEquals

string

param statusEquals

Return customization jobs with the specified status.

type nameContains

string

param nameContains

Return customization jobs only if the job name contains these characters.

type maxResults

integer

param maxResults

Maximum number of results to return in the response.

type nextToken

string

param nextToken

Continuation token from the previous response, for Amazon Bedrock to list the next set of results.

type sortBy

string

param sortBy

The field to sort by in the returned list of jobs.

type sortOrder

string

param sortOrder

The sort order of the results.

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'modelCustomizationJobSummaries': [
        {
            'jobArn': 'string',
            'baseModelArn': 'string',
            'jobName': 'string',
            'status': 'InProgress'|'Completed'|'Failed'|'Stopping'|'Stopped',
            'lastModifiedTime': datetime(2015, 1, 1),
            'creationTime': datetime(2015, 1, 1),
            'endTime': datetime(2015, 1, 1),
            'customModelArn': 'string',
            'customModelName': 'string',
            'customizationType': 'FINE_TUNING'|'CONTINUED_PRE_TRAINING'
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      Page continuation token to use in the next request.

    • modelCustomizationJobSummaries (list) --

      Job summaries.

      • (dict) --

        Information about one customization job

        • jobArn (string) --

          ARN of the customization job.

        • baseModelArn (string) --

          ARN of the base model.

        • jobName (string) --

          Name of the customization job.

        • status (string) --

          Status of the customization job.

        • lastModifiedTime (datetime) --

          Time that the customization job was last modified.

        • creationTime (datetime) --

          Creation time of the custom model.

        • endTime (datetime) --

          Time that the customization job ended.

        • customModelArn (string) --

          ARN of the custom model.

        • customModelName (string) --

          Name of the custom model.

        • customizationType (string) --

          Specifies whether to carry out continued pre-training of a model or whether to fine-tune it. For more information, see Custom models.