The primary goal of langugae models is next-word/next-sequence prediction. The transformer architecture is built on the premise of “attention”, this was developed to solve the precursor’s weakness in modeling long-length text sequences (namely recursive neural networks).
In its most basic format, an RNN is a reduce over a sequence with a carried accumulator (in machine-learning terms, the current state).
For context,
reduce(function, iterable, initializer)goes through the iterable from left to right, applying the function at each call. It takes the output offunction(accumulator, item)at each call, returning the new accumulator and moves to the next item. Theinitializeris the starting accumulator/state