Serialization error when tokenizer_config key matches function name in PreTrainedTokenizerBase #30796
Labels
Core: Tokenization
Internals of the library; Tokenization.
Good Second Issue
Issues that are more difficult to do than "Good First" issues - give it a try if you want!
transformers/src/transformers/tokenization_utils_base.py
Lines 2449 to 2451 in 37bba2a
When one of the keys in
self.init_kwargs
matches the name of a function in PreTrainedTokenizerBase (e.g.,add_special_tokens
), this for loops replaces the value for that key intokenizer_config
with the function object, which is not serializable, thus causing an error duringsave_pretrained
.To solve this issue, one option is to add an assert in the
__init__
function that throws an error if one of the keys matches an existing attribute/function on thePreTrainedTokenizerBase
:transformers/src/transformers/tokenization_utils_base.py
Line 1569 in 37bba2a
This error was also raised in the Stack Overflow issue below:
https://stackoverflow.com/questions/78062739/huggingface-transformers-error-when-saving-model-typeerror-object-of-type-meth
The text was updated successfully, but these errors were encountered: