AI and Deep Learning

Why is the Transformer architecture preferred over LSTMs for modern Natural Language Processing?

RO Asked by Robert Taylor · 05-01-2024
0 upvotes 15,715 views 0 comments
The question

I keep reading that LSTMs and GRUs are "dead" in the age of Transformers. Can someone explain in plain English why the Attention mechanism is so much better at handling long-range dependencies in text? I understand that LSTMs have a "memory," so why did the industry shift so quickly toward models like BERT and GPT? I’m trying to justify a hardware upgrade to my boss for GPU-based training.

3 answers

0
JE
Answered on 07-01-2024

The primary reason is parallelization. LSTMs process text sequentially—one word at a time—which makes them incredibly slow to train on large datasets because you can't easily distribute the work across multiple GPUs. Transformers use the "Attention" mechanism to look at every word in a sentence simultaneously. This allows the model to understand the context of a word based on its relationship with every other word, regardless of how far apart they are. This "global" view prevents the vanishing gradient problem that plagued LSTMs when trying to remember information from the beginning of a long paragraph while processing the end.

0
MI
Answered on 09-01-2024

Is your primary concern the training speed or the actual accuracy of the model? For very short sequences, LSTMs can still be quite efficient and less resource-heavy than a massive Transformer. 

RO 11-01-2024

Michael, we are mostly dealing with long-form medical reports, so capturing context across several pages is our main goal. Based on what Jessica said, it sounds like the sequential nature of LSTMs is exactly what’s holding us back. We need that "global" attention to link symptoms mentioned at the start to a diagnosis at the end. I think the speed of training on a GPU cluster will be the final selling point for my boss to move away from our current CPU-based LSTM setup.

0
LA
Answered on 13-01-2024

Transformers simply scale better. As you add more data and more parameters, the performance of Transformers continues to climb, whereas LSTMs tend to plateau much earlier. 

JE 14-01-2024

spot on, Laura. The scalability is exactly why we've seen the jump from millions to billions of parameters in the latest language models we see today.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

World globe icon Country: Canada

Book Free Session