From 488a6641513face9c03b537b6fe3210dbdb39f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Louf?= Date: Tue, 15 Oct 2019 21:03:32 +0200 Subject: [PATCH] add `is_decoder` attribute to `PretrainedConfig` We currenctly instantiate encoders and decoders for the seq2seq by passing the `is_decoder` keyword argument to the `from_pretrained` classmethod. On the other hand, the model class looks for the value of the `is_decoder` attribute in its config. In order for the value to propagate from the kwarg to the configuration we simply need to define `is_decoder` as an attribute to the base `PretrainedConfig`, with a default at `False`. --- transformers/configuration_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/transformers/configuration_utils.py b/transformers/configuration_utils.py index 8a23be4ff6..228150fc89 100644 --- a/transformers/configuration_utils.py +++ b/transformers/configuration_utils.py @@ -56,6 +56,7 @@ class PretrainedConfig(object): self.torchscript = kwargs.pop('torchscript', False) self.use_bfloat16 = kwargs.pop('use_bfloat16', False) self.pruned_heads = kwargs.pop('pruned_heads', {}) + self.is_decoder = kwargs.pop('is_decoder', False) def save_pretrained(self, save_directory): """ Save a configuration object to the directory `save_directory`, so that it