Amazon Comprehend
Pretrained natural language processing on AWS: entities, key phrases, PII detection and redaction, language, sentiment and targeted sentiment, syntax, custom classification and entity recognition, processing modes, Comprehend Medical, availability changes, security, and cost.
5 min read · Last reviewed · SAA-C03
Sign in to bookmark tutorials and track what you have read.
On this page
What it is
Amazon Comprehend is a natural language processing (NLP) service that extracts insights from text. It uses pretrained models, so you don't need training data or ML (Machine learning)Software that learns patterns from example data to make predictions or decisions, instead of following rules written by hand. A model is first trained on data, then used to make predictions on new data, which is called inference.Glossary entry expertise. Send it text, such as customer reviews, support tickets, emails, or social media posts, and it returns what the text is about and how it feels.
Choose Comprehend when a question asks to find sentiment, entities, key phrases, the language, or personal data (PII (Personally identifiable information)Information that can identify a person, alone or combined with other data, such as a name, email address, or passport number. Amazon Macie finds PII in Amazon S3.Glossary entry) in text, or to classify documents into your own categories. It works on text: to get text from documents, use Amazon Textract first; to get text from audio, use Amazon Transcribe first.
Insights
- Entities: names of people, places, organizations, dates, quantities, and other items.
- Key phrases: the main phrases in the text.
- Personally identifiable information (PII): locate or redact PII such as addresses, bank account numbers, and phone numbers (English and Spanish).
- Real-time analysis of a single document only locates PII: it returns each entity's type, score, and character offsets, and does not change the text.
- To get a redacted copy of the text, run an asynchronous batch job on documents in S3.
- Dominant language of the text.
- Sentiment: positive, negative, neutral, or mixed for the whole document.
- Targeted sentiment: the sentiment toward each entity, for example a positive view of the food but a negative view of the service.
- Syntax: the part of speech of each word.
Comprehend Custom
Without ML skills, Comprehend uses AutoML to train models on your labeled data:
- Custom classification sorts documents into your own categories, such as routing support tickets to the right team.
- Custom entity recognition finds entity types specific to your business, such as policy numbers or product codes.
Processing modes
- Single-document synchronous: one document, immediate response.
- Multi-document synchronous: a small batch in one call.
- Asynchronous batch: large collections of documents in Amazon S3, with results written back to S3.
Availability changes
Comprehend topic modeling, event detection, and prompt safety classification are no longer available to new customers. Accounts that used them in the previous 12 months keep access, and all other Comprehend features are unaffected. Do not choose these features for a new design.
Amazon Comprehend Medical
Comprehend Medical is a separate, HIPAA (Health Insurance Portability and Accountability Act)A US law that protects health information. AWS customers can process protected health information on HIPAA-eligible services after accepting a Business Associate Addendum (BAA) with AWS, which is available in AWS Artifact.Glossary entry-eligible service that extracts medical information, such as conditions, medications, and dosages, from unstructured clinical text like physician notes. It is not a substitute for professional medical judgment.
Security, resilience, performance, and cost
Security
- IAM controls access; asynchronous jobs use an IAM role to read and write S3.
- Your own KMS key can encrypt the storage volumes used by jobs and the output of asynchronous jobs.
- Interface VPC endpointA private connection from a VPC to an AWS service or another endpoint service without crossing the internet. Gateway endpoints, for Amazon S3 and DynamoDB, are route table targets; interface endpoints are network interfaces that use AWS PrivateLink.Glossary entry (AWS PrivateLink) keep calls off the internet. CloudTrail records API (Application programming interface)A defined way for one program to ask another for data or actions, such as a set of HTTPS requests and responses. Every AWS service is controlled through its API, which the console, the CLI, and the SDKs call for you.Glossary entry calls.
- Use PII redaction to remove personal data before storing or sharing text.
Resilience and performance
- Comprehend is a managed, Regional service. Use asynchronous jobs for large volumes.
Cost
- Pay per unit of text analyzed (1 unit = 100 characters), with a 3-unit minimum per request.
- Custom models also charge for training. A real-time endpoint for a custom model is billed for its inference units from the moment it starts until you delete it, even with no traffic, so delete idle endpoints.
Monitoring
- CloudWatch metrics for requests and errors; CloudTrail for auditing.
Comprehend or another option?
| If the requirement is | Choose |
|---|---|
| Sentiment, entities, or key phrases in text | Amazon Comprehend |
| Find where PII appears in one document, in real time | Comprehend PII detection (real-time) |
| Produce redacted copies of documents in S3 | Comprehend PII redaction (asynchronous job) |
| Route documents into our own categories | Comprehend custom classification |
| Medical conditions and medications in clinical notes | Amazon Comprehend Medical |
| Extract text from scanned documents | Amazon Textract |
| Translate text to another language | Amazon Translate |
| Find PII in files stored in S3 at scale | Amazon Macie |
Reverse mindmap: when the question points here
- Yes, when the question says
- Sentiment of reviews or social posts leads to Comprehend sentiment
- Sentiment toward each product or brand mentioned leads to Targeted sentiment
- People, places, and organizations in text leads to Comprehend entities
- Detect or redact PII in text leads to Comprehend PII
- Redacted copies of documents leads to Asynchronous PII redaction job
- Detect the language of text leads to Comprehend dominant language
- Sort tickets into our own categories leads to Custom classification
- Clinical notes, medications, conditions leads to Comprehend Medical
- No, when the question says
- Text from scanned documents leads to Textract first
- Text from audio leads to Transcribe first
- Sensitive data across S3 buckets leads to Macie
Key takeaways
- Comprehend is pretrained NLP: entities, key phrases, PII, language, sentiment, targeted sentiment, and syntax.
- Comprehend Custom trains classifiers and entity recognizers on your data with no ML skills.
- Use synchronous calls for single documents and asynchronous jobs for collections in S3.
- Real-time PII detection only locates entities; redacted output comes from an asynchronous job.
- Topic modeling, event detection, and prompt safety classification are closed to new customers.
- Comprehend Medical handles clinical text; Macie, not Comprehend, scans S3 for sensitive data.
Sources
- Amazon Comprehend Developer Guide: What is Amazon Comprehend?
- Amazon Comprehend Developer Guide: Entities
- Amazon Comprehend Developer Guide: Key phrases
- Amazon Comprehend Developer Guide: Detecting PII entities
- Amazon Comprehend Developer Guide: Dominant language
- Amazon Comprehend Developer Guide: Sentiment
- Amazon Comprehend Developer Guide: Targeted sentiment
- Amazon Comprehend Developer Guide: Syntax analysis
- Amazon Comprehend Developer Guide: Custom classification
- Amazon Comprehend Developer Guide: Custom entity recognition
- Amazon Comprehend Developer Guide: Document processing modes
- Amazon Comprehend Developer Guide: Amazon Comprehend feature availability change
- Amazon Comprehend Developer Guide: KMS encryption in Amazon Comprehend
- Amazon Comprehend Developer Guide: Amazon Comprehend and interface VPC endpoints
- Amazon Comprehend Medical Developer Guide: What is Amazon Comprehend Medical?
- Amazon Comprehend pricing