This Best Practices guide is intended for researchers and model developers to learn how to efficiently develop and train speech and language models using NVIDIA NeMo Toolkit.

1. Overview

The toolkit is available open source as well as a docker container on ngc. This guide makes an assumption that the user has already installed using the getting started instructions.

The conversational AI pipeline consists of three major stages: Automatic Speech Recognition (ASR), Natural Language Processing (NLP) or Natural Language Understanding (NLU), and Text-to-Speech (TTS) or voice synthesis. As you talk to a computer, the ASR phase converts the audio signal into text, the NLP stage interprets the question and generates a smart response, and finally the TTS phase converts the text into speech signals to generate audio for the user.The toolkit enables development and training of deep learning models from each domain involved in conversational AI and makes it easy to chain them together.

2. Why NeMo?

Deep learning model development for Conversational AI is complex, it involves defining, building and training several models in specific domains; experimenting several times to get high accuracy, fine tuning on multiple tasks and domain specific data, ensuring training performance and making sure the models are ready for deployment to inference applications.

Neural Modules are logical blocks of AI applications which take typed inputs and produce typed outputs. By separating a model into its essential components in a building block manner, NeMo helps researchers develop state of the art accuracy models for domain specific data faster and easier.

NeMo contains collections of modules that are specific to speech recognition, natural language, and speech synthesis. These modules can be combined to build flexible and reusable pipelines.

A Neural Module’s inputs and outputs all have a Neural Type that describes the semantics, the axis order and meaning, and the dimensions of the input and output tensors. This typing allows Neural Modules to be safely chained together to build models for applications.

NeMo can be used to train new models or perform transfer learning on existing pretrained models. Pretrained weights per module(such as encoder, decoder) help accelerate model training for domain specific data.

ASR, NLP and TTS pretrained models are trained on multiple datasets(including some languages such as Mandarin) and optimized for high accuracy. They can be used with Transfer Learning to quickly get started with NeMo.

NeMo supports developing models that work with multiple languages and comes with pre-trained checkpoints in English and Mandarin.

Nemo has tutorials that help users to train or fine-tune models for a variety of conversational AI tasks, including speech recognition, speaker recognition, speech synthesis, sentiment analysis, and automatic punctuation and capitalization.

The export method provided in NeMo makes it easy to transform a model trained in NeMo to a model that is in an inference-ready format for deployment.

A key area of development in the toolkit is interoperability with other tools used by speech researchers. Data layer for Kaldi compatibility is one such example.

3. NeMo, PyTorch Lightning, and Hydra

Conversational AI architectures are typically very large and require a lot of data and compute for training. NeMo uses Pytorch Lightning for easy and performant multi-GPU/multi-node mixed precision training.

Pytorch Lightning is a high-performance PyTorch wrapper that organizes PyTorch code, scales model training, and reduces boilerplate. PyTorch Lightning has two main components, the LightningModule and the Trainer. The LightningModule is used to organize PyTorch code so that deep learning experiments can be easily understood and reproduced. The Pytorch Lightning Trainer is then able to take the LightningModule and automate everything needed for deep learning training.

NeMo models are LightningModules that come equipped with all supporting infrastructure for training and reproducibility. This includes the deep learning model architecture, data preprocessing, optimizer, checkpointing and experiment logging. NeMo models, like LightningModules, are also PyTorch modules and fully compatible with the broader PyTorch ecosystem. Any NeMo model can be taken and plugged into any PyTorch workflow.

Configuring Conversational AI applications is difficult due to the need to bring together many different Python libraries into one end-to-end system. NeMo uses Hydra for configuring both NeMo models and the PyTorch Lightning Trainer. Hydra is a flexible solution that makes it easy to configure all of these libraries from a configuration file or from the command line.

Every NeMo model has an example configuration file and a corresponding script that contains all configurations needed for training to state-of-the-art accuracy. NeMo models have the same look and feel so that it is easy to do Conversational AI research across multiple domains.

4. Using State-of-the-Art Pretrained models with NeMo

The NVIDIA GPU CLOUD (NGC) is a software repository that has containers and models optimized for Deep Learning. NGC hosts many Conversational AI models developed with NeMo that have been trained to State-of-the-Art accuracy on large datasets. NeMo models on NGC can be automatically downloaded and used for transfer learning tasks.

Pretrained models are the quickest way to get started with Conversational AI on your own data. NeMo has many example scripts and Jupyter Notebook tutorials showing step by step how to fine-tune pretrained NeMo ModelsI on your own domain-specific datasets.

The table below shows all pretrained models available to use. For BERT based models, the model weights provided are ready for downstream natural language understanding tasks. For speech models, it can be helpful to start with a pretrained model and then continue pretraining on your own domain-specific data. Jasper and QuartzNet base model pretrained weights have been known to be very efficient when used as base models. For an easy to follow guide on transfer learning and building domain specific ASR models, you can follow this blog. All pre-trained NeMo Models can be found on the NGC NeMo Collection. Everything needed to quickly get started with NeMo ASR, NLP, and TTS models is there.

Pre-trained models are packaged as a .nemo file and contain the PyTorch checkpoint along with everything needed to use the model. NeMo Models are trained to state-of-the-art accuracy and trained on multiple datasets so that they are robust to small differences in data. NeMo contains a large variety of models such as Speaker Identification and Megatron BERT and the best models in Speech and Language are constantly being added as they become available. NeMo is the premier toolkit for Conversational AI model building and training.

Below you can find description of the models available in NeMo as well as links to tutorials to run training/fine tuning workflow.


Domain Title GitHub URL
NeMo Simple Application with NeMo Voice swap app
NeMo Exploring NeMo Fundamentals NeMo primer
NeMo Models Exploring NeMo Model Construction NeMo models
ASR ASR with NeMo ASR with NeMo
ASR Speech Commands Speech commands
ASR Speaker Recognition and Verification Speaker Recognition and Verification
ASR Online Noise Augmentation Online noise augmentation
NLP Using Pretrained Language Models for Downstream Tasks Pretrained language models for downstream tasks
NLP Exploring NeMo NLP Tokenizers NLP tokenizers
NLP Text Classification (Sentiment Analysis) with BERT Text Classification (Sentiment Analysis)
NLP Question answering with SQuAD Question answering Squad
NLP Token Classification (Named Entity Recognition) Token classification: named entity recognition
NLP Joint Intent Classification and Slot Filling Joint Intent and Slot Classification
NLP GLUE Benchmark GLUE benchmark
NLP Punctuation and Capitialization Punctuation and capitalization
NLP Named Entity Recognition - BioMegatron Named Entity Recognition - BioMegatron
NLP Relation Extraction - BioMegatron Relation Extraction - BioMegatron
TTS Speech Synthesis TTS inference

5. ASR guidance

Question: Is there a way to add domain specific vocabulary in NeMo? If so, how do I do that?”

Answer: QuartzNet and Jasper models are character-based. So pretrained models we provide for these two output lowercase English letters and ‘. Users can re-retrain them on vocabulary with upper case letters and punctuation symbols.

Question: When training, there are “Reference” lines and “Decoded” lines that are printed out. It seems like the reference line should be the “truth” line and the decoded should be what the ASR is transcribing. Why do I see that even the reference lines do not appear to be correct?

Answer: Because our pre-trained models can only output lowercase letters and apostrophe, everything else is dropped. So the model will transcribe “10” as “ten”. Best way forward is to prepare training data first by lowercasing everything and converting numbers from digit representation to word representation using a simple library such ashttps://pypi.org/project/inflect/. Then add uppercase letters and punctuation back using the NLP punctuation model. Here is an example of how this is incorporated:


Question: What languages are supported in NeMo currently ?

Answer: Along with English, Mandarin chinese is supported. A pre-trained model for Mandarin, QuartzNet15x5Base-Zh, is provided that works for that language. For more information, see https://ngc.nvidia.com/catalog/models/nvidia:nemospeechmodels.

6. Data Augmentation

Data augmentation in ASR is invaluable, it comes at the cost of increased training time if samples are augmented during training time. To save training time, it is recommended to pre-process the dataset offline for a one time preprocessing cost and then train the dataset on this augmented training set.

Processing a single sample for example involves:
  • Speed Perturbation
  • Time Stretch Perturbation (Sample level)
  • Noise Perturbation
  • Impulse Perturbation
  • Time Stretch Augmentation (Batch level, Neural Module)

A simple tutorial provided guides users on using the utilities provided in NeMo: https://github.com/NVIDIA/NeMo/blob/main/tutorials/asr/05_Online_Noise_Augmentation.ipynb.

7. Speech Data Explorer

Speech data explorer is a Dash-based tool for interactive exploration of ASR/TTS datasets. It helps find out:
  • Dataset's statistics (alphabet, vocabulary, duration-based histograms)
  • Navigation across dataset (sorting, filtering)
  • Inspection of individual utterances (waveform, spectrogram, audio player

In order to use the tool, it needs to be installed separately, follow directions from here:https://github.com/NVIDIA/NeMo/tree/main/tools/speech_data_explorer

8. Using Kaldi Formatted Data

The Kaldi Speech Recognition Toolkit project began in 2009 at Johns Hopkins University. It is a toolkit written in C++. If researchers have used Kaldi and have datasets that are formatted to be used with the toolkit; they can use NeMo to develop models based on that data.

To load Kaldi-formatted data, you can simply use the KaldiFeatureDataLayer instead of the AudioToTextDataLayer. The KaldiFeatureDataLayer takes in the argument kaldi_dir instead of a manifest_filepath, and this argument should be set to the directory that contains the files feats.scp and text. See the Kaldi Compatibility section of the NVIDIA Neural Modules Developer Guide for more information.

9. Using speech command recognition task for ASR models

Speech Command Recognition is the task of classifying an input audio pattern into a set of discrete classes. It is a subset of Automatic Speech Recognition, sometimes referred to as ”Key Word Spotting”, in which a model is constantly analyzing speech patterns to detect certain "action" classes.

Upon detection of these “commands”, a specific action can be taken. An example Jupyter notebook provided in NeMo shows how to train a Quartznet model with a modified decoder head trained on a speech commands dataset.

Note: It is preferred that you use absolute paths to data_dir when preprocessing the dataset.

10. Natural Language Processing (NLP) Fine Tuning BERT

BERT, or Bidirectional Encoder Representations from Transformers, is a neural approach to pre-train language representations which obtains near state-of-the-art results on a wide array of Natural Language Processing (NLP) tasks, including the GLUE Benchmark and SQuAD Question Answering dataset.

BERT model checkpoints (BERT-large-uncased, BERT-base-uncased) provided can be used for either fine tuning BERT on your custom dataset, or fine tuning downstream tasks, including GLUE benchmark tasks, question answering tasks e.g. SQuAD, joint intent and slot detection, punctuation and capitalization, named entity recognition, and speech recognition post processing model to correct mistakes.

Note: Almost all NLP examples also support RoBERTa and ALBERT models for downstream fine-tuning tasks (see the list of all supported models by calling nemo.collections.nlp.modules.common.lm_utils.get_pretrained_lm_models_list(). The user just needs to specify the name of the model desired while running the example scripts.

11. BioMegatron medical BERT

BioMegatron is a large language model (Megatron-LM) trained on larger domain text corpus (PubMed abstract + full-text-commercial). It achieves state of the art results for certain tasks such as Relationship Extraction, Named Entity recognition and Question Answering. Follow these tutorials to learn how to train and fine tune BioMegatron, Pretrained models are provided on NGC:

12. Fast Training with NeMo

Conversational AI architectures are typically very large and require lots of data and compute for training. Take full advantage of NVIDIA GPUs by enabling mixed-precision and multi-GPU/multi-node training.

Using Mixed Precision

To use mixed-precision with NeMo and PyTorch Lightning, simply set the Trainer flag “precision=16”. The NeMo model will then automatically be trained with Pytorch Native AMP.

  • How does using mixed precision help with training?

    Mixed-precision training with NVIDIA Tensor Cores is faster than training with single precision alone and also maintains high accuracy. Tensor Cores are a specific hardware unit that comes with the Volta and Turing architectures. They accelerate large matrix to matrix multiply-add operations by operating them on half-precision (FP16) inputs and returning the result in full-precision (FP32). Large Conversational AI neural networks usually use massive matrix multiplications and can be significantly sped up with mixed-precision training and NVIDIA Tensor Cores. Some neural network layers are numerically more sensitive than others. PyTorch Native AMP maximizes the benefit of mixed precision training and maintains numeric stability automatically.

Multi-GPU training

  • Why is multi-GPU training preferred over other types of training?
    • Multi-GPU training reduces the total training time by distributing the workload onto multiple compute devices. This is particularly important for large Conversational AI neural networks which would otherwise take weeks to train until convergence. All NeMo models support multi-GPU and multi-node training, which means that no code change is needed to move from single to multi-GPU training. Enable multi-GPU and multi-node training with the PyTorch Lightning Trainer by specifying “gpus” and “num_nodes” flags. Note, multi-node training requires a properly setup environment such as a SLURM cluster.
  • What is the difference between multi-GPU and multi-node training?
    • Multi-GPU training is training on a single compute workstation or server with multiple GPUs.
    • Multi-node training is training on multiple compute servers with multiple GPUs. Multi-node training is needed to continue scaling the total number of GPUs used for training. Multi-node training requires a distributed compute cluster such as SLURM so that each node can easily communicate with each other. The underlying inter-node network topology and hardware will play a large role in achieving full performance.
    • No code changes are needed to enable multi-GPU and multi-node training with NeMo.
    • Underlying inter node network topology and type to achieve full performance, such as HPC-style hardware such as NVLink, InfiniBandnetworking, or Ethernet.

  • What is the difference between multi-GPU and multi-node training?

    Multi-node is an abstraction of multi-gpu training, which requires a distributed compute cluster, where each node can have multiple GPUs. Multi-node training is needed to scale training beyond a single node to large amounts of GPUs.

    From the framework perspective nothing changes from moving to multi-node training. However, a master address and port need to be set up for internode communication. Multi-GPU training will then be launched on each node with these information passed. You might also consider the underlying inter node network topology and type to achieve full performance, such as HPC-style hardware such as NVLink, InfiniBandnetworking, or Ethernet.

13. Exporting models

Modules fine-tuned or trained in NeMo can be exported for efficient deployment in variety of formats. The nemo.core.classes.exportable.Exportable contains API enabling export

def export(
        output: str,
        onnx_opset_version: int = 12,
        try_script: bool = False,
        set_eval: bool = True,
        check_trace: bool = True,
        use_dynamic_axes: bool = True,

The recommended format to export your modules is ONNX. However, not all modules may support export to all formats. "PYTORCH" target will work for all modules and will simply save the module's weights in a Pytorch checkpoint.

For core ASR models such as Jasper and QuartzNet all 4 formats will work. Example scripts for export to Jarvis ASR service could be found under the scripts folder in the NeMo repository.

Here is an example of a “NeMo Model”:https://github.com/NVIDIA/NeMo/blob/v0.11.0/examples/asr/QuartzNetModel.ipynb For ASR, specifically, A NeMoModel is a kind of NeuralModule which contains other neural modules inside it. NeMoModel can have other NeuralModules inside and their mode, and topology of connections can depend on the mode in which the NeMo model is used (training or evaluation).Exporting to .nemo file greatly simplifies the experience of deployment with Jarvis.

14. Tips/Tricks/Areas for Optimization and FAQs

Are there areas where performance can be increased?
  • You should try using mixed precision for improved performance. Note that typically when using mixed precision memory consumption is decreased and larger batch sizes could be used to further improve the performance.
  • When fine-tuning ASR models on your data it is almost always possible to take advantage of NeMo's pre-trained modules. Even if you have different target vocabulary, or even different language - you can still try starting with pre-trained weights from Jasper/QuartzNet *encoder* and only adjust *decoder* for your needs.
What is the recommended sampling rate for ASR?
  • -The released models are based on 16 KHz audio, so use the models with 16 KHz audio. Reduced performance should be expected for any audio that is upsampled from a sampling frequency less than 16 KHz data.
How do we use this toolkit for audio with different type of compression and frequency than the training domain for ASR?
  • You have to match the compression and frequency.
How to replace the 6-gram out of the ASR model with custom language model? 2) what is the language format supported in NeMo?



This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality.

NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice.

Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete.

NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document.

NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk.

NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs.

No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA.

Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices.


VESA DisplayPort

DisplayPort and DisplayPort Compliance Logo, DisplayPort Compliance Logo for Dual-mode Sources, and DisplayPort Compliance Logo for Active Cables are trademarks owned by the Video Electronics Standards Association in the United States and other countries.


HDMI, the HDMI logo, and High-Definition Multimedia Interface are trademarks or registered trademarks of HDMI Licensing LLC.


ARM, AMBA and ARM Powered are registered trademarks of ARM Limited. Cortex, MPCore and Mali are trademarks of ARM Limited. All other brands or product names are the property of their respective holders. "ARM" is used to represent ARM Holdings plc; its operating company ARM Limited; and the regional subsidiaries ARM Inc.; ARM KK; ARM Korea Limited.; ARM Taiwan Limited; ARM France SAS; ARM Consulting (Shanghai) Co. Ltd.; ARM Germany GmbH; ARM Embedded Technologies Pvt. Ltd.; ARM Norway, AS and ARM Sweden AB.


OpenCL is a trademark of Apple Inc. used under license to the Khronos Group Inc.


NVIDIA, the NVIDIA logo, and CUDA, CUDA Toolkit, GPU, NVLink, NVIDIA Ampere GPU architecture, NVIDIA Deep Learning SDK, NVIDIA Developer Program, NVIDIA GPU Cloud, NVIDIA NeMo, Turing, and Volta are trademarks and/or registered trademarks of NVIDIA Corporation in the United States and other countries. Other company and product names may be trademarks of the respective companies with which they are associated.