When building natural language processing pipelines, developers frequently choose Transformer-based models over Recurrent Neural Networks (RNNs). What architectural difference primarily explains this preference?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Let's talk about why the Transformer took over the NLP world, because this is a big one. Before Transformers came along, we relied on Recurrent Neural Networks, or RNNs. Think of an RNN like a single-lane road where cars have to drive one after the other. To understand the last word in a long sentence, the RNN has to process every single word that came before it, step-by-step. If you've got a long paragraph, by the time the RNN gets to the end, it's already forgotten what happened at the beginning. That's called the vanishing gradient problem, and it's a huge pain. Transformers, though? They throw out the sequential bottleneck. Instead of waiting in line, a Transformer looks at the entire sentence all at once. It uses what's called a self-attention mechanism to instantly connect any word to any other word, no matter how far apart they are. Because it processes everything in parallel, we can train these models on massive GPU clusters in a fraction of the time. Trust me, being able to train models faster while actually remembering the beginning of a document is a total game-changer. So on the exam, remember: RNNs are sequential and forgetful; Transformers are parallel and attentive!
Full explanation below image
Full Explanation
The transition from Recurrent Neural Networks (RNNs) to Transformer architectures represents a paradigm shift in natural language processing (NLP). The primary limitation of RNNs (including LSTMs and GRUs) is their sequential nature. To process the $t$-th word in a sequence, an RNN must first compute the hidden states for all preceding steps $1$ to $t-1$. This sequential dependency prevents parallelization during training, restricting the use of modern multi-GPU hardware. Furthermore, as the sequence length increases, the gradients tend to vanish or explode, making it difficult for the network to retain information from early time steps (the long-range dependency problem).
In contrast, the Transformer architecture discards recurrence entirely in favor of the self-attention mechanism. This design allows the model to ingest the entire sequence of tokens simultaneously. The self-attention mechanism calculates a set of attention weights for each word relative to every other word in the sequence, regardless of their distance. This allows the model to capture semantic relations across long spans of text in a single step. Because the computations for all tokens are independent of prior states, they can be processed in parallel across GPUs, drastically accelerating training efficiency on massive datasets.
Let's evaluate the incorrect choices: - Option A is incorrect because Transformers excel at handling long sequences, whereas RNNs struggle with them. - Option B is incorrect because Transformers are actually more complex to design and implement than standard RNNs due to their multi-head attention and positional encoding systems. - Option D is incorrect because Transformers require training data just like RNNs; they cannot perform deep language tasks without training.