UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
15.48k stars 2.5k forks source link

AttributeError: module 'transformers' has no attribute 'AdamW' #1574

Open ljvin opened 2 years ago

ljvin commented 2 years ago

File "C:\Users\Dell.conda\envs\xt\lib\site-packages\sentence_transformers\SentenceTransformer.py", line 33, in class SentenceTransformer(nn.Sequential): File "C:\Users\Dell.conda\envs\xt\lib\site-packages\sentence_transformers\SentenceTransformer.py", line 562, in SentenceTransformer optimizer_class: Type[Optimizer] = transformers.AdamW, AttributeError: module 'transformers' has no attribute 'AdamW'

nreimers commented 2 years ago

When calling fit, you can try:

import torch
...
model.fit(..., optimizer_class=torch.optim.AdamW)
ljvin commented 2 years ago

ok,thanks