Skip to content

Commit f0bfdf4

Browse files
Merge pull request #51 from pico-lm/decoder-config-fix
Updating decoder config to ignore kwargs Note we do this to avoid any unwanted behavior from the way the parent pretrained model class might handle kwargs by default.
2 parents 044768b + 5b020d3 commit f0bfdf4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/model/pico_decoder.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,12 @@ class PicoDecoderHFConfig(PretrainedConfig):
534534

535535
@classmethod
536536
def from_dict(cls, config_dict: Dict[str, Any], **kwargs) -> "PicoDecoderHFConfig":
537-
# NOTE The typical from_dict method doesn't actually set the attributes unless they are
538-
# defined in the constructor.
539-
540-
pico_config = cls(**kwargs)
541-
542-
# Because this class is just a wrapper around the ModelConfig dataclass, we need to do
543-
# a little extra work to ensure that the attributes are actually set.
544-
for key, value in config_dict.items():
545-
setattr(pico_config, key, value)
537+
"""
538+
Initialize config from a dictionary. Note that no kwargs are passed to the constructor --
539+
this is because with some kwargs special handling is required and can make this class
540+
brittle.
541+
"""
542+
pico_config = cls(**config_dict)
546543

547544
return_unused_kwargs = kwargs.pop("return_unused_kwargs", False)
548545
unused_kwargs = {

0 commit comments

Comments
 (0)