Skill 1.1.1: Extract data from data sources
Question 1 - Advanced Text Tokenization for Domain-Specific Vocabulary
A healthcare AI startup is building a medical document classification system using Amazon SageMaker. Their corpus contains specialized clinical terminology (e.g., "tachyarrhythmia", "electrocardiographic abnormalities") and medication names that are frequently split incorrectly by standard tokenizers. The team needs to preprocess 500,000 clinical notes stored in Amazon S3 before training a BERT-based classifier. The solution must handle domain-specific multi-word medical terms as single tokens, minimize operational overhead, and scale automatically as new documents arrive.
Which approach should the ML engineer use to tokenize this domain-specific text? (Select ONE)
- A) Use Amazon Bedrock with the Titan Embeddings model to automatically tokenize clinical terms using its built-in healthcare vocabulary.
- B) Extend a BERT tokenizer's vocabulary with domain-specific clinical terms using Amazon SageMaker Processing, then save the tokenizer to Amazon SageMaker Model Registry for reuse.
- C) Deploy an AWS Lambda function that splits text on whitespace and punctuation, then manually maps each multi-word medical term to a single token ID using a hardcoded dictionary.
- D) Use Amazon Comprehend Medical to automatically tokenize clinical documents and extract medical entities as tokens for model training.
Click to reveal Answer & Explanation
Correct Answer: B
Correct Option Analysis
- B is Correct: Extending a tokenizer's vocabulary (WordPiece/BPE) with domain-specific terms while preserving base model vocabulary is the standard approach for domain adaptation in NLP. Using SageMaker Processing provides managed, scalable compute for vocabulary extension, and Model Registry ensures versioned tokenizer artifacts are shared between training and inference.
Distractor Analysis
- A is Incorrect: Amazon Bedrock's Titan Embeddings model creates vector representations but does not perform custom vocabulary tokenization. Bedrock models use their own fixed tokenizers that cannot be extended with domain-specific terms.
- C is Incorrect: Manual whitespace splitting plus hardcoded dictionary mapping introduces unnecessary operational overhead, doesn't handle subword tokenization properly, and won't scale to 500,000 documents. It also violates the "minimize operational overhead" constraint since the dictionary must be manually maintained.
- D is Incorrect: Amazon Comprehend Medical performs entity recognition (diagnosis, medication, dosage), not vocabulary-level tokenization. Its entity outputs are annotations, not token IDs suitable for BERT input.
Key Takeaway: For domain-specific tokenization, extend the base tokenizer's vocabulary rather than replacing it - this preserves general language understanding while adding specialized terminology.
Question 2 - Domain-Specific Text Augmentation
A financial services firm is training a fraud detection model on transaction description text using Amazon SageMaker. Their labeled dataset contains only 2,000 examples of fraudulent transactions but 50,000 legitimate ones. The compliance team requires that all augmented data remain within the firm's AWS account and that no synthetic data leave their VPC. The team needs to increase the minority class size while preserving domain-specific patterns like account numbers, currency codes, and merchant category classifications.
Which TWO techniques should the ML engineer apply for domain-specific augmentation? (Select TWO)
- A) Use Amazon Bedrock to generate synthetic fraudulent transaction descriptions by prompting a foundation model with examples.
- B) Apply random synonym replacement from a domain-specific financial glossary using AWS Glue jobs.
- C) Implement back-translation: translate English transaction descriptions to German using Amazon Translate, then back to English to create paraphrased variants.
- D) Use Amazon SageMaker Data Wrangler to perform SMOTE-style oversampling on TF-IDF vectors of transaction descriptions.
- E) Apply domain-aware random insertion/deletion of financial tokens (currency symbols, account number masks) using Amazon EMR with Spark NLP.
Click to reveal Answer & Explanation
Correct Answers: B and E
Correct Options Analysis
- B is Correct: Synonym replacement using domain-specific glossaries preserves financial terminology and generates plausible variations without requiring external model access. AWS Glue provides cost-effective batch processing for text augmentation.
- E is Correct: Domain-aware augmentation that inserts/deletes financial tokens (e.g., "$", "USD", masked account patterns "XXXX-1234") maintains the structural patterns of financial text while creating new training samples. Amazon EMR with Spark NLP scales for processing large text corpora with custom NLP pipelines.
Distractor Analysis
- A is Incorrect: Amazon Bedrock accesses foundation models outside the firm's VPC-boundary (though within AWS network), and this violates the compliance requirement that synthetic data generation remain within their account. It also risks exposing transaction patterns through prompting.
- C is Incorrect: Back-translation via Amazon Translate is a generic augmentation technique that doesn't preserve domain-specific constraints like currency codes, account number formats, or merchant classification rules. Translation systems typically normalize numbers and domain structures, breaking the patterns needed for fraud detection.
- D is Incorrect: SMOTE-style oversampling on TF-IDF vectors generates interpolated samples that may not correspond to valid domain textual sequences. The augmented embeddings would not map back to realistic token sequences that a model could meaningfully learn from.
Key Takeaway: Domain-specific augmentation preserves the structural patterns (token formats, domain vocabulary) of your data - generic augmentation techniques often break these patterns.
Question 3 - Tokenization for Streaming Text Processing
A logistics company processes real-time shipment tracking messages from Amazon Kinesis Data Streams. Each message contains concatenated fields like timestamps, package IDs, and location codes (e.g., "2024-01-15|PKG88421|SEA-TAC|OUT_FOR_DELIVERY"). The ML team needs to tokenize these messages for input to a transformer model that predicts delivery delays. The tokenization must handle field-separator delimiters, convert location codes to normalized tokens (e.g., "SEA-TAC" → "SEATTLE_TACOMA"), and process messages within 50 milliseconds to meet latency SLAs.
Which solution meets these requirements with the LOWEST operational overhead? (Select ONE)
- A) Deploy an AWS Lambda function that tokenizes each Kinesis record using a custom regex parser, then forwards normalized tokens to the inference endpoint.
- B) Use Amazon Managed Service for Apache Flink to maintain a sliding window of messages and apply custom tokenization logic using Flink's stateful operators.
- C) Deploy Amazon SageMaker Processing jobs scheduled every minute to batch-tokenize incoming messages from Kinesis.
- D) Use AWS Glue Streaming with a custom Spark UDF to parse and normalize tokens before sending to the model endpoint.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Option Analysis
- A is Correct: AWS Lambda provides per-record processing with sub-50ms cold-start optimized tokenization for simple regex-based field splitting and normalization. It scales automatically with Kinesis throughput, and the regex mapping (location code → normalized name) is stateless, making it ideal for event-driven per-record transformation.
Distractor Analysis
- B is Incorrect: Amazon Managed Service for Apache Flink is designed for stateful stream processing with sliding windows and ordering guarantees. For simple per-record regex tokenization, Flink introduces unnecessary operational complexity (cluster management, checkpoints, state management) that violates the "lowest operational overhead" constraint.
- C is Incorrect: SageMaker Processing jobs are batch-oriented and scheduled. The one-minute scheduling interval introduces unacceptable latency (up to 60 seconds) for a real-time pipeline that requires 50ms processing.
- D is Incorrect: AWS Glue Streaming is better suited for continuous batch-like processing with heavy transformations. The overhead of Spark's micro-batch model adds latency and complexity compared to a simple Lambda regex parser.
Key Takeaway: Match the transformation complexity to the tool - stateless per-record tokenization belongs in Lambda; stateful multi-record transformations need a stream processing framework.
Question 4 - Chunking Strategy and Tokenization for RAG
An e-commerce company is building a RAG application for product documentation using Amazon Bedrock Knowledge Bases and Amazon OpenSearch Service. Their documentation includes API reference guides with code snippets, pricing tables, and prose explanations. The team needs to implement chunking that preserves code blocks as atomic units, captures markdown headings as metadata, and generates embeddings that accurately represent technical content. The retrieval quality must not be compromised by splitting code examples mid-function or separating a heading from its content.
Which chunking approach should the ML engineer configure? (Select ONE)
- A) Use fixed-size chunking with 1,000-token chunks to ensure consistent chunk sizes across all content types.
- B) Use hierarchical chunking in Amazon Bedrock Knowledge Bases with parent chunks containing full sections and child chunks for detailed retrieval.
- C) Use semantic chunking based on markdown structure, with custom preprocessing that keeps code blocks together and associates headings as metadata.
- D) Disable chunking entirely since technical documentation is logically structured and should be retrieved as whole documents.
Click to reveal Answer & Explanation
Correct Answer: C
Correct Option Analysis
- C is Correct: Semantic chunking that respects document structure (markdown headings, code blocks, tables) ensures that technical content isn't split arbitrarily. Custom preprocessing keeps code snippets intact and attaches heading context as metadata, improving retrieval precision for technical queries where code and explanatory text must align.
Distractor Analysis
- A is Incorrect: Fixed-size chunking may split code blocks at arbitrary token boundaries, breaking function definitions or separating API endpoint documentation from its example code. This directly compromises the requirement that code examples remain atomic.
- B is Incorrect: While hierarchical chunking preserves parent-child relationships, Amazon Bedrock Knowledge Bases' native hierarchical chunking doesn't automatically recognize code block boundaries. Custom preprocessing is still needed to mark code blocks as indivisible units, making option C more complete.
- D is Incorrect: Whole-document retrieval would return the entire API guide for every query, diluting the semantic signal and generating prompts that exceed context window limits. This also increases embedding costs and retrieval latency unnecessarily.
Key Takeaway: For technical RAG content, structure-aware chunking that respects code blocks and heading metadata is critical for retrieval quality.
Question 5 - Tokenization for Multilingual Text
A global customer support platform processes feedback in 12 languages using Amazon SageMaker. They are fine-tuning a multilingual BERT model on product reviews. The reviews contain language mixing (code-switching), emojis with sentiment meaning (e.g., "service was terrible 😡 but delivery was fast 👍"), and language-specific hashtags (e.g., "#ExcellentService" vs. "#ServicioExcelente"). The team needs to preprocess these texts to preserve emotional context from emojis while correctly tokenizing mixed-language content.
Which preprocessing strategy should the ML engineer implement? (Select ONE)
- A) Remove all emojis and hashtags since they introduce noise, then use the base multilingual tokenizer directly.
- B) Convert emojis to descriptive text tokens (e.g., 😡 → "[ANGER_FACE]") using a custom mapping, preserve hashtags as compound tokens, and use the multilingual tokenizer's native subword handling.
- C) Split text by language detected using Amazon Comprehend, process each language segment with a language-specific tokenizer, then concatenate token sequences.
- D) Use Amazon Translate to convert all reviews to English, then tokenize with an English-only tokenizer for consistency.
Click to reveal Answer & Explanation
Correct Answer: B
Correct Option Analysis
- B is Correct: Converting emojis to descriptive tokens preserves sentiment information that would otherwise be lost (critical for feedback models). Preserving hashtags as compound tokens allows the subword tokenizer to leverage meaningful word fragments across languages. The multilingual tokenizer's WordPiece/SentencePiece handles code-switching natively.
Distractor Analysis
- A is Incorrect: Removing emojis destroys critical sentiment signals ( 😡 vs. 👍 convey entirely different emotions). Removing hashtags discards domain-specific user-generated features that correlate strongly with satisfaction metrics.
- C is Incorrect: Language detection and per-language tokenization segments introduces cold-start overhead for mixed-language sentences and cannot handle inter-sentential code-switching (switching languages mid-sentence). The multilingual tokenizer handles mixed input without external language detection.
- D is Incorrect: Translation to English loses language-specific nuances, informal phrasing patterns (which are strong predictors in sentiment analysis), and introduces translation latency that adds operational complexity. Translation also destroys the code-switching patterns that multilingual models should learn from.
Key Takeaway: Preserve domain-specific signals (emojis, hashtags) rather than discarding them - multilingual tokenizers already handle code-switching without external language detection.
Question 6 - Domain-Specific Augmentation for Fine-Tuning
A legal tech company is preparing training data for fine-tuning a foundation model on contract review tasks using Amazon Bedrock. They have 500 annotated contract clauses and need to increase this to 5,000 training examples. Compliance requires that all synthetic data be generated within their AWS account and that no client contract content is transmitted to third parties. The augmentation must preserve legal-specific structures ("WHEREAS clauses", "indemnification language", "force majeure provisions") and maintain consistent legal terminology.
Which approach best meets these requirements? (Select ONE)
- A) Use Amazon Bedrock to perform model distillation by generating synthetic clauses from a larger model, then fine-tune on the generated outputs.
- B) Apply template-based augmentation using Amazon SageMaker Data Wrangler: extract clause templates from existing contracts and generate variations by filling slots with domain-specific legal terms.
- C) Use Amazon Comprehend to detect entities in existing contracts and generate new clauses by recombining detected entity values.
- D) Upload contracts to a third-party data augmentation service that specializes in legal text synthesis, then import generated data back to S3.
Click to reveal Answer & Explanation
Correct Answer: B
Correct Option Analysis
- B is Correct: Template-based augmentation keeps synthetic data generation within AWS infrastructure (SageMaker Data Wrangler), satisfies the compliance constraint, and preserves legal document structures by treating clauses as templates with domain-specific variables. This approach generates structured, realistic training examples without external model access.
Distractor Analysis
- A is Incorrect: Model distillation uses a teacher model to generate outputs for prompts, but this does not create the labeled prompt-response pairs needed for fine-tuning. Distillation compresses capabilities rather than augmenting training data, and it still requires the original labeled data to evaluate student model performance.
- C is Incorrect: Amazon Comprehend extracts entities (names, dates, organizations) but doesn't understand legal clause structures. Recombining entities without understanding clause semantics produces nonsensical legal text that fails to preserve domain structure.
- D is Incorrect: Using a third-party service directly violates the compliance constraint that client contract content must not be transmitted to parties outside their AWS account. External services also introduce supply chain risk and data governance challenges.
Key Takeaway: Template-based augmentation preserves domain structure and stays within your AWS security boundary - external augmentation services may violate compliance rules.
Question 7 - Advanced Tokenization for Code and Technical Text
A developer tools company is building a code documentation assistant using Amazon SageMaker that must understand programming queries in natural language and retrieve relevant documentation. Their training data includes Python code snippets, API signatures, and natural language explanations mixed together (e.g., "Use DataFrame.groupby() to split data by column category"). Standard BERT tokenization breaks groupby() into group and by, losing the API reference identity.
Which tokenization strategy should the ML engineer implement? (Select ONE)
- A) Use Amazon CodeWhisperer to automatically tokenize code and documentation with its built-in programming language understanding.
- B) Extend the tokenizer with programming-specific tokens (e.g.,
DataFrame,groupby(), API names) using SageMaker Processing, then apply BPE augmentation to handle unseen code symbols. - C) Split the corpus into separate pipelines: use a character-level tokenizer for code snippets and a word-level tokenizer for natural language, then merge embeddings.
- D) Preprocess text to replace all code tokens with generic placeholders (e.g.,
[CODE_SYMBOL]) before tokenization.
Click to reveal Answer & Explanation
Correct Answer: B
Correct Option Analysis
- B is Correct: Extending the vocabulary with programming-specific terms (API names, method calls) ensures these compound tokens are preserved as atomic units. BPE (Byte-Pair Encoding) augmentation handles out-of-vocabulary code symbols like variable names or function arguments that appear in documentation. SageMaker Processing provides scalable infrastructure for vocabulary extension.
Distractor Analysis
- A is Incorrect: Amazon CodeWhisperer is designed for interactive code suggestion and completion, not for tokenizing text for ML training. It doesn't expose a configurable tokenizer for use in custom SageMaker models.
- C is Incorrect: Separate pipelines create a complex architecture where merging embeddings requires additional alignment mechanisms and training objectives. The dual-tokenizer approach also increases inference complexity and creates model architecture constraints.
- D is Incorrect: Replacing code tokens with generic placeholders destroys the semantic information that distinguishes
DataFrame.groupby()fromArray.map(). The model would learn no distinction between API methods, completely defeating the purpose of documentation retrieval.
Key Takeaway: For code and technical text, preserve API names and method calls as atomic tokens by extending the vocabulary rather than letting generic subword tokenizers split them.
Question 8 - Domain-Specific Augmentation with Data Privacy
An insurance company is developing a claims processing model using Amazon SageMaker. Their training data contains domain-specific claim descriptions with PII (policyholder names, addresses, claim numbers). The data science team wants to augment the dataset with synthetic claims for rare claim types (natural disasters, fraud cases). Compliance requires PII removal before augmentation and complete audit trails of data transformations.
Which pipeline design meets these requirements? (Select ONE)
- A) Use Amazon Macie to discover PII in claims data, mask PII using Amazon Comprehend PII detection, then apply augmentation using SageMaker Data Wrangler with audit logging enabled.
- B) Immediately generate synthetic claims using Amazon Bedrock, then apply PII detection to remove any PII from generated content before training.
- C) Copy raw claims to a second S3 bucket for augmentation, then remove PII from the augmented dataset only.
- D) Use AWS Glue jobs to tokenize claims and replace PII with random values at inference time, then apply augmentation on tokenized data.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Option Analysis
- A is Correct: This pipeline follows the correct order: discover PII locations using Macie (for auditability), redact/mask using Amazon Comprehend (removes PII before any generation), then apply augmentation on clean data using SageMaker Data Wrangler. Audit logging via SageMaker and CloudTrail provides compliance traceability for every transformation.
Distractor Analysis
- B is Incorrect: Generating synthetic content from PII-containing prompts exposes sensitive data to external models (even within AWS, Bedrock transmits prompts for inference). PII must be removed before any generation occurs, not after, since anything in the training data can surface in model outputs.
- C is Incorrect: Copying raw PII data to another bucket doubles the compliance risk surface without providing any benefit. PII must be removed at the source before augmentation, not afterward.
- D is Incorrect: Replacing PII at inference time leaves PII in the training data, which means the model still learns from it during training. PII removal at inference is too late — the model's weights may have already memorized sensitive patterns.
Key Takeaway: PII must be removed at the start of any augmentation pipeline — not after generation, and not at inference — to maintain compliance.
Question 9 - Tokenization for Embedding Model Selection
A research institution is building a semantic search application for biomedical literature using Amazon OpenSearch Service and Amazon Bedrock embedding models. They need to choose between Ada 002 (OpenAI-style subword tokenizer) and Amazon Titan Embeddings v2. Their queries involve gene names (e.g., "BRCA1", "TP53"), chemical compounds ("acetylcholinesterase inhibitor"), and clinical trial identifiers ("NCT01234567"). The team needs to ensure that gene names are not split into generic subwords that dilute semantic meaning.
Which consideration should guide the tokenization and embedding model selection? (Select ONE)
- A) Choose the model with the largest vocabulary size, since larger vocabularies always preserve domain-specific terms better.
- B) Evaluate both models' tokenization of representative biomedical terms, then select the model whose native tokenizer preserves gene names and clinical identifiers as atomic tokens.
- C) Use a custom BPE tokenizer that splits biomedical terms into character-level tokens, then pass these tokens to any embedding model.
- D) Choose the model with the lowest cost per million tokens, since tokenization differences are negligible at internet scale.
Click to reveal Answer & Explanation
Correct Answer: B
Correct Option Analysis
- B is Correct: Tokenization quality directly impacts embedding quality. If a model's tokenizer splits "BRCA1" into "B", "R", "CA", "1" (or similar fragments), the embedding model learns these subwords rather than the gene symbol as an atomic concept. Evaluating actual tokenization behavior on domain terms is essential before selecting an embedding model.
Distractor Analysis
- A is Incorrect: Vocabulary size doesn't guarantee domain-specific coverage. A large general vocabulary might still lack gene names if trained mostly on general web text. The relevant factor is whether the tokenizer recognizes domain terms, not raw vocabulary count.
- C is Incorrect: Character-level tokenization fragments gene names into individual letters, destroying the semantic identity of terms like "BRCA1" entirely. This would make it impossible for embeddings to distinguish between "BRCA1" and "BRCA2" based on token identity.
- D is Incorrect: Tokenization differences are not negligible for domain-specific semantic search. Splitting gene names differently changes embedding quality and retrieval performance, even if the price per token is similar. Cost should not drive model selection when semantic accuracy is the primary requirement.
Key Takeaway: Test how embedding models tokenize your actual domain vocabulary before selection — tokenization quality is a critical but often overlooked factor in embedding quality.
Question 10 - Advanced Text Preprocessing Pipeline Optimization
A media company is processing 2 million news articles per day for a content recommendation system using Amazon SageMaker. The preprocessing pipeline must handle HTML stripping, tokenization, stop word removal, domain-specific entity masking (e.g., masking celebrity names to prevent bias while preserving genre/location tokens), and document-level feature extraction. The current pipeline runs on AWS Glue with a Python script but takes 6 hours per batch, missing the 2-hour SLA for daily model retraining.
Which optimization should the ML engineer apply? (Select ONE)
- A) Migrate the text preprocessing to Amazon EMR with Apache Spark and optimized NLP libraries (Spark NLP with GPU acceleration), enabling distributed tokenization and entity masking across cluster nodes.
- B) Deploy the preprocessing as AWS Lambda functions triggered by S3 events for each article upload, ensuring real-time processing of each document.
- C) Use Amazon Bedrock to generate preprocessed summaries of each article, replacing the tokenization pipeline entirely.
- D) Use Amazon SageMaker Processing with a larger instance type running the same Python script, since vertical scaling always improves performance.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Option Analysis
- A is Correct: Migrating to Amazon EMR with Apache Spark enables distributed processing across cluster nodes. Spark NLP provides optimized, parallelizable tokenization and entity masking operations specifically designed for large-scale text processing. GPU acceleration on EMR further speeds up transformer-based tokenization and entity masking for 2 million articles per day.
Distractor Analysis
- B is Incorrect: Lambda functions are limited to 15 minutes of execution time, which is insufficient for comprehensive text preprocessing (HTML stripping, entity masking, full tokenization) of very long news articles. Also, NAWS Glue's batch processing is more efficient for 2 million articles than per-record Lambda invocations, which would incur significant orchestration overhead.
- C is Incorrect: Amazon Bedrock summarization does not perform the required preprocessing tasks (HTML stripping, tokenization, domain-specific entity masking). It also generates natural language summaries rather than the structured token-level features needed for document-level feature extraction and subsequent model training.
- D is Incorrect: Vertical scaling (using a larger instance) has diminishing returns – a single instance cannot parallelize across 2 million articles efficiently. The bottleneck is not CPU/GPU capacity but the sequential processing of unstructured text. Distributed processing across cluster nodes provides horizontal scalability that addresses this bottleneck.
Key Takeaway: For large-scale text preprocessing, distributed processing (Spark on EMR) provides the throughput that sequential Python scripts cannot achieve, regardless of instance size.