Save (.nemo) and restore punctuation and capitalization models
State: closed | Pull request: no
Labels: name: bug

Hi,

I'm following this tutorial to train a punctuation and capitalization model: https://github.com/NVIDIA/NeMo/blob/stable/tutorials/nlp/Punctuation_and_Capitalization.ipynb

The model is initialized with bert-base-uncased. I use `model.save_to(save_path="mymodel.nemo")` to export the trained model and use `PunctuationCapitalizationModel.restore_from(restore_path="mymodel.nemo")` to load it in a separate script. I got this error:
```
prospectiveTraceback (most recent call last):
  File "punctuation_server.py", line 58, in <module>
    server = PunctuationCapitalizationServer()
  File "punctuation_server.py", line 23, in __init__
    restore_path="/home/boliang/punctuation_and_capitalization/mymodel.nemo"
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/collections/nlp/models/nlp_model.py", line 428, in restore_from
    return super().restore_from(restore_path, override_config_path, map_location, strict, return_config)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/core/classes/modelPT.py", line 482, in restore_from
    return cls._default_restore_from(restore_path, override_config_path, map_location, strict, return_config)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/core/classes/modelPT.py", line 433, in _default_restore_from
    instance = cls.from_config_dict(config=conf)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/core/classes/common.py", line 471, in from_config_dict
    instance = cls(cfg=config)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/collections/nlp/models/token_classification/punctuation_capitalization_model.py", line 57, in __init__
    self.setup_tokenizer(cfg.tokenizer)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/collections/nlp/models/nlp_model.py", line 110, in setup_tokenizer
    vocab_file = self.register_artifact(config_path='tokenizer.vocab_file', src=cfg.vocab_file)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/collections/nlp/models/nlp_model.py", line 61, in register_artifact
    return super().register_artifact(config_path, src, verify_src_exists=verify_src_exists)
  File "/home/boliang/anaconda3/envs/speech_translation/lib/python3.7/site-packages/nemo/core/classes/modelPT.py", line 238, in register_artifact
    assert os.path.exists(return_path)
AssertionError
```

Checked `modelPT.py` and found that it seems this file is missing: `/tmp/tmp5t7keady/e751620140c8488d9f23db68c172a1aa_tokenizer.vocab_file`. Then I extracted the saved model and got: `model_config.yaml` and `model_weights.ckpt`. While I tried to untar the pretrained model `punctuation_en_bert.nemo` and got: `manifest.yaml`, `model_config.yaml`, `model_weights.ckpt`, `tokenizer_vocab_dict.json`, and `tokenizer.vocab_file`. It looks like the model I trained dose not have tokenizer vocab files. Is this the reason I got the error above? How should I fix it?