

# Model Registry Collections
<a name="modelcollections"></a>

You can use Collections to group registered models that are related to each other and organize them in hierarchies to improve model discoverability at scale. With Collections, you can organize registered models that are associated with one another. For example, you could categorize your models based on the domain of the problem they solve as Collections titled * NLP-models*, *CV-models*, or * Speech-recognition-models*. To organize your registered models in a tree structure, you can nest Collections within each other. Any operations you perform on a Collection, such as create, read, update, or delete, will not alter your registered models. You can use the Amazon SageMaker Studio UI or the Python SDK to manage your Collections.

The **Collections** tab in the Model Registry displays a list of all the Collections in your account. The following sections describe how you can use options in the **Collections** tab to do the following:
+ Create Collections
+ Add Model Groups to a Collection
+ Move Model Groups between Collections
+ Remove Model Groups or Collections from other Collections

Any operation you perform on your Collections does not affect the integrity of the individual Model Groups they contain—the underlying Model Group artifacts in Amazon S3 and Amazon ECR are not modified.

While Collections provide greater flexibility in organizing your models, the internal representation imposes some constraints on the size of your hierarchy. For a summary of these constraints, see [Constraints](modelcollections-limitations.md).

The following topics show you how to create and work with Collections in the Model Registry.

**Topics**
+ [Set up prerequisite permissions](modelcollections-permissions.md)
+ [Create a Collection](modelcollections-create.md)
+ [Add Model Groups to a Collection](modelcollections-add-models.md)
+ [Remove Model Groups or Collections from a Collection](modelcollections-remove-models.md)
+ [Move a Model Group Between Collections](modelcollections-move-models.md)
+ [View a Model Group's Parent Collection](modelcollections-view-parent.md)
+ [Constraints](modelcollections-limitations.md)

# Set up prerequisite permissions
<a name="modelcollections-permissions"></a>

Create a custom policy which includes the following required Resource Groups actions:
+ `resource-groups:CreateGroup`
+ `resource-groups:DeleteGroup`
+ `resource-groups:GetGroupQuery`
+ `resource-groups:ListGroupResources`
+ `resource-groups:Tag`
+ `tag:GetResources`

For instructions on how to add an inline policy, see [ Adding IAM identity permissions (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console). When you choose the policy format, choose the JSON format and add the following policy:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "resource-groups:ListGroupResources"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "resource-groups:GetGroupQuery"
            ],
            "Resource": "arn:aws:resource-groups:*:*:group/*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "resource-groups:CreateGroup",
                "resource-groups:Tag"
            ],
            "Resource": "arn:aws:resource-groups:*:*:group/*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:TagKeys": "sagemaker:collection"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": "resource-groups:DeleteGroup",
            "Resource": "arn:aws:resource-groups:*:*:group/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/sagemaker:collection": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": "tag:GetResources",
            "Resource": "*"
        }
    ]
}
```

------

# Create a Collection
<a name="modelcollections-create"></a>

**Important**  
Custom IAM policies that allow Amazon SageMaker Studio or Amazon SageMaker Studio Classic to create Amazon SageMaker resources must also grant permissions to add tags to those resources. The permission to add tags to resources is required because Studio and Studio Classic automatically tag any resources they create. If an IAM policy allows Studio and Studio Classic to create resources but does not allow tagging, "AccessDenied" errors can occur when trying to create resources. For more information, see [Provide permissions for tagging SageMaker AI resources](security_iam_id-based-policy-examples.md#grant-tagging-permissions).  
[AWS managed policies for Amazon SageMaker AI](security-iam-awsmanpol.md) that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.

You can create a Collection in the Amazon SageMaker Studio console. To create a Collection, complete the following steps based on whether you use Studio or Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Models**.

1. Choose the **Registered models** tab, if not selected already.

1. Immediately below the **Registered models** tab label, choose **Collections**.

1. (Optional) To create a Collection inside another Collection, navigate to the hierarchy where you want to add your Collection. Otherwise, your Collection is created at the root level.

1. In the **Actions** dropdown menu in the top right, choose **Create new collection**.

1. Enter a name for your Collection in the **Name** field of the dialog box.
**Note**  
If you plan to create multiple hierarchies in this Collection, keep your Collection names short. The absolute path, which is a string representing the location of your Collections from the root level, must be 256 characters or less. For additional details, see [Collection and Model Group tagging](modelcollections-limitations.md#modelcollections-tagging).

1. (Optional) To add Model Groups to your Collection, complete the following steps:

   1. Choose **Select model groups**.

   1. Select the Model Groups that you want to add. You can select up to 10.

1. Choose **Create**.

1. Check to make sure your Collection was created in the current hierarchy. If you do not immediately see your new Collection, choose **Refresh**.

------
#### [ Studio Classic ]

1. Sign in to Amazon SageMaker Studio Classic. For more information, see [Launch Amazon SageMaker Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-launch.html).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Collections** tab.

1. (Optional) To create a Collection inside another Collection, navigate to the hierarchy where you want to add your Collection. Otherwise, your Collection is created at the root level.

1. In the **Actions** dropdown menu in the top right, choose **Create new collection**.

1. Enter a name for your Collection in the **Name** field of the dialog box.
**Note**  
If you plan to create multiple hierarchies in this Collection, keep your Collection names short. The absolute path, which is a string representing the location of your Collections from the root level, must be 256 characters or less. For additional details, see [Collection and Model Group tagging](modelcollections-limitations.md#modelcollections-tagging).

1. (Optional) To add Model Groups to your Collection, complete the following steps:

   1. Choose **Select model groups**.

   1. Select the Model Groups that you want to add. You can select up to 10.

1. Choose **Create**.

1. Check to make sure your Collection was created in the current hierarchy. If you do not immediately see your new Collection, choose **Refresh**.

------

# Add Model Groups to a Collection
<a name="modelcollections-add-models"></a>

You can add model groups to a Collection in the Amazon SageMaker Studio console. To add Model Groups to a Collection, complete the following steps based on whether you use Studio or Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Models**.

1. Choose the **Registered models** tab, if not selected already.

1. Immediately below the **Registered models** tab label, choose **Models**, if not selected already.

1. Select the check box next to the model groups that you want to add. You can select up to 10 Model Groups. If you select more than 10, the UI option to add your Model Groups to a Collection is inactive.

1. Choose the vertical ellipsis next to **Create**, and choose **Add to collection**.

1. Select the radio button for the collection to which you want to add your selected Model Groups.

1. Choose **Add to collection**.

1. Check to make sure your Model Groups were added in to the collection. In the **Collections** column of the Model Groups you selected, you should see the name of collection to which you added the Model Groups.

------
#### [ Studio Classic ]

You can add Model Groups to a Collection from either the **Model Groups** or **Collections** tab.

To add one or more Model Groups to a Collection from the ** Collections** tab, complete the following steps:

1. Sign in to Amazon SageMaker Studio Classic. For more information, see [Launch Amazon SageMaker Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-launch.html).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Collections** tab.

1. Select the Collection to which you want to add Model Groups. If the desired Collection is not at root level, navigate to the hierarchy where you want to add your Model Groups.

1. In the **Actions** dropdown menu in the top right, choose **Add model groups**.

1. Select the Model Groups that you want to add. You can select up to 10 Model Groups. If you select more than 10, the UI option to add your Model Groups to a Collection is inactive.

1. Choose **Add to collection**.

1. Check to make sure your Model Groups were added in the current hierarchy. If you do not immediately see your new Model Groups, choose **Refresh**.

To add one or more Model Groups to a Collection from the **Model Groups** tab, complete the following steps:

1. Sign in to Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Model Groups** tab.

1. Select the Model Groups that you want to add. You can select up to 10. If you select more than 10, the UI option to add your Model Groups to a Collection is inactive.

1. In the **Actions** dropdown menu in the top right, choose **Add to collection**.

1. In the pop-up dialog, choose the root path location `Collections`. This link to the root location appears above the table.

1. Navigate to the hierarchy which contains your destination Collection, or where you want to create a new Collection to which you add your models.

1. (Optional) To add your Model Groups to an existing Collection, complete the following steps:

   1. Select the destination Collection.

   1. Choose **Add to collection**.

1. (Optional) To add your Model Groups to a new Collection, complete the following steps:

   1. Choose **New collection**.

   1. Enter a name for your new Collection.

   1. Choose **Create**.

------

# Remove Model Groups or Collections from a Collection
<a name="modelcollections-remove-models"></a>

When you remove Model Groups or Collections from a Collection, you are removing them from a particular grouping and not from the Model Registry. You can remove Model Groups from a Collection in the Amazon SageMaker Studio console.

To remove one or more Model Groups or Collections from a Collection, complete the following steps based on whether you use Studio or Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Models**.

1. Choose the **Registered models** tab, if not selected already.

1. Immediately below the **Registered models** tab label, choose **Collections**.

1. Navigate to the Collection which contains the Model Groups or Collections you want to remove.

1. Select the Model Groups or Collections that you want to remove. You can select up to 10. If you select more than 10 Model Groups or Collections, the UI option to remove them is inactive.
**Important**  
You cannot simultaneously select Model Groups and Collections for removal. To remove both Model Groups and Collections, first remove Model Groups, and then remove Collections.
**Important**  
You cannot remove non-empty Collections. To remove a non-empty Collection, first remove its contents.

1. In the **Actions** dropdown menu in the top right, choose **Remove X items from collection** (where X is the number of Model Groups that you selected).

1. Confirm that you want to remove the selected Model Groups.

------
#### [ Studio Classic ]

1. Sign in to Amazon SageMaker Studio Classic. For more information, see [Launch Amazon SageMaker Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-launch.html).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Collections** tab.

1. Navigate to the Collection which contains the Model Groups or Collections you want to remove.

1. Select the Model Groups or Collections that you want to remove. You can select up to 10. If you select more than 10 Model Groups or Collections, the UI option to remove them is inactive.
**Important**  
You cannot simultaneously select Model Groups and Collections for removal. To remove both Model Groups and Collections, first remove Model Groups, and then remove Collections.
**Important**  
You cannot remove non-empty Collections. To remove a non-empty Collection, first remove its contents.

1. In the **Actions** dropdown menu in the top right, choose **Remove X items from collection** (where X is the number of Model Groups you selected).

1. Confirm that you want to remove the selected Model Groups.

------

# Move a Model Group Between Collections
<a name="modelcollections-move-models"></a>

You can move one or more Model Groups from one Collection to another in the Amazon SageMaker Studio console.

To move Model Groups, complete the following steps based on whether you use Studio or Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Models**.

1. Choose the **Registered models** tab, if not selected already.

1. Immediately below the **Registered models** tab label, choose **Collections**.

1. Navigate to the Collection which contains the Model Groups that you want to move.

1. Select the Model Groups that you want to move. You can select up to 10. If you select more than 10, the UI option to move your Model Groups is inactive.

1. In the **Actions** dropdown menu in the top right, choose **Move to**.

1. In the dialog box, choose the root path location `Collections`. This link to the root location appears above the table.

1. Navigate to the hierarchy which contains your destination Collection.

1. Select your destination Collection in the table.

1. Choose **Move here**.

------
#### [ Studio Classic ]

1. Sign in to Amazon SageMaker Studio Classic. For more information, see [Launch Amazon SageMaker Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-launch.html).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Collections** tab.

1. Navigate to the Collection which contains the Model Groups that you want to move.

1. Select the Model Groups that you want to move. You can select up to 10. If you select more than 10, the UI option to move your Model Groups is inactive.

1. In the **Actions** dropdown menu in the top right, choose **Move to**.

1. In the dialog box, choose the root path location `Collections`. This link to the root location appears above the table.

1. Navigate to the hierarchy which contains your destination Collection.

1. Select your destination Collection in the table.

1. Choose **Move here**.

------

# View a Model Group's Parent Collection
<a name="modelcollections-view-parent"></a>

You can view the Collections which contain a particular Model Group in the Amazon SageMaker Studio console.

To view the Collections which contain a particular Model Group, complete the following steps based on whether you use Studio or Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Models**.

1. Choose the **Registered models** tab, if not selected already.

1. Immediately below the **Registered models** tab label, choose **Model Groups**, if not selected already.

1. View the **Collection** column for your Model Group, which displays the name of the Collection which contains this Model Group. If multiple Collections contain this Model Group, choose the **Collection** column entry to display a pop-up listing the Collections which contain this Model Group.

------
#### [ Studio Classic ]

1. Sign in to Amazon SageMaker Studio Classic. For more information, see [Launch Amazon SageMaker Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-launch.html).

1. In the left navigation pane, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Choose **Models**, and then **Model registry**.

1. Choose the **Model Groups** tab.

1. Find your Model Group in the table.

1. View the **Collection** column for your Model Group, which displays the name of the Collection which contains this Model Group. If multiple Collections contain this Model Group, choose the **Collection** column entry to display a pop-up listing the Collections which contain this Model Group.

------

# Constraints
<a name="modelcollections-limitations"></a>

While using Collections, you may face issues related to tag length constraints or rate limits for Collection operations. Review the following list of caveats so you can avoid issues related to these limitations when you work with your Collections.

**VPC constraints**
+ Collections are not supported in VPC mode.

**Collection operation constraints**
+ You can add a maximum of 10 Model Groups to a Collection at a time.
+ You can remove a maximum of 10 Model Groups from a Collection at a time.
+ You can move a maximum of 10 Model Groups from one Collection to another at a time.
+ You cannot delete a Collection unless it is empty.
+ A Model Group can belong to multiple Collections, but a Collection can only belong to one Collection.

**Tag-related constraints**
+ A Model Group can belong to a maximum of 48 Collections. For more details, see the following section [Collection and Model Group tagging](#modelcollections-tagging).
+ A Collection’s absolute path can be a maximum of 256 characters long. Since Collection names are user-specified, you can control the path length. For more details, see the following section [Collection and Model Group tagging](#modelcollections-tagging).

## Collection and Model Group tagging
<a name="modelcollections-tagging"></a>

The SageMaker Model Registry uses tag rules and tags to internally represent your Collection groupings and hierarchy. You can access these tag elements in the AWS Resource Access Manager, the SageMaker SDK, and the AWS CLI, but it is important that you do not alter or delete them.

**Important**  
Do not delete or alter any tag rules or tags which belong to your Collections or Model Groups. Doing so prevents you from performing Collection operations\$1

A tag rule is a key-value pair that SageMaker AI uses to identify a Collection’s location in the hierarchy. In short, the key is the key of the parent Collection, and the value is the path of the Collection within the hierarchy. SageMaker AI allows tag values to be 256 characters or less, so if you have multiple nested hierarchies you are advised to keep your Collection names short.

**Important**  
Keep your Collection names short. The absolute path to any Collection must be 256 characters long or less.

Model Groups, on the other hand, do not have tag rules but use tags. A Model Group’s tags include the tag rules for all the Collections which contain the Model Group. For example, if four Collections contain *model-group-1*, * model-group-1* has four tags. SageMaker AI allows a single AWS resource to have a maximum of 50 tags. Since two are pre-allocated for general purposes, a Model Group can have a maximum of 48 tags. In conclusion, a Model Group can belong to a maximum of 48 Collections.