TRF015

Models with non-empty _tied_weights_keys must have tie_word_embeddings in their Config.

   
Default Enabled
Scope All models
Source mlinter/trf015.py
Show in terminal mlinter --rule TRF015

What it does

When a PreTrainedModel subclass defines _tied_weights_keys as a non-empty collection, checks that the corresponding configuration file declares a tie_word_embeddings field.

Why is this bad?

Without tie_word_embeddings in the config, users cannot control weight tying behavior. The model ties weights unconditionally, breaking serialization round-trips and preventing fine-tuning with untied heads.

Example

 # configuration_foo.py
 @strict(accept_kwargs=True)
 class FooConfig(PreTrainedConfig):
     hidden_size: int = 768
+    tie_word_embeddings: bool = True

Suppressing this rule

Add a # trf-ignore: TRF015 comment on the flagged line or the line directly above it. See Suppressing rules for whole-file directives and when a suppression is the wrong answer.