Detecting Custom Entities in Real Time with Amazon Comprehend - Amazon Comprehend

Detecting Custom Entities in Real Time with Amazon Comprehend

With Amazon Comprehend, you can quickly detect custom entities in individual text documents by running real-time analysis. Unlike asynchronous batch jobs that analyze large documents or large sets of documents, real-time analysis is useful for applications that process small bodies of text as they arrive. For example, you can immediately detect custom entities in social media posts, support tickets, or customer reviews.

After you train a custom entity recognition model, you enable real-time analysis by creating an endpoint. After you create the endpoint, your custom model is available for real-time analysis, and you can detect entities by using the Amazon Comprehend console, the Amazon Comprehend API, the AWS CLI, or the AWS SDKs.

Before you begin

Before you can detect custom entities, you must train a custom entity recognition model. For more information about these models, see Training Custom Entity Recognizers. For the steps to train a model, see Creating a Custom Entity Recognizer Using the Console.

Creating an Endpoint for Custom Entity Detection

After you train a custom entity recognition model, you can use that model to quickly detect custom entities in individual documents. First, you must create an endpoint, which makes your model available for real-time analysis.

To meet your text processing needs, you assign inference units to the endpoint, and each unit allows of 100 characters per second. You can then adjust the throughput up or down. The cost of real-time analysis is based on the throughput of an endpoint and the duration of time it is active. For more information on endpoint cost, see Amazon Comprehend Pricing.

After you create an endpoint, you can monitor it with Amazon CloudWatch, update it to change its inference units, or delete it when you no longer need it. For more information, see Managing Endpoints with Amazon Comprehend.

Creating an Endpoint with the Console

Complete the following steps to create an endpoint that you can use to detect custom entities in real time.

  1. Sign in to the AWS Management Console and open the Amazon Comprehend console at https://console.aws.amazon.com/comprehend/.

  2. In the navigation pane on the left, choose Customization, and then choose Custom entity recognition.

  3. Under Entity recognizers, select the custom model for which you want to create the endpoint.

  4. Choose the Actions menu, and choose Create endpoint.

  5. On the Create endpoint page, give the endpoint a name. The name must be unique within the AWS Region and account.

  6. For Compute units, specify the number of inference units to assign to the endpoint. Each unit represents a throughput of 100 characters per second for up to 2 documents per second. You can assign up to a maximum of 10 inference units per endpoint.

    Note

    The throughput you assign the endpoint affects your costs. For more details, see Amazon Comprehend Pricing.

  7. (Optional) To add a tag to the endpoint, enter a key-value pair under Tags and choose Add tag.

  8. Choose Create endpoint. The Endpoints list is displayed, with the new endpoint showing Creating. Once it shows Ready, you can use the endpoint for real-time entity detection.

Creating an Endpoint with the AWS CLI

To create an endpoint by using the AWS CLI, use the create-endpoint command:

$ aws comprehend create-endpoint \ > --desired-inference-units number of inference units \ > --endpoint-name endpoint name \ > --model-arn arn:aws:comprehend:region:account-id:model/example \ > --tags Key=Key,Value=Value

If your command succeeds, Amazon Comprehend responds with the endpoint ARN:

{ "EndpointArn": "Arn" }

For more information about this command, its parameter arguments, and its output, see create-endpoint in the AWS CLI Command Reference

Running Real-Time Custom Entity Detection

After you create an endpoint for your custom entity recognizer model, you can run real-time analysis to quickly detect entities in individual bodies of text.

Detecting Entities with the Console

Complete the following steps to detect custom entities in your text by using the Amazon Comprehend console.

  1. Sign in to the AWS Management Console and open the Amazon Comprehend console at https://console.aws.amazon.com/comprehend/.

  2. From the left menu, choose Real-time analysis.

  3. In the Input text section, for Analysis type, choose Custom.

  4. For Select endpoint, choose the endpoint that is associated with the entity-detection model that you want to use.

  5. Under Input text, provide the text you want to analyze.

  6. Choose Analyze. The text analysis based on your custom model is displayed, along with a confidence assessment of the analysis.

Detecting Entities with the AWS CLI

To detect custom entities by using the AWS CLI, use the detect-entities command:

$ aws comprehend detect-entities \ > --endpoint-arn arn \ > --language-code en \ > --text "Jeff Bezos is the CEO of Amazon."

If your command succeeds, Amazon Comprehend responds with the analysis. For each entity that Amazon Comprehend detects, it provides the entity type, text, location, and confidence score.

For more information about this command, its parameter arguments, and its output, see detect-entities in the AWS CLI Command Reference