Checkpoints¶
There are two main ways to load pretrained checkpoints in NeMo:
Using the
restore_from()
method to load a local checkpoint file (.nemo), orUsing the
from_pretrained()
method to download and set up a checkpoint from NGC.
See the following sections for instructions and examples for each.
Note that these instructions are for loading fully trained checkpoints for evaluation or fine-tuning.
For resuming an unfinished training experiment, please use the experiment manager to do so by setting the
resume_if_exists
flag to True.
Loading Local Checkpoints¶
NeMo will automatically save checkpoints of a model you are training in a .nemo format.
You can also manually save your models at any point using model.save_to(<checkpoint_path>.nemo)
.
If you have a local .nemo
checkpoint that you’d like to load, simply use the restore_from()
method:
import nemo.collections.asr as nemo_asr
model = nemo_asr.models.<MODEL_BASE_CLASS>.restore_from(restore_path="<path/to/checkpoint/file.nemo>")
Where the model base class is the ASR model class of the original checkpoint, or the general ASRModel class.
NGC Pretrained Checkpoints¶
The ASR collection has checkpoints of several models trained on various datasets for a variety of tasks. These checkpoints are obtainable via NGC NeMo Automatic Speech Recognition collection. The model cards on NGC contain more information about each of the checkpoints available.
The tables below list the ASR models available from NGC, and the models can be accessed via the
from_pretrained()
method inside the ASR Model class.
In general, you can load any of these models with code in the following format.
import nemo.collections.asr as nemo_asr
model = nemo_asr.models.ASRModel.from_pretrained(model_name="<MODEL_NAME>")
Where the model name is the value under “Model Name” entry in the tables below.
For example, to load the base English QuartzNet model for speech recognition, run:
model = nemo_asr.models.ASRModel.from_pretrained(model_name="QuartzNet15x5Base-En")
You can also call from_pretrained()
from the specific model class (such as EncDecCTCModel
for QuartzNet) if you will need to access specific model functionality.
If you would like to programatically list the models available for a particular base class, you can use the
list_available_models()
method.
nemo_asr.models.<MODEL_BASE_CLASS>.list_available_models()
Transcribing/Inference¶
You may perform inference and transcribe a sample of speech after loading the model by using its ‘transcribe()’ method:
model.transcribe(paths2audio_files=[list of audio files], batch_size=BATCH_SIZE, logprobs=False)
Setting argument ‘logprobs’ to True would return the log probabilities instead of transcriptions. You may find more detail here: ./api.html#modules The audio files should be 16KHz monochannel wav files.
Automatic Speech Recognition Models¶
Speech Recognition (Languages)¶
English¶
Mandarin¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_zh_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_zh_quartznet15x5 |
stt_zh_citrinet_512 |
EncDecCTCBPEModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_zh_citrinet_512 |
German¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_de_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_de_quartznet15x5 |
Polish¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_pl_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_pl_quartznet15x5 |
Italian¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_it_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_it_quartznet15x5 |
Russian¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_ru_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_ru_quartznet15x5 |
Spanish¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_es_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_es_quartznet15x5 |
Catalan¶
Model |
Model Base Class |
Model Card |
---|---|---|
stt_ca_quartznet15x5 |
EncDecCTCModel |
https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_ca_quartznet15x5 |