AWS Machine Learning Blog 前天 00:35
Bridging the gap between development and production: Seamless model lifecycle management with Amazon Bedrock
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文深入探讨了亚马逊Bedrock推出的Model Share(模型共享)和Model Copy(模型复制)功能,旨在简化AI模型的开发、部署和管理流程。通过这两个功能,用户可以在不同AWS账户和区域之间高效地共享和复制自定义模型,从而优化资源利用、增强团队协作,并提升AI应用的性能和可靠性。文章详细介绍了这两个功能的工作原理、优势以及实际应用场景,为构建全球分布式AI基础设施提供了有力的支持。

🤝 **Model Share(模型共享)**:该功能允许在同一组织内的不同AWS账户之间共享在Amazon Bedrock上微调的自定义模型。这简化了从开发到生产环境的模型迁移过程,增强了团队协作,并优化了资源利用,尤其适用于维护独立开发和生产环境的组织。

🌍 **Model Copy(模型复制)**:此功能支持在同一账户的不同区域内复制自定义模型。它主要用于优化全球模型部署、区域负载均衡和灾难恢复。通过将模型分布在不同区域,Model Copy有助于提高AI应用的性能和可靠性,并支持区域合规性要求。

🔑 **先决条件和重要考虑事项**:在使用Model Share和Model Copy之前,需要满足一定的先决条件,包括AWS Organizations的设置、IAM权限的配置、KMS密钥策略的设置(可选)以及网络配置等。同时,文章也强调了在共享和复制加密模型时,需要正确配置密钥策略,以确保安全。

💡 **应用场景**:Model Share适用于在不同AWS账户之间共享模型,例如从开发账户到生产账户的迁移。Model Copy既可以单独使用,用于在同一账户内跨区域部署模型,也可以与Model Share结合使用,构建更强大的全球分布式AI基础设施。

In the landscape of generative AI, organizations are increasingly adopting a structured approach to deploy their AI applications, mirroring traditional software development practices. This approach typically involves separate development and production environments, each with its own AWS account, to create logical separation, enhance security, and streamline workflows.

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies such as AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI. As organizations scale their AI initiatives, they often face challenges in efficiently managing and deploying custom models across different stages of development and across geographical regions.

To address these challenges, Amazon Bedrock introduces two key features: Model Share and Model Copy. These features are designed to streamline the AI development lifecycle, from initial experimentation to global production deployment. They enable seamless collaboration between development and production teams, facilitate efficient resource utilization, and help organizations maintain control and security throughout the customized model lifecycle.

In this comprehensive blog post, we’ll dive deep into the Model Share and Model Copy features, exploring their functionalities, benefits, and practical applications in a typical development-to-production scenario.

Prerequisites for Model Copy and Model Share

Before you can start using Model Copy and Model Share, the following prerequisites must be fulfilled:

    AWS Organizations setup: Both the source account (the account sharing the model) and the target account (the account receiving the model) must be part of the same organization. You’ll need to create an organization if you don’t have one already, enable resource sharing, and invite the relevant accounts. IAM permissions:  KMS key policies (Optional): If your models are encrypted with a customer-managed KMS key, you’ll need to set up key policies to allow the target account to decrypt the shared model or to encrypt the copied model with a specific KMS key. Network configuration: Make sure that the necessary network configurations are in place, especially if you’re using VPC endpoints or have specific network security requirements. Service quotas: Check and, if necessary, request increases for the number of custom models per account service quotas in both the source and target Regions and accounts. Provisioned throughput support: Verify that the target Region supports provisioned throughput for the model you intend to copy. This is crucial because the copy job will be rejected if provisioned throughput isn’t supported in the target Region.

Model Share: Streamlining development-to-production workflows

The following figure shows the architecture of Model Share and Model Copy. It consists of a source account where the model is fined tuned. Next, Amazon Bedrock shares it with the recipient account which accepts the shared model in AWS Resource Access Manager (RAM). Then, the shared model can be copied to the desired AWS Region.

When managing Amazon Bedrock custom models in a development-to-production pipeline, it’s essential to securely share these models across different AWS accounts to streamline the promotion process to higher environments. The Amazon Bedrock Model Share feature addresses this need, enabling smooth sharing between development and production environments. Model Share enables the sharing of custom models fine-tuned on Amazon Bedrock between different AWS accounts within the same Region and organization. This feature is particularly useful for organizations that maintain separate development and production environments.

Important considerations: 

Key benefits: 

How it works: 

    After a model has been fine-tuned in the source AWS account using Amazon Bedrock, the source AWS account can use the AWS Management Console for Amazon Bedrock to share the model. The target AWS account accepts the shared model in AWS RAM. The shared model in the target AWS account needs to be copied to the desired Regions. After copying, the target AWS account can purchase provisioned throughput and use the model. If using KMS encryption, make sure the key policy is properly set up for the recipient account.

Model Copy: Optimizing model deployment across Regions

The Amazon Bedrock Model Copy feature enables you to replicate custom models across different Regions within your account. This capability serves two primary purposes: it can be used independently for single-account deployments, or it can complement Model Share in multi-account scenarios, where you first share the model across accounts and then copy it. The feature is particularly valuable for organizations that require global model deployment, Regional load balancing, and robust disaster recovery solutions. By allowing flexible model distribution across Regions, Model Copy helps optimize your AI infrastructure for both performance and reliability.

Important considerations: 

Key benefits of Model Copy: 

How it works: 

    Identify the target Region where you want to deploy your model. Use the Amazon Bedrock console to initiate the Model Copy process from the source Region to the target Region. After the model has been copied, purchase provisioned throughput for the model in each Region where you want to use it. If using KMS encryption, make sure the key policy is properly set up for the role performing the copy operation.

Use cases: 

By using Model Copy, either on its own or in tandem with Model Share, you can create a robust, globally distributed AI infrastructure. This flexibility offers low-latency access to your custom models across different geographical locations, enhancing the performance and reliability of your AI-powered applications regardless of your account structure.

Aligning Model Share and Model Copy with AWS best practices

When implementing Model Share and Model Copy, it’s crucial to align these features with AWS best practices for multi-account environments. AWS recommends setting up separate accounts for development and production, which makes Model Share particularly valuable for transitioning models between these environments. Consider how these features interact with your organizational structure, especially if you have separate organizational units (OUs) for security, infrastructure, and workloads. Key considerations include:

By aligning Model Share and Model Copy with these best practices, you can enhance security, compliance, and operational efficiency in your AI model lifecycle management. For more detailed guidance, see the AWS Organizations documentation.

From development to production: A practical use case

Let’s walk through a typical scenario where Model Copy and Model Share can be used to streamline the process of moving a custom model from development to production.

Step 1: Model development (development account)

In the development account, data scientists fine-tune a model on Amazon Bedrock. The process typically involves:

    Experimenting with different FMs Performing prompt engineering Fine-tuning the selected model with domain-specific data Evaluating model performance on the specific task Applying Amazon Bedrock Guardrails to make sure that the model meets ethical and regulatory standards

The following example fine-tunes an Amazon Titan Text Express model in the US East (N. Virginia) Region (us-east-1).

# Example: Fine-tuning a model in the development accountimport boto3bedrock = boto3.client(service_name='bedrock')    # Set parameterscustomizationType = "FINE_TUNING"baseModelIdentifier = "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-text-express-v1"roleArn = "${your-customization-role-arn}"jobName = "MyFineTuningJob"customModelName = "MyCustomModel"hyperParameters = {        "epochCount": "1",        "batchSize": "1",        "learningRate": ".0005",        "learningRateWarmupSteps": "0"    }trainingDataConfig = {"s3Uri": "s3://${training-bucket}/myInputData/train.jsonl"}outputDataConfig = {"s3Uri": "s3://${output-bucket}/myOutputData"}# Create jobresponse = bedrock.create_model_customization_job(    jobName=jobName,     customModelName=customModelName,    roleArn=roleArn,    baseModelIdentifier=baseModelIdentifier,    hyperParameters=hyperParameters,    trainingDataConfig=trainingDataConfig,    outputDataConfig=outputDataConfig) job_arn = response['jobArn']print(f"Model customization job created: {job_arn}")

Step 2: Model evaluation and selection

After the model is fine-tuned, the development team evaluates its performance and decides if it’s ready for production use.

# Example: Evaluating the fine-tuned modelbedrock_runtime = boto3.client('bedrock-runtime') response = bedrock_runtime.invoke_model(    modelId=customModelName,    contentType="application/json",    accept="application/json",    body=json.dumps({        "prompt": "Your LLM as judge prompt go here",        "max_tokens_to_sample": 500    })) result = json.loads(response['body'].read())print(f"Model output: {result['completion']}")

Step 3: Model sharing (development to production account)

After the model is approved for production use, the development team uses Model Share to make it available to the production account. Remember, this step is only applicable for fine-tuned models created within Amazon Bedrock, not for custom models imported using custom model import.

# Example: Sharing the model with the production accountram = boto3.client('ram')response = ram.create_resource_share(    name='financial-analyst-model-share',    resourceArns=['arn:aws:bedrock:us-east-1:{dev-account-id}:model/custom-financial-analyst-model'],    principals=['production-account-id'],    allowExternalPrincipals=False) share_arn = response['resourceShare']['resourceShareArn']print(f"Resource share created: {share_arn}"

Step 4: Model Copy (production account)

The production team, now with access to the shared model, must first copy the model to their desired Region before they can use it. This step is necessary even for shared models, because sharing alone doesn’t make the model usable in the target account.

# Example: Copying the model to the production account's desired regionbedrock = boto3.client('bedrock', region_name='us-west-2') # Check if the target region supports provisioned throughput for this model# This check is not provided by the API and would need to be implemented separately response = bedrock.create_model_copy_job(    sourceModelArn='arn:aws:bedrock:us-east-1:{dev-account-id}:model/custom-financial-analyst-model',    targetModelName='financial-analyst-model-us-west-2',    targetRegion='us-west-2') job_arn = response['jobArn']print(f"Model copy job created: {job_arn}"

Step 5: Production deployment

Finally, after the model has been successfully copied, the production team can purchase provisioned throughput and set up the necessary infrastructure for inference.

# Example: Setting up provisioned throughput and inference endpoint in productionbedrock = boto3.client('bedrock', region_name='us-west-2') # Purchase provisioned throughputresponse = bedrock.create_provisioned_model_throughput(    modelId='financial-analyst-model-us-west-2',    provisionedUnits=1) # Set up inference endpointresponse = bedrock.create_model_invocation_endpoint(    modelId='financial-analyst-model-us-west-2',    endpointName='financial-analyst-endpoint',    instanceType='ml.g4dn.xlarge',    instanceCount=2) endpoint_arn = response['endpointArn']print(f"Inference endpoint created: {endpoint_arn}" 

Conclusion

Amazon Bedrock Model Copy and Model Share features provide a powerful option for managing the lifecycle of an AI application from development to production. These features enable organizations to:

As the field of AI continues to evolve, these tools are crucial for organizations to stay agile, efficient, and competitive. Remember, the journey from development to production is iterative, requiring continuous monitoring, evaluation, and refinement of models to maintain ongoing effectiveness and alignment with business needs.

By implementing the best practices and considerations outlined in this post, you can create a robust, secure, and efficient workflow for managing your AI models across different environments and Regions. This approach will accelerate your AI development process and maximize the value of your investments in model customization and fine tuning. With the features provided by Amazon Bedrock, you’re well-equipped to navigate the complexities of AI model management and deployment successfully.


About the Authors

Ishan Singh is a Generative AI Data Scientist at Amazon Web Services, where he helps customers build innovative and responsible generative AI solutions and products. With a strong background in AI/ML, Ishan specializes in building Generative AI solutions that drive business value. Outside of work, he enjoys playing volleyball, exploring local bike trails, and spending time with his wife and dog, Beau.

Neeraj Lamba is a Cloud Infrastructure Architect with Amazon Web Services (AWS) Worldwide Public Sector Professional Services. He helps customers transform their business by helping design their cloud solutions and offering technical guidance. Outside of work, he likes to travel, play Tennis and experimenting with new technologies.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

亚马逊Bedrock 模型共享 模型复制 AI部署
相关文章