pecos
pecos copied to clipboard
Replace deprecated AdamW from transformers with torch.optim.AdamW
The codebase currently imports AdamW from transformers:
from transformers import AdamW
However, this import has been deprecated and removed in recent Transformer versions (as noted in Hugging Face issue #36954) ([GitHub]). Users now encounter:
ImportError: cannot import name 'AdamW' from 'transformers'
Additionally, a FutureWarning explicitly states:
“This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation
torch.optim.AdamWinstead.” ([GitHub], [Hugging Face Forums])
Suggested change:
- from transformers import AdamW
+ from torch.optim import AdamW
This change ensures compatibility with future versions of the transformers library and avoids deprecation warnings during training.