Error while saving Longformer pre-trained model
See original GitHub issueThanks for the transformers library!
Information
I am trying to finetune a pre-trained model of type LongformerForQuestionAnswer
on a custom QA dataset using a custom script morphed from run_squad.py
. The pre-trained model is allenai/longformer-large-4096-finetuned-triviaqa
While saving the pretrained model, I run into the following error:
Traceback (most recent call last):
File "examples/question-answering/run_nq.py", line 809, in <module>
main()
File "examples/question-answering/run_nq.py", line 752, in main
global_step, tr_loss = train(args, train_dataset, model, tokenizer)
File "examples/question-answering/run_nq.py", line 248, in train
tokenizer.save_pretrained(output_dir)
File "/home/danishp/git/explain-qa/src/third_party/transformers/src/transformers/tokenization_utils_base.py", line 1368, in save_pretrained
write_dict[key] = value.__getstate__()
AttributeError: 'AddedToken' object has no attribute '__getstate__'
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Longformer
Transformer-based models are unable to process long sequences due to their self-attention operation, which scales quadratically with the sequence length. To ...
Read more >Cannot load longformer model in tensorflow after fine ...
I fine-tuned a longformer model in Tensorflow 2.8.2 on Google Colab ... But now I am getting this error when trying to save...
Read more >Importing Hugging Face models into Spark NLP
In this article we are going to show two examples of how to import Hugging Face embeddings models into Spark NLP, and another...
Read more >Source code for extractive - TransformerSum - Read the Docs
MODEL_CLASSES = ( tuple( "Note: Only showing custom models because old ... Only load the pre-trained weights when # beginning to fit for...
Read more >arXiv:2004.05150v2 [cs.CL] 2 Dec 2020
ness of Longformer in long document modeling. Then, to evaluate Longformer's ability ... pretrained models, we pretrain it with the masked.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just had the same issue with version 3.0.2 while fine-tuning the Robert-base model. Guess, it would have been the same with other BERT-base models. Changing this line solved the issue.
Actually, I never pip-installed the tranformers library, I am just running the cloned github code from a few days ago (this is because I had to edit some parts of the code for my use case).
However, when I pip installed these versions, surprisingly, I don’t see this error. As you suggest, it is possible that some tokenizer changes that were intended for version 3.0.0 crept in.
In the cloned code that I am using, if I change the following line to:
https://github.com/huggingface/transformers/blob/ef0e9d806c51059b07b98cb0279a20d3ba3cbc1d/src/transformers/tokenization_utils_base.py#L1368
The problem is fixed.