Lesson 2 of 5 Text Preparation, Embeddings and Vector Databases

Augmenting Text for Specialist Domains

This lesson explains how domain-specific augmentation creates more useful training text in fields such as law, medicine and finance while preserving the meaning of domain terms.

Learning outcomes

After completing this lesson, you will be able to:

  • Apply augmentation techniques such as back-translation and FM paraphrasing.
  • Keep augmented data trustworthy.
  • Decide when domain adaptation beyond augmentation is needed.

Augmentation techniques

Synonym replacement swaps words for synonyms, but general thesauri can damage domain terms ("discharge" means something different in medicine and law), so use a domain glossary and protect key terms. Back-translation translates text into another language and back with Amazon Translate, producing natural paraphrases; custom terminology in Translate keeps domain terms unchanged. FM paraphrasing asks a model on Amazon Bedrock to rewrite examples in different styles or to generate new examples for rare classes from a description and a few seeds. Entity substitution swaps names, products or amounts with other valid values to vary examples without changing their label.

Match the pairs

Augmentation techniques

Exam skills 1.2.6

Match each text augmentation technique with what it does.

Log in to try this activity Interactive activities are free with an account.

Keeping augmented data trustworthy

Augmented text can change meaning or even the correct label, for example a paraphrase that reverses the sentiment of a review. A sample of augmented data should therefore be validated, by expert review or with a classifier trained on real data. Generated text that is too similar to the original adds little, and text that drifts off-topic adds noise, so both are filtered out.

Synthetic examples should be tracked, so their effect can be measured and they can be removed if they cause problems, and they must never be placed in the test set, which must reflect real data. Synthetic data generated by a foundation model must also respect the model provider's terms of use, some of which restrict using outputs to train other models.

The following table summarises the techniques.

TechniqueAWS supportRisk to manage
Synonym replacement with glossaryCustom code, domain glossaryChanging domain meaning
Back-translationAmazon Translate with custom terminologyMistranslated domain terms
FM paraphrasing and generationAmazon BedrockHallucinated or wrong labels
Entity substitutionComprehend entities plus listsUnrealistic combinations

The following diagram shows the steps used to augment a set of only 150 training examples for a rare claim type.

Augmenting the 150 subrogation examples. Back-translation through French and German with Amazon Translate and a custom terminology file keeps subrogation and policy codes unchanged; a Bedrock model writes 300 new descriptions from anonymised seeds, and adjusters review a 10% sample; all synthetic examples are tagged and kept out of the test set.
The scenario is illustrative.
Select all that apply

Trust the synthetic examples

Exam skills 1.2.6 · 1.3.6

Identify the practices that keep augmented text useful rather than harmful.

Log in to try this activity Interactive activities are free with an account.

Domain adaptation beyond augmentation

When the model's vocabulary is the problem rather than the number of examples, consider a domain pre-trained model from SageMaker JumpStart, continued pre-training on domain text (covered in the next module), or, for FMs, adding definitions of domain terms to prompts and RAG context.

Scenario questions

Beyond augmentation

Exam skills 1.2.6 · 2.1.2

Choose how to adapt a model to specialist language when augmentation is not enough.

Log in to try this activity Interactive activities are free with an account.
Worked example

Rare insurance claim types

A claims classifier has 20,000 examples, but only 150 for "subrogation" claims, a legal term. The model rarely predicts this class.

  • Back-translate the 150 examples through French and German with Amazon Translate, using a custom terminology file that keeps "subrogation" and policy codes unchanged.
  • Ask a Bedrock model to write 300 new claim descriptions from anonymised seed examples, then have adjusters review a 10% sample.
  • Tag all synthetic examples and keep the test set entirely real.

Recall on subrogation claims rises because the model now sees varied phrasings. Using a general synonym tool would have replaced "subrogation" with unrelated words and corrupted the label.

Check yourself

How can paraphrases be created with Amazon Translate?

Show answer

By back-translation: translating text into another language and back.

Exam Tips

Remember for the exam

  • Protect domain terms during augmentation with glossaries or custom terminology.
  • Back-translation with Amazon Translate creates natural paraphrases.
  • Bedrock models can generate synthetic examples for rare classes.
  • Review samples of synthetic data and keep the test set real.
  • Vocabulary gaps may need domain models or continued pre-training instead.