Fine-tuning Data Efficiency › Data Augmentation for NLP
Language AI HandbookAll chapters Fine-tuning Data Efficiency › Data Augmentation for NLPOne section · Sections in this chapter4 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Data augmentation artificially expands the training set by creating modified versions of existing examples. While augmentation has been especially effective for computer vision (random crops, rotations, color changes), text augmentation is more challenging because small changes can alter meaning sharply. Changing a single word can flip the sentiment of a sentence, and rearranging phrases can make text ungrammatical. The goal is to introduce real variation while preserving the label's validity.
Synonym Replacement
The simplest augmentation replaces words with synonyms:
Original: "The quick brown fox jumps over the lazy dog."
Augmented: "The fast brown fox leaps over the lazy dog."
This preserves the overall meaning while introducing lexical variation. The model learns that both "quick" and "fast," or "jumps" and "leaps," can express similar concepts, reducing its dependence on specific vocabulary. However, synonym replacement has limitations: not all words have good synonyms, context matters (a "bank" isn't always replaceable with "shore"), and some domains have specialized vocabulary where synonyms don't exist.
Back-Translation
Back-translation generates paraphrases by translating text to another language and back:
Original (English): "I love this product"
→ German: "Ich liebe dieses Produkt"
→ English: "I love this product" or "I adore this item"
The translation process naturally introduces variation in word choice and sentence structure while typically preserving meaning. Each translation step makes decisions about how to express concepts, and these decisions may differ from the original phrasing. Using multiple intermediate languages generates more diverse paraphrases, as each language brings its own structural biases and vocabulary choices to the translation process.
Random Operations
Several random operations can augment text data, each introducing a different kind of variation.
Random insertion adds random words from the vocabulary into sentences. While this might seem likely to introduce noise, it encourages the model to focus on key words rather than word order. The model learns to identify important content words even when surrounded by distractors.
Random swap exchanges the positions of two words in a sentence. Again, this seems potentially harmful, but it helps models tolerate minor ordering variations. Many classification tasks do not depend on exact word order, and this augmentation reflects that fact.
Random deletion removes words with some probability. This simulates incomplete or noisy input and prevents over-reliance on specific words. If a model can still classify correctly with some words missing, it has learned more reliable patterns than one requiring all words present.
These random operations work best when applied conservatively. Augmenting too aggressively can create examples that are too different from real data, training the model on a distribution that doesn't match what it will encounter at test time.
Mixup for Text
Mixup, originally developed for images, creates new training examples by interpolating between existing ones. The intuition behind mixup is simple but powerful: by training on blended examples with soft labels, we encourage the model to behave linearly in the space between training points, leading to smoother decision boundaries. For text, this is less straightforward since discrete tokens cannot be interpolated directly. You cannot average the word "happy" and "sad" to get a word that is half-positive. Instead, text mixup operates in embedding space, where continuous representations make interpolation real:
Given two examples and , we create a synthetic example by interpolating their embeddings and labels:
where:
- : the embedding vector for the new synthetic example
- : the label for the new example (a "soft" target)
- : the mixing coefficient sampled from a Beta distribution (), controlling the ratio between the two examples
- : the embeddings of the original examples (typically [CLS] token embeddings or pooled representations)
- : the labels of the original examples
The first equation creates a new embedding that lies somewhere on the line segment connecting the two original embeddings in the high-dimensional space. When , we recover the first example exactly; when , we recover the second. Intermediate values produce embeddings that blend characteristics of both inputs.
The second equation applies the same interpolation to the labels. This is what makes mixup so distinctive: rather than assigning a hard label to the synthetic example, we assign a soft target that shows the mixture. This process smooths the decision boundary in the embedding space by teaching the model that intermediate regions should have intermediate predictions. For instance, if a positive example () is mixed with a negative example () with , the target label becomes , encouraging the model to reflect this ambiguity in its prediction confidence. The model learns that it should be more confident near pure examples and less confident in the interpolated regions between classes.
The Beta distribution for sampling is chosen because it naturally produces values between 0 and 1, and its shape parameter controls how often extreme values (near 0 or 1) versus moderate values (near 0.5) are sampled. Lower shape parameters favor interpolations closer to the original examples, while higher values encourage more balanced mixing.

Contextual Augmentation
More advanced augmentation uses language models themselves to generate variations. Given a sentence, mask out one or more words and use a masked language model to predict replacements:
Original: "The movie was incredibly boring."
Masked: "The movie was incredibly [MASK]."
Augmented: "The movie was incredibly dull." (from MLM prediction)
This approach generates contextually appropriate substitutions that maintain grammaticality better than random synonym replacement. The language model considers the full context when selecting a replacement word. This keeps the augmented word fits naturally in its surroundings. A word like "dull" is chosen because the model has learned that it appears in similar contexts to "boring."
Generative models can create even more diverse augmentations. Given a few examples of a class, a language model can generate entirely new examples in the same style, potentially multiplying the effective dataset size many times over. This approach can create examples that express the same sentiment or class membership through entirely different phrasings. This gives richer training signal than modifications of existing examples.