Library / SDK
makcedward/nlpaug avatar
makcedward/nlpaug

nlpaug: a data augmentation library for text, audio and spectrogram pipelines

Data augmentation for NLP

4,667 stars473 forksJupyter NotebookMIT

At a glance

What is it?
nlpaug wraps character, word, sentence, audio and spectrogram augmentation behind a single Augmenter interface and a Flow pipeline. The design is easy to adopt, but its heaviest augmenters pull in transformer models and external corpora, so the install surface is wider than the README's 'lightweight' framing suggests.
Who is it for?
Adopt nlpaug if you need to expand a small labelled text or audio set and want to try several augmentation strategies through one API before committing to any of them; the Augmenter and Flow abstractions make that comparison cheap.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 7 days ago.
What is it written in?
Mainly Jupyter Notebook, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The gap nlpaug fills between a small labelled set and a model that generalises

Most NLP projects hit the same wall: a few thousand labelled examples, a task where word order and word choice both matter, and no budget for more annotation. nlpaug targets that gap by generating additional training rows from the rows you already have. The README frames it as generating "synthetic data for improving model performance without manual effort", and the augmenter table makes the scope concrete. At character level it offers KeyboardAug and OcrAug, which simulate typing and OCR errors. At word level it offers SynonymAug, AntonymAug, WordEmbsAug, TfIdfAug, SpellingAug, SplitAug and RandomWordAug. At sentence level it offers ContextualWordEmbsForSentenceAug, AbstSummAug and LambadaAug. The same library also covers audio and spectrogram inputs through CropAug, LoudnessAug, MaskAug, NoiseAug, PitchAug, ShiftAug and SpeedAug. The intended user is an engineer who already has a training loop and wants to test whether augmentation moves a metric, not someone building an augmentation research framework from scratch. The breadth is the selling point: one import path covers text and signal, so you can test a text strategy and an audio strategy without adopting two libraries.

Augmenter and Flow: the two objects you actually program against

The README states that "Augmenter is the basic element of augmentation while Flow is a pipeline to orchestrate multiple augmenters together". That is the whole architecture in one sentence. An augmenter is a callable that takes a piece of data and returns a modified version, with parameters controlling how aggressive the modification is. Flow is the composition layer: you register several augmenters and it applies them in sequence, which is how you build something like spelling noise followed by synonym substitution. The repository also documents a change log notebook, "Example of Showing Augmentation History", which implies the library records which operation produced which output. That matters more than it sounds. When augmentation hurts a metric, you need to know whether the damage came from the synonym substitution or from the random deletion, and a history record is what lets you attribute the change. The library additionally exposes extension points: the README links an example notebook titled "How to create custom augmentation", so a custom augmenter is a supported path rather than a fork. Two augmentation methods require you to train a model first: there are separate notebooks for training a TF-IDF model and a LAMBADA model. TfIdfAug and LambadaAug therefore have a setup cost that the pure-dictionary augmenters do not.

Installation and the split between dictionary augmenters and model-backed ones

The README's Installation section is the entry point, and the standard route for a Python project of this shape is pip. The README does not reproduce the exact command in the cleaned text supplied here, so treat the package name as the thing to confirm rather than assuming a flag. The real installation decision is not the command, it is which augmenters you intend to call. SynonymAug relies on WordNet or PPDB synonym data, AntonymAug on WordNet antonym data, and SpellingAug on a spelling mistake dictionary; those are data files that have to be present. ContextualWordEmbsAug feeds surrounding words to BERT, DistilBERT, RoBERTa or XLNet to pick a replacement, and BackTranslationAug "leverage[s] two translation models for augmentation". ContextualWordEmbsForSentenceAug inserts a sentence using XLNet, GPT2 or DistilGPT2 predictions. Those five augmenters are the ones that turn a small install into a large one, because the pretrained weights are fetched or loaded separately from the library itself. A practical approach is to start with the dictionary-based augmenters, confirm the API shape on your own data, and only then add the transformer-backed ones for the cases where synonym substitution is too blunt. The README also notes a "Python 3.12-ready V2 baseline with offline-first tests and GitHub Actions coverage", which is a statement about the test setup, not about the augmenters: offline-first tests do not mean the augmenters run offline.

Where nlpaug is the wrong tool

The clearest failure mode is the offline or air-gapped environment. Any pipeline built on ContextualWordEmbsAug, BackTranslationAug or ContextualWordEmbsForSentenceAug needs pretrained model weights, and those are not shipped inside the library. If your training job runs in a container with no egress, those augmenters will not initialise. The dictionary augmenters are the only ones you can reasonably expect to run without network access, and even they depend on the relevant WordNet, PPDB or spelling dictionary data being present. The second limitation is task fit. Character-level noise from KeyboardAug and OcrAug makes sense when your input is user-typed or scanned text. Applied to clean, professionally edited prose, it teaches the model to be invariant to errors that never occur at inference time, which is a way to lose accuracy rather than gain it. The third limitation is that augmentation is not free accuracy. It multiplies your effective dataset, and therefore your training time, and it changes the label distribution in ways that are easy to miss: replacing a word with its WordNet antonym can flip the sentiment of a sentence while leaving the label untouched. The README does not describe any label-preservation check. That check is on you, and it is the single most common way an augmentation pipeline silently degrades a classifier.

How nlpaug differs from a general augmentation framework

The obvious comparison target is a general-purpose augmentation framework that treats text as one of several supported modalities alongside images. The difference in approach is the unit of augmentation. A general framework typically augments a tensor or an array, so text has to be encoded into a numeric form before augmentation and decoded afterwards, which puts the tokenizer in the middle of the augmentation step. nlpaug augments the text itself, at character, word or sentence granularity, and the augmenter table is organised around exactly that distinction. The consequence is that nlpaug's operations are linguistically aware in a way array-based augmentation cannot be: substituting a synonym via WordNet, or inserting a word that BERT considers likely in context, has no equivalent when you are operating on a fixed-length tensor. The trade-off runs the other way too. Because nlpaug works on strings, it cannot be dropped into a training loop as a tensor transform, and it does not compose with image or tabular augmentation in a single pipeline. If your project is multimodal and text is a minor component, a general framework with a text module will fit your training loop more naturally. If text is the whole problem, nlpaug's granularity is the reason to pick it.

Maintenance, release cadence and what the MIT licence does not cover

The repository is not archived, and the last push recorded in the supplied material is 2026-09-08, but the most recent release listed is 1.1.11 from 2022-07-07, preceded by 1.1.10 in December 2021 and 1.1.9 in December 2021. Repository activity and tagged releases are therefore out of step, which is worth knowing before you pin a version in a requirements file. Pin the release rather than tracking the default branch, because the branch can move without a corresponding tag. The primary language is listed as Jupyter Notebook, which reflects the fact that the examples and several training workflows live in notebooks under example/; the importable library is Python, but if you want to understand an augmenter's behaviour, the notebooks are where the worked examples are. The project is MIT licensed, which is permissive and imposes few conditions on your own code. That licence covers nlpaug. It does not cover the pretrained transformer weights, the WordNet or PPDB synonym data, or the spelling dictionaries that the augmenters load. Those carry their own terms, and a commercial deployment that uses BackTranslationAug is using two translation models whose licences you have to check separately. The same applies to any word embedding files used by WordEmbsAug.

Adoption checklist before you put nlpaug in a training pipeline

Start by deciding which augmenters you will actually call, because that decision determines your dependency and network requirements. If the answer includes ContextualWordEmbsAug, BackTranslationAug or ContextualWordEmbsForSentenceAug, confirm that the model weights can be fetched in your build environment and cached for the training run. If the answer is limited to SynonymAug, AntonymAug, SpellingAug, SplitAug, KeyboardAug, OcrAug or RandomWordAug, confirm the dictionary data is available locally. Then run the augmenters over a sample of your labelled data and inspect the outputs by hand before training anything. The specific thing to look for is label flips, and the augmenters most likely to cause them are AntonymAug and the random insert, substitute, swap and delete operations in RandomAug and RandomWordAug. The change log notebook in the example directory is the mechanism for auditing this, since it shows which operation produced which output. Finally, treat augmentation as an experiment with a control: train the same model with and without augmentation on the same split, and keep the augmented variant only if it wins. The README's claim is that augmentation improves performance without manual effort. The effort is not in generating the data, it is in verifying that the generated data still carries the right label.

Editorial conclusion

Adopt nlpaug if you need to expand a small labelled text or audio set and want to try several augmentation strategies through one API before committing to any of them; the Augmenter and Flow abstractions make that comparison cheap. Do not adopt it if your pipeline must stay offline or dependency-free, because ContextualWordEmbsAug, BackTranslationAug and ContextualWordEmbsForSentenceAug download pretrained models at runtime, and the last release in the supplied material is 1.1.11 from July 2022. Verify first that the specific augmenter you plan to use still resolves its model or dictionary files, and check the licence of every model and dictionary it downloads, since nlpaug's own MIT licence does not cover those.

Official sources

  1. License: MIT
  2. makcedward/nlpaug on GitHub
  3. Project website
  4. README
  5. Releases
Community notes

Community notes