Getting errors while running google Collab's code attached to chapter 3

Hi folks,

I am trying to run the preprocessing code that was provided in google collab, and i got below error, while I replaced the line [from transformers import AdamW, AutoTokenizer, AutoModelForSequenceClassification] with the line [from torch.optim import AdamW], the below error got resolved, yet I wanted to know the context of it.
Error : ImportError: cannot import name ‘AdamW’ from ‘transformers’ (/usr/local/lib/python3.11/dist-packages/transformers/init.py)

Also, I got another error in the next cell for which I couldn’t find solution to
Error: ValueError: Invalid pattern: '’ can only be an entire path component**

Kindly help me with this, thank you.

1 Like

Here is the background information regarding the removal of AdamW from the Transoformers library.

In first cell,

!pip install -U datasets evaluate transformers==4.49.0 sentencepiece huggingface_hub fsspec

This change made it work. An older version of the datasets library was being used.

Thanks a lot John !! It helped.

1 Like