NeMo (Neural Modules) is a toolkit for creating AI applications built around neural modules, conceptual blocks of neural networks that take typed inputs and produce typed outputs. Such modules typically represent data layers, encoders, decoders, language models, loss functions, or methods of combining activations.
NeMo makes it easy to combine and re-use these building blocks while providing a level of semantic correctness checking via its neural type system. As long as two modules have compatible inputs and outputs, it is legal to chain them together. An application built with NeMo is a Directed Acyclic Graph (DAG) of connected modules.
NeMo's API is designed to be framework-agnostic, but currently only PyTorch is supported.
NeMo follows a lazy execution model: no computation is done until an action (such as optimizer.optimize(...) is called.
The toolkit comes with extendable collections of pre-built modules for automatic speech recognition (ASR) and natural language processing (NLP). Furthermore, NeMo provides built-in support for distributed training and mixed precision on the latest NVIDIA GPUs.
NeMo consists of:
- NeMo Core: fundamental building blocks for all neural models and type system.
- NeMo collections: pre-built neural modules for particular domains such as automatic speech recognition (nemo_asr) and natural language processing (nemo_nlp).
Introduction
See this video for a quick walk-through.
Requirements
- Python 3.6 or 3.7
- PyTorch 1.2 with GPU support
- NVIDIA APEX. Install from here: https://github.com/NVIDIA/apex
Documentation
See examples/start_here to get started with the simplest example. The folder examples contains several examples to get you started with various tasks in NLP and ASR.
Getting started
You can use our NGC PyTorch container which already includes all the requirements above.
- Pull the docker:
docker pull nvcr.io/nvidia/pytorch:19.08-py3
- Run:
nvidia-docker run -it --rm -v <nemo_github_folder>:/NeMo --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 nvcr.io/nvidia/pytorch:19.08-py3
cd /NeMo
and then continue with the following steps.
Note
For step 2 and 3, if you want to use NeMo in development mode, use:
pip install -e .
instead of
pip install .
- Clone the repository
git clone https://github.com/NVIDIA/NeMo.git
- Go to NeMo folder and install the toolkit:
cd NeMo
pip install .
- Install the collection you want.
# Install the ASR collection from collections/nemo_asr
apt-get install libsndfile1
cd collections/nemo_asr
pip install .
# Install the NLP collection from collections/nemo_nlp
apt-get install libsndfile1
cd collections/nemo_nlp
pip install .
Tutorials
Unittests
This command runs unittests:
./reinstall.sh
python -m unittest tests/*.py