Skip to main content

AdamW optimizer

 Nowadays, most LLMs get trained with the AdamW optimizer as opposed to the Adam optimizer. Why? 


There used to be a time when Adam was the king among optimizers, and it didn't make much sense to spend too much time trying to find a better one. This has changed recently, and AdamW has become the default optimizer for the LLM practitioners. 


It all depends on how we apply the regularization terms to the weight parameters. For the typical gradient descent algorithm, if we want to apply an L2​ regularization term, we modify the loss function such that: 


regularized loss = loss + L2 term


Then, we compute the gradient of that new loss to update the model parameters. The goal of the regularization term is to ensure that the weights don't grow too large and it acts as a weight decay mechanism when we update the weights.


In Adam, when we apply the L2 regularization, we regularize the loss function as well but it gets used differently. The loss function is used to compute the first and second moments and when we update the weights, the regularization term is in the numerator and denominator of the gradient update term. Because of it, the effect of the L2 regularization term is minimized and cannot act as a weight decay mechanism.


In AdamW, on the other hand, we DO NOT regularize the loss function and compute the gradient update independent from the regularization term. Only during the weights update do we add the regularization term so that it acts on the weights and not on the loss function. Because of it,  training with AdamW tends to be more stable and leads to models that generalize better! Good to know, right?


Comments

Popular posts from this blog

Python Road map

 

Job site

 1. FlexJobs https://www.flexjobs.com 2. We Work Remotely https://weworkremotely.com 3. Remote.co https://remote.co 4. Remotive https://remotive.io 5. Indeed Remote Jobs https://www.indeed.com/q-Remote-jobs.html 6. LinkedIn Jobs https://www.linkedin.com/jobs 7. Glassdoor https://www.glassdoor.com/ 8. AngelList https://angel.co/jobs 9. Virtual Vocations https://www.virtualvocations.com 10. SkipTheDrive https://www.skipthedrive.com 11. Remote OK https://remoteok.io 12. Working Nomads https://www.workingnomads.co/jobs 13. Jobspresso https://jobspresso.co 14. Upwork https://www.upwork.com 15. Freelancer https://www.freelancer.com 16. Guru https://www.guru.com 17. PeoplePerHour https://www.peopleperhour.com 18. Fiverr https://www.fiverr.com 19. Toptal https://www.toptal.com 20. Dribbble Jobs https://dribbble.com/jobs 21. Behance Jobs https://www.behance.net/joblist 22. Stack Overflow Jobs https://stackoverflow.com/jobs 23. CyberCoders https://www.cybercoders.com 26. ZipRecruiter https:/...

Freelancing site

 Stop believing you can't land a remote job because you are not a U.S. citizen  Here are 30 sites to land a remote job that pays in USD worldwide: People Are Getting Paid in Dollars.Tap into 30 remote job websites and start cashing in. 1. Upwork – A massive freelance marketplace for writers, designers, developers, marketers, and more. https://www.upwork.com 2. Fiverr – Sell microservices starting at $5. Great for creatives, voiceovers, writing, and marketing. https://www.fiverr.com 3. Toptal – Premium platform for top freelancers in tech, design, and finance. Rigorously vetted. https://www.toptal.com 4. FlexJobs – Curated, scam-free listings of remote and flexible jobs across all industries. https://www.flexjobs.com 5. We Work Remotely – High-quality remote job board for devs, marketers, writers, and customer support. https://weworkremotely.com 6. Remote OK – Remote job listings for tech, design, marketing, and customer success. https://remoteok.com 7. PeoplePerHour – Connects...