Unverified Commit 216dff75 authored by fleance's avatar fleance Committed by GitHub
Browse files

Do not warn about unexpected decoder weights when loading T5EncoderModel and...

Do not warn about unexpected decoder weights when loading T5EncoderModel and LongT5EncoderModel (#26211)

Ignore decoder weights when using T5EncoderModel and LongT5EncoderModel

Both T5EncoderModel and LongT5EncoderModel do not have any decoder layers, so
loading a pretrained model checkpoint such as t5-small will give warnings about
keys found in the model checkpoint that are not in the model itself.

To prevent this log warning, r"decoder" has been added to _keys_to_ignore_on_load_unexpected for
both T5EncoderModel and LongT5EncoderModel
parent 38e96324
...@@ -2152,6 +2152,7 @@ class LongT5ForConditionalGeneration(LongT5PreTrainedModel): ...@@ -2152,6 +2152,7 @@ class LongT5ForConditionalGeneration(LongT5PreTrainedModel):
) )
class LongT5EncoderModel(LongT5PreTrainedModel): class LongT5EncoderModel(LongT5PreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight"] _tied_weights_keys = ["encoder.embed_tokens.weight"]
_keys_to_ignore_on_load_unexpected = [r"decoder"]
def __init__(self, config: LongT5Config): def __init__(self, config: LongT5Config):
super().__init__(config) super().__init__(config)
......
...@@ -1866,6 +1866,7 @@ class T5ForConditionalGeneration(T5PreTrainedModel): ...@@ -1866,6 +1866,7 @@ class T5ForConditionalGeneration(T5PreTrainedModel):
) )
class T5EncoderModel(T5PreTrainedModel): class T5EncoderModel(T5PreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight"] _tied_weights_keys = ["encoder.embed_tokens.weight"]
_keys_to_ignore_on_load_unexpected = [r"decoder"]
def __init__(self, config: T5Config): def __init__(self, config: T5Config):
super().__init__(config) super().__init__(config)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment