Skip to content

Saving a HuggingFaceNmtModel trainer raises AttributeError #386

Description

@ddaspit

Saving a trainer created by HuggingFaceNmtModel.create_trainer raises an AttributeError. Calling save() on the trainer is enough to trigger it. The trained model is not copied to the model path, and the model's engine is not reset.

Affected: _Trainer in machine/translation/huggingface/hugging_face_nmt_model.py.

Versions: main and #363. I found this by reading the code. I have not reproduced it.

Expected: save() saves the model, copies it to the model path, and resets the engine.

Actual: AttributeError: 'str' object has no attribute 'training_args'

Cause: _Trainer.__init__ assigns self._model = model and then calls super().__init__. HuggingFaceNmtModelTrainer.__init__ sets self._model to its first argument, which is the parent model name. save() then reads self._model.training_args from a str. Storing the HuggingFaceNmtModel under a different attribute name would fix it.

Test: no test covers HuggingFaceNmtModel.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      🔖 Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions