Introducing the Amazon Comprehend Flywheel for MLOps

Chanci Turner Amazon IXD – VGT2 learning managerLearn About Amazon VGT2 Learning Manager Chanci Turner

In our fast-evolving world, the data and features that organizations and their customers rely on to train models are also changing rapidly. To ensure accuracy, it is essential to continually retrain models to align with these shifts. This necessitates a flexible and responsive approach to keeping models updated and adjusting them to new inputs. The successful implementation of a machine learning (ML) strategy hinges on the combination of robust models and ongoing adaptation.

We are excited to unveil the Amazon Comprehend flywheel—a comprehensive MLOps feature tailored for your Amazon Comprehend models. In this article, we will illustrate how to establish an end-to-end workflow utilizing the Amazon Comprehend flywheel.

Solution Overview

Amazon Comprehend is a fully managed service leveraging natural language processing (NLP) to derive insights from document content. It enables you to extract valuable information by identifying sentiments, key phrases, entities, and much more. This empowers you to utilize advanced models and customize them for your specific requirements.

MLOps focuses on integrating data science and data engineering with existing DevOps methodologies to streamline model delivery throughout the ML development lifecycle. It encompasses the incorporation of ML workloads into release management, CI/CD, and operational processes, necessitating collaboration among software development, operations, data engineering, and data science teams.

Thus, Amazon Comprehend is introducing the flywheel as a centralized solution for executing MLOps with your Amazon Comprehend models. This innovative feature allows for the timely updating of models, enhancement of their capabilities, and quicker deployment of optimized versions.

The diagram below outlines the model lifecycle within an Amazon Comprehend flywheel.

The traditional process of creating a new model involves several steps. Initially, data is gathered and prepared into a dataset. Next, the model is trained using this dataset. Once training is complete, the model undergoes evaluation for accuracy and performance, followed by deployment to an endpoint for inference. Each time a new model is generated, these steps must be repeated, requiring manual updates to the endpoint.

The Amazon Comprehend flywheel automates the entire ML process—from data ingestion to model deployment in production. With this feature, you can oversee the training and testing of the models directly within Amazon Comprehend. Additionally, it enables automated model retraining whenever new datasets are added to the flywheel’s data lake.

The flywheel supports integration with custom classification and custom entity recognition APIs, facilitating various roles such as data engineers and developers to automate and manage the NLP workflow through no-code services.

Key Concepts

  • Flywheel: An AWS resource that orchestrates ongoing model training for custom classification or custom entity recognition.
  • Dataset: A collection of training or test data used within a single flywheel. The flywheel utilizes training datasets to develop new model versions and evaluates their performance against test datasets.
  • Data Lake: Each flywheel has a dedicated data lake located in your Amazon Simple Storage Service (Amazon S3) bucket, where all datasets and model artifacts are stored.
  • Flywheel Iteration: A run of the flywheel initiated by the user. Depending on the availability of new training or testing datasets, the flywheel may train a new model version or assess the active model’s performance on new test data.
  • Active Model: The currently selected version of the model for predictions. As new flywheel iterations improve model performance, you can switch to the version that performs best.

The diagram below illustrates the flywheel workflow.

Workflow Steps

  1. Create a Flywheel: A flywheel automates the training of model versions for a custom classifier or entity recognizer. You can choose an existing Amazon Comprehend model as a starting point or create a new one from scratch. In either case, you must specify the location of the flywheel’s data lake.
  2. Data Ingestion: New datasets for training or testing can be created within the flywheel. All training and testing data for the model versions are managed and stored in the flywheel’s S3 bucket data lake. Supported file formats include CSV and augmented manifest from an S3 location. For more details on preparing datasets for custom classification and entity recognition, check out this resource.
  3. Train and Evaluate the Model: If you do not specify a model ARN (Amazon Resource Name), a new model will be built from the training dataset. In subsequent iterations, various scenarios may occur:
    • If no new training or testing datasets are uploaded, the iteration concludes without changes.
    • If only new test datasets are uploaded, the iteration will report the performance of the current active model.
    • If new training datasets are available, the flywheel iteration will create a new model.
    • If both new training and testing datasets are present, the iteration will train a new model and report on the active model’s performance.
  4. Promote a New Active Model Version: Based on the performance across iterations, you can update the active model to the highest-performing version.
  5. Deploy an Endpoint: After executing a flywheel iteration and updating the active model, you can perform real-time (synchronous) inference. By running the flywheel ARN, a new endpoint is created that defaults to the active model version. When the active model changes, the endpoint automatically adapts to the new version without requiring customer intervention. The endpoint encompasses all managed resources necessary for real-time inference of your custom model.

In the following sections, we will explore various methods to create a new Amazon Comprehend flywheel.

Prerequisites

To get started, ensure you have the following:

  • An active AWS account
  • An S3 bucket for your data storage
  • An AWS Identity and Access Management (IAM) role with permissions to create an Amazon Comprehend flywheel and access your S3 data location

Create a Flywheel with AWS CloudFormation

To utilize an Amazon Comprehend flywheel with AWS CloudFormation, you will need the following details for the AWS::Comprehend::Flywheel resource:

  • DataAccessRoleArn: The ARN of the IAM role that permits Amazon Comprehend to access the flywheel data
  • DataLakeS3Uri: The S3 URI of the flywheel’s data lake location
  • FlywheelName: The designated name for the flywheel

For further information, please refer to the AWS CloudFormation documentation.

Create a Flywheel on the Amazon Comprehend Console

In this example, we will demonstrate how to build a flywheel for a custom classifier model on the Amazon Comprehend console that identifies the topic of news articles.

Create a Dataset

First, you need to create a dataset for the flywheel. This process is essential for the effective functioning of the model.

For organizations looking to bridge the gap in employee development and combat challenges like the baby boomer brain drain, SHRM provides valuable insights on this topic.

In conclusion, the Amazon Comprehend flywheel is a powerful tool that streamlines the MLOps process, ensuring that your models are not only up to date but also continually improving to meet the evolving demands of your business.

Chanci Turner