A long-range dependency links distant elements in a sequence when interpreting one element requires information from far earlier in the input. In language modeling, the next-word prediction may depend on the entire preceding sequence rather than only the current word. section 8.1.2 section 8.1.1
Sequence models handle this requirement by carrying context forward, but the choice of model and training window matters:
- An RNN uses a hidden state containing a summary of earlier inputs, allowing each prediction to use the current input together with accumulated sequence information. section 8.1.2
- Standard RNNs handle short-term dependencies more easily than longer-range dependencies, so preserving distant context remains a central challenge. section 8.1.2
- Training sequences that are too short can prevent the model from learning long-range dependencies, while longer sequences can slow training. section 8.3.2 section 12.2.2
Predicting the next word
For “a frog has four legs,” the prediction of “legs” should use “a frog has four,” not just “four.” RNN processing carries this earlier context through successive hidden states. section 8.1.2
Figure 8.1 How a layer of recurrent neurons unfolds through time. When a recurrent neural network makes a prediction on sequential data, it takes the hidden state from the previous time step, h(t – 1), along with the input at the current time step, x(t), and generates the output, y(t), and the updated hidden state, h(t). The hidden state at time step t captures the information in all previous time steps, x(0), x(1), …, x(t).
The unfolded recurrent layer shows how each step combines the current input x(t) with the previous hidden state h(t−1), producing an output and updated state. section 8.1.2


