RNNs process tokens one at a time, carrying a hidden state; they are slow to train (no parallelism over time) and struggle with long dependencies because of vanishing gradients.
LSTMs and GRUs add gates that control what to remember and forget, handling longer dependencies better.
Transformers use self-attention to relate every token to every other token in parallel, scaling better on modern hardware and capturing long-range context; the cost is attention memory and compute that grows quadratically with sequence length.
Loading…