Connect with us

Amazon

Detect anomalies using Amazon Lookout for Metrics and review inference through Amazon A2I

Proactively detecting unusual or unexpected variances in your business metrics and reducing false alarms can help you stay on top of sudden changes and improve your business performance. Accurately identifying the root cause of deviation from normal business metrics and taking immediate steps to remediate an anomaly can not only boost user engagement but also…

Published

on

Proactively detecting unusual or unexpected variances in your business metrics and reducing false alarms can help you stay on top of sudden changes and improve your business performance. Accurately identifying the root cause of deviation from normal business metrics and taking immediate steps to remediate an anomaly can not only boost user engagement but also improve customer experience.

As the volume of data monitored by your business grows, detecting anomalies gets challenging. On March 25, 2021, AWS announced the general availability of Amazon Lookout for Metrics, a service that uses machine learning (ML) to automatically detect anomalies that are most important to businesses with greater speed and accuracy, and identifies their root cause.

ML models often need human oversight to retrain and continuously improve model accuracy. In this post, we show how you can set up Lookout for Metrics to train a model to detect anomalies. We then use a human-in-the-loop workflow to review the predictions using Amazon Augmented AI (Amazon A2I), and use the feedback to improve model accuracy.

Solution overview

Lookout for Metrics uses ML to automatically detect and diagnose anomalies (outliers from the norm) in business and operational data, such as a sudden dip in sales revenue or customer acquisition rates. In a couple of clicks, you can connect Lookout for Metrics to popular data stores like Amazon Simple Storage Service (Amazon S3), Amazon Redshift, and Amazon Relational Database Service (Amazon RDS), as well as third-party software as a service (SaaS) applications such as Salesforce, ServiceNow, Zendesk, and Marketo, and start monitoring metrics that are important to your business.

Lookout for Metrics automatically inspects and prepares the data from these sources to detect anomalies with greater speed and accuracy than traditional methods used for anomaly detection. You can also provide feedback on detected anomalies to tune the results and improve accuracy over time. Lookout for Metrics makes it easy to diagnose detected anomalies by grouping together anomalies that are related to the same event and sending an alert that includes a summary of the potential root cause. It also ranks anomalies in order of severity so you can prioritize your attention to what matters most to your business.

Amazon A2I is an ML service that makes it easy to build the workflows required for human review. Amazon A2I brings human review to all developers, removing the undifferentiated heavy lifting associated with building human review systems or managing large numbers of human reviewers, whether running on AWS or not.

To get started with Lookout for Metrics, we create a detector, create and attach a dataset with metrics that you want to train on and monitor, activate the detector, and view anomalies. Following these steps, we show how you can set up a human review workflow using Amazon A2I. Finally, it updates the detector with human review feedback, which helps retrain the model and further improve accuracy.

Architecture overview

The following diagram illustrates the solution architecture.

The solution has the following workflow:

  1. Upload data from your source to Amazon S3.
  2. We run Lookout for Metrics in continuous mode to process data continuously from the Amazon S3 path.
  3. Inference results are stored in Amazon S3
  4. When Lookout for Metrics detects anomalies, the inference input and outputs are presented to the private workforce for validation via Amazon A2I.
  5. A private workforce investigates and validates the detected anomalies and provides feedback.
  6. We update the results with corresponding feedback from human loop through Amazon A2I.
  7. Updated feedback improves accuracy of future trainings.

In the accompanying Jupyter notebook downloadable from GitHub, we walk you through the following steps:

  1. Generate a synthetic dataset.
  2. Create a detector and map measures and dimensions to metrics.
  3. Activate the detector.
  4. Detect anomalies.
  5. Set up Amazon A2I to review predictions from Lookout for Metrics.
  6. Update the model based on output from human loop through Amazon A2I.

Prerequisites

Before you get started, complete the following steps to set up the Jupyter notebook:

  1. Create a notebook instance in Amazon SageMaker.
  2. When the notebook is active, choose Open Jupyter.
  3. On the Jupyter dashboard, choose New, and choose Terminal.
  4. In the terminal, enter the following code:

git clone https://github.com/aws-samples/amazon-lookout-for-metrics-a2i-integration.git

  1. Open the notebook for this post from next_steps/A2I_Integration:

Amazon_L4M_Detector_A2I.ipynb

You’re now ready to run the notebook cells. Run the environment setup step to set up the necessary Python SDKs and libraries, S3 bucket, and Region that we use throughout the notebook. Make sure that the SageMaker Studio IAM role has the necessary permissions.

NOTE: The code uses Python 3.7. Please use the Python 3 (Data Science) kernel for this notebook.

Generate synthetic data

In this section, we generate synthetic data for the detector and for predicting anomalies. The metrics data is aggregated on an hourly basis, and the detector runs in continuous mode in real time, every hour. In this example, we use the detector to detect anomalies. Starting from the current date, we generate data for 6 months in the past and 3 days in the future. The historical data is used for training the model, and we use the current and future data for predicting anomalies on an ongoing basis. Note the following configuration:

  • Historical data is created as a CSV file called ./data/ecommerce/backtest/input.csv
  • Hourly data files are stored in the folder ./data/ecommerce/live///.csv
  • Complete data along with the anomaly labels is available in ./data/ecommerce/label.csv

Access the notebook section generate synthetic data and run the cells. Then inspect the DataFrame:

backtest_df = pd.read_csv(‘data/ecommerce/backtest/input.csv’) backtest_df.head()

Data points are generated in a random manner, so your response might look different than the following screenshot.

Save the data to the S3 bucket previously created:

%%time !aws s3 sync {DIR_PATH}/{DATASET_NAME}/ s3://{bucket_name}/{DATASET_NAME}/ —quiet —delete

Create a detector and map measures and dimensions to metrics

A detector is a Lookout for Metrics resource that monitors a dataset and identifies anomalies. To detect outliers, Lookout for Metrics builds an ML model that is trained with your source data. This model is automatically trained with the ML algorithm that best fits your data and use case. Access the notebook section Create Lookout for Metrics Detector and run the cell to create a detector:

if len(ecom_anomaly_detector_arn) == 0: # Detector for ecommerce example does not exists. Create the anomaly detector. create_anomaly_detector_response = L4M.create_anomaly_detector( AnomalyDetectorName = ecom_anomaly_detector_name, AnomalyDetectorDescription = “Anomaly detection on a sample ecommerce dataset.”, AnomalyDetectorConfig = { “AnomalyDetectorFrequency” : FREQUENCY, }, )

You get the following response:

Anomaly Detector ARN: arn:aws:lookoutmetrics:[REGION]:[ACCOUNT NUMBER]:AnomalyDetector:ecommerce-continuous-detector

Measures are the primary fields that the detector monitors. You can also configure up to five additional fields as dimensions. Dimensions are secondary fields that create subgroups of measures based on their value.

In this ecommerce example, views and revenue are our measures and platform and marketplace are our dimensions. You may want to monitor your data for anomalies in number of views or revenue for every platform, marketplace, and combination of both.

Each combination of measure and dimension is called a metric. Measures, dimensions, and metrics map to datasets, which also contain the Amazon S3 locations of your source data, an AWS Identity and Access Management (IAM) role that has both read and write permissions to those Amazon S3 locations, and the rate at which data should be ingested from the source location (the upload frequency and data ingestion delay). Run the cells in the Measures and Dimensions section to create a metric set for your detector that points to the live data in Amazon S3:

create_metric_set_response = L4M.create_metric_set( ** params ) ecom_metric_set_arn = create_metric_set_response[“MetricSetArn”]

You get the following response:

Metric Set ARN: arn:aws:lookoutmetrics:::MetricSet/ecommerce-continuous-detector/ecommerce-metric-set-1

Activate your detector

Now it’s time to activate your detector. During activation, the model is trained with historical data that was generated in a previous cell and stored in the ./data/ecommerce/backtest folder. Run the cells under Activate the Detector:

if ecom_detector_status in [“INACTIVE”, “ACTIVATING”]: # Activate the detector if ecom_detector_status == “INACTIVE”: L4M.activate_anomaly_detector(AnomalyDetectorArn = ecom_anomaly_detector_arn) print(“nActivating ecommerce example Detector.”)

You get the following response:

Activating ecommerce example Detector. Detector status: ACTIVATING … Detector status: ACTIVATING … Detector status: LEARNING … Detector status: ACTIVE

You can also check the status of your detector on the Lookout for Metrics console.

Detect anomalies

In this section, you review the anomalies found by the detector. We have created a continuous detector that operates on live data. It expects to receive input data every hour. We already generated some data into the future, which is in the ./data/ecommerce/live folder. Run the cell from the notebook section Fetch Anomalies to detect anomalies:

…. if next_token: params[“NextToken”] = next_token response = L4M.list_anomaly_group_summaries(**params ) print(“Anomaly group summaries:n {}”.format(response)) anomaly_groups += response[“AnomalyGroupSummaryList”] print(‘ntype of AnomalyGroupSummaryList: {}’.format(type(anomaly_groups)))

You get the following response:

You may have to wait for the detector to run at the top of the hour to detect anomalies. So, if no anomalies are found when running the next cell, you may want to come back later and run it again.

Set up Amazon A2I to review predictions from Lookout for Metrics

In this section, you set up a human review loop for low-confidence detection in Amazon A2I. It includes the following steps:

  1. Create a private workforce.
  2. Create a human task UI.
  3. Create a human task workflow.
  4. Send predictions to Amazon A2I human loops.
  5. Complete your review and check the human loop status.

Create a private workforce

You must create a private workforce on the SageMaker console. For instructions, see Create an Amazon Cognito Workforce Using the Labeling Workforces Page. Once created, note the ARN of the workforce and enter its value in the notebook cell:

WORKTEAM_ARN = ‘your private workforce team ARN’

Create a human task UI

You now create a human task UI resource, giving a UI template in liquid HTML. This HTML page is rendered to the human workers whenever a human loop is required. For over 70 pre-built UIs, see the amazon-a2i-sample-task-uis GitHub repo.

Follow the steps provided in the notebook section Create a human task UI to create the web form and initialize the Amazon A2I APIs:

… if not describe_human_task_ui_response: # Create the human task UI create_human_task_ui_response = sagemaker_client.create_human_task_ui( HumanTaskUiName=l4m_taskUIName, UiTemplate={‘Content’: ecom_a2i_template}) print(“nCreate human task ui response: “) pprint.pprint(create_human_task_ui_response, width = 2) …

You get the following response:

Human task UI ARN: arn:aws:sagemaker:[REGION]:[ACCOUNT NUMBER]:human-task-ui/l4m-ecommerce-ui

Create a human task workflow

Workflow definitions allow you to specify the following:

  • The worker template or human task UI you created in the previous step.
  • The workforce that your tasks are sent to. For this post, it’s the private workforce you created in the prerequisite steps.
  • The instructions that your workforce receives.

This post uses the Create Flow Definition API to create a workflow definition. The results of the human review are stored in an S3 bucket, which can be accessed by the client application. Run the cell Create a Human task Workflow in the notebook:

… if not describe_flow_definition_response: create_workflow_definition_response = sagemaker_client.create_flow_definition( FlowDefinitionName = l4m_flowDefinitionName, RoleArn=sagemaker_role_arn, HumanLoopConfig= { “WorkteamArn”: workteam_ARN, “HumanTaskUiArn”: l4m_review_ui_arn, “TaskCount”: 1, “TaskDescription”: “Review the anomalies detected by Amazon Lookout for Metrics”, “TaskTitle”: “Ecommerce Anomalies Review” }, OutputConfig={ “S3OutputPath” : s3_output_path } ) …

You get the following response:

S3 output path: s3://[ACCOUNT NUMBER]-[REGION]-lookoutmetrics-lab/ecommerce/a2i-results Flow definition Arn: arn:aws:sagemaker:[REGION]:[ACCOUNT NUMBER]:flow-definition/l4m-ecommerce-workflow

Send predictions to Amazon A2I human loops

Run cells in the start human review loop section to find the URL of a portal for providing feedback on anomalies. Open the URL in a browser and log in with the credentials of the human review worker. You should have sent an invitation email to a worker for joining the work team when you created the work team on the Amazon A2I console. Complete the review from the portal and inspect the output:

…. start_human_loop_response = a2i_client.start_human_loop( HumanLoopName=humanLoopName, FlowDefinitionArn=flowDefinitionArn, HumanLoopInput={ “InputContent”: json.dumps(ip_content) } ) print(“nStart human loop response: “) #pprint.pprint(start_human_loop_response, width=2)

Complete the review and check the human loop status

Complete your review and check the human loop status with the following code:

… try: describe_human_loop_response = a2i_client.describe_human_loop(HumanLoopName=humanLoopName) print(“nDescribe human loop response: “) pprint.pprint(describe_human_loop_response, width=2) completed_human_loops_s3_output = describe_human_loop_response[“HumanLoopOutput”][“OutputS3Uri”] print(“HumanLoop Status: {}”.format(describe_human_loop_response[“HumanLoopStatus”])) except: print(“Error getting human loop”) #print(“nHumanLoop Name: {}”.format(humanLoopName)) #print(“HumanLoop Status: {}”.format(describe_human_loop_response[“HumanLoopStatus”])) print(“nOutput in S3 at: n{}”.format(describe_human_loop_response[“HumanLoopOutput”][“OutputS3Uri”]))

You get the following response:

HumanLoop Status: Completed Output in S3 at: s3://[ACCOUNT NAME]-[REGION]-lookoutmetrics-lab-2/ecommerce/a2i-results/l4m-ecommerce-workflow/2021/06/22/05/35/13/51e352ff-38f3-4154-a162-1fb6661462da/output.json

Update the detector based on human feedback from Amazon A2I

In this section, we review our results and update the detector to improve prediction accuracy. Refer to the accompanying notebook in GitHub for detailed steps to add human loop. We check whether the human review detected an anomaly:

while anomaly_col_name in review_result: #tseriesid = review_result[‘tseriesid-‘ + str(col_name_suffix)] print(“n{}”.format(str(col_name_suffix))) is_anomaly = review_result[anomaly_col_name][‘on’] print(“Is Anomaly: {}”.format(is_anomaly))

If the review results indicated an anomaly, get the corresponding time series ID and anomaly group ID from the DataFrame and update the training set using the put feedback API call:

row_value = df_anomalies_by_ts.loc[(df_anomalies_by_ts[‘timestamp’] == timestamp) & (df_anomalies_by_ts[‘marketplace’] ==marketplace) & (df_anomalies_by_ts[‘platform’] ==platform)] #print(“Row :{}”.format(row_value)) …. …. put_feedback_response = L4M.put_feedback( AnomalyDetectorArn=ecom_anomaly_detector_arn, AnomalyGroupTimeSeriesFeedback={ ‘AnomalyGroupId’: anomaly_group_id, ‘TimeSeriesId’: tseriesid, ‘IsAnomaly’: is_anomaly} )

You can now retrain your model using the updated dataset to improve your model accuracy.

Clean up

Run the clean-up resources cell to clean up the resources that you created. Because we created a continuous detector, it continues to run one time every hour and incur charges until it is deleted.

Conclusion

In this post, we walked you through how to use Lookout for Metrics to train a model to detect anomalies, review diagnostics from the trained model, review the predictions from the model with a human in the loop using Amazon A2I, augment our original training dataset, and retrain our model with the feedback from the human reviews.

With Lookout for Metrics and Amazon A2I, you can set up a continuous prediction, review, train, and feedback loop to audit predictions and improve the accuracy of your models. Use the GitHub repo to access the notebook used in this post.

About the Authors

Neel Sendas is a Senior Technical Account Manager at Amazon Web Services. Neel works with enterprise customers to design, deploy, and scale cloud applications to achieve their business goals. He has worked on various ML use cases, ranging from anomaly detection to predictive product quality for manufacturing and logistics optimization. When he isn’t helping customers, he dabbles in golf and salsa dancing.

Ashish Rawat is a Senior Solutions Architect at Amazon Web Services, based in Atlanta, Georgia. Ashish provides architecture guidance to enterprise customers and helps them implement strategic industry solutions on AWS. He is passionate about AI/ML and Internet of Things.



Source

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published.

Amazon

AWS Week in Review – May 16, 2022

This post is part of our Week in Review series. Check back each week for a quick roundup of interesting news and announcements from AWS! I had been on the road for the last five weeks and attended many of the AWS Summits in Europe. It was great to talk to so many of you…

Published

on

By

This post is part of our Week in Review series. Check back each week for a quick roundup of interesting news and announcements from AWS!

I had been on the road for the last five weeks and attended many of the AWS Summits in Europe. It was great to talk to so many of you in person. The Serverless Developer Advocates are going around many of the AWS Summits with the Serverlesspresso booth. If you attend an event that has the booth, say “Hi ” to my colleagues, and have a coffee while asking all your serverless questions. You can find all the upcoming AWS Summits in the events section at the end of this post.

Last week’s launches
Here are some launches that got my attention during the previous week.

AWS Step Functions announced a new console experience to debug your state machine executions – Now you can opt-in to the new console experience of Step Functions, which makes it easier to analyze, debug, and optimize Standard Workflows. The new page allows you to inspect executions using three different views: graph, table, and event view, and add many new features to enhance the navigation and analysis of the executions. To learn about all the features and how to use them, read Ben’s blog post.

Example on how the Graph View looks

Example on how the Graph View looks

AWS Lambda now supports Node.js 16.x runtime – Now you can start using the Node.js 16 runtime when you create a new function or update your existing functions to use it. You can also use the new container image base that supports this runtime. To learn more about this launch, check Dan’s blog post.

AWS Amplify announces its Android library designed for Kotlin – The Amplify Android library has been rewritten for Kotlin, and now it is available in preview. This new library provides better debugging capacities and visibility into underlying state management. And it is also using the new AWS SDK for Kotlin that was released last year in preview. Read the What’s New post for more information.

Three new APIs for batch data retrieval in AWS IoT SiteWise – With this new launch AWS IoT SiteWise now supports batch data retrieval from multiple asset properties. The new APIs allow you to retrieve current values, historical values, and aggregated values. Read the What’s New post to learn how you can start using the new APIs.

AWS Secrets Manager now publishes secret usage metrics to Amazon CloudWatch – This launch is very useful to see the number of secrets in your account and set alarms for any unexpected increase or decrease in the number of secrets. Read the documentation on Monitoring Secrets Manager with Amazon CloudWatch for more information.

For a full list of AWS announcements, be sure to keep an eye on the What’s New at AWS page.

Other AWS News
Some other launches and news that you may have missed:

IBM signed a deal with AWS to offer its software portfolio as a service on AWS. This allows customers using AWS to access IBM software for automation, data and artificial intelligence, and security that is built on Red Hat OpenShift Service on AWS.

Podcast Charlas Técnicas de AWS – If you understand Spanish, this podcast is for you. Podcast Charlas Técnicas is one of the official AWS podcasts in Spanish. This week’s episode introduces you to Amazon DynamoDB and shares stories on how different customers use this database service. You can listen to all the episodes directly from your favorite podcast app or the podcast web page.

AWS Open Source News and Updates – Ricardo Sueiras, my colleague from the AWS Developer Relation team, runs this newsletter. It brings you all the latest open-source projects, posts, and more. Read edition #112 here.

Upcoming AWS Events
It’s AWS Summits season and here are some virtual and in-person events that might be close to you:

You can register for re:MARS to get fresh ideas on topics such as machine learning, automation, robotics, and space. The conference will be in person in Las Vegas, June 21–24.

That’s all for this week. Check back next Monday for another Week in Review!

— Marcia



Source

Continue Reading

Amazon

Personalize your machine translation results by using fuzzy matching with Amazon Translate

A person’s vernacular is part of the characteristics that make them unique. There are often countless different ways to express one specific idea. When a firm communicates with their customers, it’s critical that the message is delivered in a way that best represents the information they’re trying to convey. This becomes even more important when…

Published

on

By

A person’s vernacular is part of the characteristics that make them unique. There are often countless different ways to express one specific idea. When a firm communicates with their customers, it’s critical that the message is delivered in a way that best represents the information they’re trying to convey. This becomes even more important when it comes to professional language translation. Customers of translation systems and services expect accurate and highly customized outputs. To achieve this, they often reuse previous translation outputs—called translation memory (TM)—and compare them to new input text. In computer-assisted translation, this technique is known as fuzzy matching. The primary function of fuzzy matching is to assist the translator by speeding up the translation process. When an exact match can’t be found in the TM database for the text being translated, translation management systems (TMSs) often have the option to search for a match that is less than exact. Potential matches are provided to the translator as additional input for final translation. Translators who enhance their workflow with machine translation capabilities such as Amazon Translate often expect fuzzy matching data to be used as part of the automated translation solution.

In this post, you learn how to customize output from Amazon Translate according to translation memory fuzzy match quality scores.

Translation Quality Match

The XML Localization Interchange File Format (XLIFF) standard is often used as a data exchange format between TMSs and Amazon Translate. XLIFF files produced by TMSs include source and target text data along with match quality scores based on the available TM. These scores—usually expressed as a percentage—indicate how close the translation memory is to the text being translated.

Some customers with very strict requirements only want machine translation to be used when match quality scores are below a certain threshold. Beyond this threshold, they expect their own translation memory to take precedence. Translators often need to apply these preferences manually either within their TMS or by altering the text data. This flow is illustrated in the following diagram. The machine translation system processes the translation data—text and fuzzy match scores— which is then reviewed and manually edited by translators, based on their desired quality thresholds. Applying thresholds as part of the machine translation step allows you to remove these manual steps, which improves efficiency and optimizes cost.

Machine Translation Review Flow

Figure 1: Machine Translation Review Flow

The solution presented in this post allows you to enforce rules based on match quality score thresholds to drive whether a given input text should be machine translated by Amazon Translate or not. When not machine translated, the resulting text is left to the discretion of the translators reviewing the final output.

Solution Architecture

The solution architecture illustrated in Figure 2 leverages the following services:

  • Amazon Simple Storage Service – Amazon S3 buckets contain the following content:
    • Fuzzy match threshold configuration files
    • Source text to be translated
    • Amazon Translate input and output data locations
  • AWS Systems Manager – We use Parameter Store parameters to store match quality threshold configuration values
  • AWS Lambda – We use two Lambda functions:
    • One function preprocesses the quality match threshold configuration files and persists the data into Parameter Store
    • One function automatically creates the asynchronous translation jobs
  • Amazon Simple Queue Service – An Amazon SQS queue triggers the translation flow as a result of new files coming into the source bucket

Solution Architecture Diagram

Figure 2: Solution Architecture

You first set up quality thresholds for your translation jobs by editing a configuration file and uploading it into the fuzzy match threshold configuration S3 bucket. The following is a sample configuration in CSV format. We chose CSV for simplicity, although you can use any format. Each line represents a threshold to be applied to either a specific translation job or as a default value to any job.

default, 75 SourceMT-Test, 80

The specifications of the configuration file are as follows:

  • Column 1 should be populated with the name of the XLIFF file—without extension—provided to the Amazon Translate job as input data.
  • Column 2 should be populated with the quality match percentage threshold. For any score below this value, machine translation is used.
  • For all XLIFF files whose name doesn’t match any name listed in the configuration file, the default threshold is used—the line with the keyword default set in Column 1.

Auto-generated parameter in Systems Manager Parameter Store

Figure 3: Auto-generated parameter in Systems Manager Parameter Store

When a new file is uploaded, Amazon S3 triggers the Lambda function in charge of processing the parameters. This function reads and stores the threshold parameters into Parameter Store for future usage. Using Parameter Store avoids performing redundant Amazon S3 GET requests each time a new translation job is initiated. The sample configuration file produces the parameter tags shown in the following screenshot.

The job initialization Lambda function uses these parameters to preprocess the data prior to invoking Amazon Translate. We use an English-to-Spanish translation XLIFF input file, as shown in the following code. It contains the initial text to be translated, broken down into what is referred to as segments, represented in the source tags.

Consent Form CONSENT FORM FORMULARIO DE CONSENTIMIENTO Screening Visit: Screening Visit Selección

The source text has been pre-matched with the translation memory beforehand. The data contains potential translation alternatives—represented as tags—alongside a match quality attribute, expressed as a percentage. The business rule is as follows:

  • Segments received with alternative translations and a match quality below the threshold are untouched or empty. This signals to Amazon Translate that they must be translated.
  • Segments received with alternative translations with a match quality above the threshold are pre-populated with the suggested target text. Amazon Translate skips those segments.

Let’s assume the quality match threshold configured for this job is 80%. The first segment with 99% match quality isn’t machine translated, whereas the second segment is, because its match quality is below the defined threshold. In this configuration, Amazon Translate produces the following output:

Consent Form FORMULARIO DE CONSENTIMIENTO CONSENT FORM FORMULARIO DE CONSENTIMIENTO Screening Visit: Visita de selección Screening Visit Selección

In the second segment, Amazon Translate overwrites the target text initially suggested (Selección) with a higher quality translation: Visita de selección.

One possible extension to this use case could be to reuse the translated output and create our own translation memory. Amazon Translate supports customization of machine translation using translation memory thanks to the parallel data feature. Text segments previously machine translated due to their initial low-quality score could then be reused in new translation projects.

In the following sections, we walk you through the process of deploying and testing this solution. You use AWS CloudFormation scripts and data samples to launch an asynchronous translation job personalized with a configurable quality match threshold.

Prerequisites

For this walkthrough, you must have an AWS account. If you don’t have an account yet, you can create and activate one.

Launch AWS CloudFormation stack

  1. Choose Launch Stack:
  2. For Stack name, enter a name.
  3. For ConfigBucketName, enter the S3 bucket containing the threshold configuration files.
  4. For ParameterStoreRoot, enter the root path of the parameters created by the parameters processing Lambda function.
  5. For QueueName, enter the SQS queue that you create to post new file notifications from the source bucket to the job initialization Lambda function. This is the function that reads the configuration file.
  6. For SourceBucketName, enter the S3 bucket containing the XLIFF files to be translated. If you prefer to use a preexisting bucket, you need to change the value of the CreateSourceBucket parameter to No.
  7. For WorkingBucketName, enter the S3 bucket Amazon Translate uses for input and output data.
  8. Choose Next.

    Figure 4: CloudFormation stack details

  9. Optionally on the Stack Options page, add key names and values for the tags you may want to assign to the resources about to be created.
  10. Choose Next.
  11. On the Review page, select I acknowledge that this template might cause AWS CloudFormation to create IAM resources.
  12. Review the other settings, then choose Create stack.

AWS CloudFormation takes several minutes to create the resources on your behalf. You can watch the progress on the Events tab on the AWS CloudFormation console. When the stack has been created, you can see a CREATE_COMPLETE message in the Status column on the Overview tab.

Test the solution

Let’s go through a simple example.

  1. Download the following sample data.
  2. Unzip the content.

There should be two files: an .xlf file in XLIFF format, and a threshold configuration file with .cfg as the extension. The following is an excerpt of the XLIFF file.

English to French sample file extract

Figure 5: English to French sample file extract

  1. On the Amazon S3 console, upload the quality threshold configuration file into the configuration bucket you specified earlier.

The value set for test_En_to_Fr is 75%. You should be able to see the parameters on the Systems Manager console in the Parameter Store section.

  1. Still on the Amazon S3 console, upload the .xlf file into the S3 bucket you configured as source. Make sure the file is under a folder named translate (for example, /translate/test_En_to_Fr.xlf).

This starts the translation flow.

  1. Open the Amazon Translate console.

A new job should appear with a status of In Progress.

Auto-generated parameter in Systems Manager Parameter Store

Figure 6: In progress translation jobs on Amazon Translate console

  1. Once the job is complete, click into the job’s link and consult the output. All segments should have been translated.

All segments should have been translated. In the translated XLIFF file, look for segments with additional attributes named lscustom:match-quality, as shown in the following screenshot. These custom attributes identify segments where suggested translation was retained based on score.

Custom attributes identifying segments where suggested translation was retained based on score

Figure 7: Custom attributes identifying segments where suggested translation was retained based on score

These were derived from the translation memory according to the quality threshold. All other segments were machine translated.

You have now deployed and tested an automated asynchronous translation job assistant that enforces configurable translation memory match quality thresholds. Great job!

Cleanup

If you deployed the solution into your account, don’t forget to delete the CloudFormation stack to avoid any unexpected cost. You need to empty the S3 buckets manually beforehand.

Conclusion

In this post, you learned how to customize your Amazon Translate translation jobs based on standard XLIFF fuzzy matching quality metrics. With this solution, you can greatly reduce the manual labor involved in reviewing machine translated text while also optimizing your usage of Amazon Translate. You can also extend the solution with data ingestion automation and workflow orchestration capabilities, as described in Speed Up Translation Jobs with a Fully Automated Translation System Assistant.

About the Authors

Narcisse Zekpa is a Solutions Architect based in Boston. He helps customers in the Northeast U.S. accelerate their adoption of the AWS Cloud, by providing architectural guidelines, design innovative, and scalable solutions. When Narcisse is not building, he enjoys spending time with his family, traveling, cooking, and playing basketball.

Dimitri Restaino is a Solutions Architect at AWS, based out of Brooklyn, New York. He works primarily with Healthcare and Financial Services companies in the North East, helping to design innovative and creative solutions to best serve their customers. Coming from a software development background, he is excited by the new possibilities that serverless technology can bring to the world. Outside of work, he loves to hike and explore the NYC food scene.



Source

Continue Reading

Amazon

Enhance the caller experience with hints in Amazon Lex

We understand speech input better if we have some background on the topic of conversation. Consider a customer service agent at an auto parts wholesaler helping with orders. If the agent knows that the customer is looking for tires, they’re more likely to recognize responses (for example, “Michelin”) on the phone. Agents often pick up…

Published

on

By

We understand speech input better if we have some background on the topic of conversation. Consider a customer service agent at an auto parts wholesaler helping with orders. If the agent knows that the customer is looking for tires, they’re more likely to recognize responses (for example, “Michelin”) on the phone. Agents often pick up such clues or hints based on their domain knowledge and access to business intelligence dashboards. Amazon Lex now supports a hints capability to enhance the recognition of relevant phrases in a conversation. You can programmatically provide phrases as hints during a live interaction to influence the transcription of spoken input. Better recognition drives efficient conversations, reduces agent handling time, and ultimately increases customer satisfaction.

In this post, we review the runtime hints capability and use it to implement verification of callers based on their mother’s maiden name.

Overview of the runtime hints capability

You can provide a list of phrases or words to help your bot with the transcription of speech input. You can use these hints with built-in slot types such as first and last names, street names, city, state, and country. You can also configure these for your custom slot types.

You can use the capability to transcribe names that may be difficult to pronounce or understand. For example, in the following sample conversation, we use it to transcribe the name “Loreck.”

Conversation 1

IVR: Welcome to ACME bank. How can I help you today?

Caller: I want to check my account balance.

IVR: Sure. Which account should I pull up?

Caller: Checking

IVR: What is the account number?

Caller: 1111 2222 3333 4444

IVR: For verification purposes, what is your mother’s maiden name?

Caller: Loreck

IVR: Thank you. The balance on your checking account is 123 dollars.

Words provided as hints are preferred over other similar words. For example, in the second sample conversation, the runtime hint (“Smythe”) is selected over a more common transcription (“Smith”).

Conversation 2

IVR: Welcome to ACME bank. How can I help you today?

Caller: I want to check my account balance.

IVR: Sure. Which account should I pull up?

Caller: Checking

IVR: What is the account number?

Caller: 5555 6666 7777 8888

IVR: For verification purposes, what is your mother’s maiden name?

Caller: Smythe

IVR: Thank you. The balance on your checking account is 456 dollars.

If the name doesn’t match the runtime hint, you can fail the verification and route the call to an agent.

Conversation 3

IVR: Welcome to ACME bank. How can I help you today?

Caller: I want to check my account balance.

IVR: Sure. Which account should I pull up?

Caller: Savings

IVR: What is the account number?

Caller: 5555 6666 7777 8888

IVR: For verification purposes, what is your mother’s maiden name?

Caller: Jane

IVR: There is an issue with your account. For support, you will be forwarded to an agent.

Solution overview

Let’s review the overall architecture for the solution (see the following diagram):

  • We use an Amazon Lex bot integrated with an Amazon Connect contact flow to deliver the conversational experience.
  • We use a dialog codehook in the Amazon Lex bot to invoke an AWS Lambda function that provides the runtime hint at the previous turn of the conversation.
  • For the purposes of this post, the mother’s maiden name data used for authentication is stored in an Amazon DynamoDB table.
  • After the caller is authenticated, the control is passed to the bot to perform transactions (for example, check balance)

In addition to the Lambda function, you can also send runtime hints to Amazon Lex V2 using the PutSession, RecognizeText, RecognizeUtterance, or StartConversation operations. The runtime hints can be set at any point in the conversation and are persisted at every turn until cleared.

Deploy the sample Amazon Lex bot

To create the sample bot and configure the runtime phrase hints, perform the following steps. This creates an Amazon Lex bot called BankingBot, and one slot type (accountNumber).

  1. Download the Amazon Lex bot.
  2. On the Amazon Lex console, choose Actions, Import.
  3. Choose the file BankingBot.zip that you downloaded, and choose Import.
  4. Choose the bot BankingBot on the Amazon Lex console.
  5. Choose the language English (GB).
  6. Choose Build.
  7. Download the supporting Lambda code.
  8. On the Lambda console, create a new function and select Author from scratch.
  9. For Function name, enter BankingBotEnglish.
  10. For Runtime, choose Python 3.8.
  11. Choose Create function.
  12. In the Code source section, open lambda_function.py and delete the existing code.
  13. Download the function code and open it in a text editor.
  14. Copy the code and enter it into the empty function code field.
  15. Choose deploy.
  16. On the Amazon Lex console, select the bot BankingBot.
  17. Choose Deployment and then Aliases, then choose the alias TestBotAlias.
  18. On the Aliases page, choose Languages and choose English (GB).
  19. For Source, select the bot BankingBotEnglish.
  20. For Lambda version or alias, enter $LATEST.
  21. On the DynamoDB console, choose Create table.
  22. Provide the name as customerDatabase.
  23. Provide the partition key as accountNumber.
  24. Add an item with accountNumber: “1111222233334444” and mothersMaidenName “Loreck”.
  25. Add item with accountNumber: “5555666677778888” and mothersMaidenName “Smythe”.
  26. Make sure the Lambda function has permissions to read from the DynamoDB table customerDatabase.
  27. On the Amazon Connect console, choose Contact flows.
  28. In the Amazon Lex section, select your Amazon Lex bot and make it available for use in the Amazon Connect contact flow.
  29. Download the contact flow to integrate with the Amazon Lex bot.
  30. Choose the contact flow to load it into the application.
  31. Make sure the right bot is configured in the “Get Customer Input” block.
  32. Choose a queue in the “Set working queue” block.
  33. Add a phone number to the contact flow.
  34. Test the IVR flow by calling in to the phone number.

Test the solution

You can now call in to the Amazon Connect phone number and interact with the bot.

Conclusion

Runtime hints allow you to influence the transcription of words or phrases dynamically in the conversation. You can use business logic to identify the hints as the conversation evolves. Better recognition of the user input allows you to deliver an enhanced experience. You can configure runtime hints via the Lex V2 SDK. The capability is available in all AWS Regions where Amazon Lex operates in the English (Australia), English (UK), and English (US) locales.

To learn more, refer to runtime hints.

About the Authors

Kai Loreck is a professional services Amazon Connect consultant. He works on designing and implementing scalable customer experience solutions. In his spare time, he can be found playing sports, snowboarding, or hiking in the mountains.

Anubhav Mishra is a Product Manager with AWS. He spends his time understanding customers and designing product experiences to address their business challenges.

Sravan Bodapati is an Applied Science Manager at AWS Lex. He focuses on building cutting edge Artificial Intelligence and Machine Learning solutions for AWS customers in ASR and NLP space. In his spare time, he enjoys hiking, learning economics, watching TV shows and spending time with his family.



Source

Continue Reading

Trending

Copyright © 2021 Today's Digital.