| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| from omegaconf.dictconfig import DictConfig |
| from pytorch_lightning.trainer.trainer import Trainer |
|
|
| from nemo.collections.nlp.models.language_modeling.megatron_t5_model import MegatronT5Model |
|
|
| __all__ = ["MegatronBARTModel"] |
|
|
|
|
| class MegatronBARTModel(MegatronT5Model): |
| """ |
| Megatron BART pretraining |
| """ |
|
|
| def __init__(self, cfg: DictConfig, trainer: Trainer): |
| super().__init__(cfg, trainer=trainer) |
|
|
| @property |
| def model_name(self): |
| """Allows child classes to implement models with different data regime""" |
| return "BART" |
|
|
| def _validate_cfg(self): |
| """Class-specific cfg validation""" |
| if self._cfg.data.get('dataset_type', None) != 'bart': |
| raise ValueError( |
| f"cfg.data.dataset_type = {self._cfg.data.get('dataset_type', None)} but 'bart' is expected" |
| ) |
|
|
| if self.num_sentinel_tokens != 0: |
| raise ValueError( |
| f"cfg.tokenizer.num_sentinel_tokens = {self.num_sentinel_tokens} but 0 is expected for 'bart'" |
| ) |
|
|
| @property |
| def _build_train_valid_test_datasets_kwargs(self): |
| """allows child classes to add kwargs to dataset building""" |
| return dict(delete_mask_prob=self._cfg.data.get('delete_mask_prob', 0.0),) |
|
|
| def list_available_models(self): |
| pass |
|
|