Introduction to RNNs
You’ll learn why sequential data needs memory, because the meaning of each word can depend on what came before. You’ll see how an RNN carries a hidden state forward and uses the same loop to combine new input, previous context, and prediction.
The Problem: Why Sequences Are Hard
We now know how to turn text into token IDs (Tokenization), look up each ID as a dense vector (Embeddings), and transform vectors with a simple neural layer (Neural Network Basics). But each token vector is still independent. The embedding for “bank” is the same whether the sentence is about rivers or money. To make predictions, the model needs to process these vectors in order, building up context as it goes.
You’ve used this feature hundreds of times: typing on your phone, and it predicts what you’ll say next.
Type “I’m going to the” and your phone suggests: gym, store, beach…
But how does it know? The key insight: context matters. The prediction for “I’m going to the ___” depends entirely on what came before. If you had typed “I’m running to the ___”, the suggestions would shift toward finish line, bathroom, car.
This is the fundamental challenge with sequential data — each piece of information depends on what came before it.
The Big Idea: A Network with Memory
Imagine reading a mystery novel. You don’t forget chapter 1 when you reach chapter 5 — you carry information forward. Clues from early chapters help you understand later events.
Recurrent Neural Networks (RNNs) work the same way. They’re neural networks with a “memory” that gets updated as they process each piece of a sequence.
Here’s the simple loop:
What to look for: Step through the words and watch two things: (1) the memory bubble accumulates words as the RNN reads, and (2) the prediction bars shift at each step. After “I,” the model spreads probability across many verbs. After “I love,” it focuses on pronouns and possessives. After “I love my,” pets and family dominate. Each word narrows the possibilities.
Why Context Changes Everything
Traditional neural networks treat each input independently — they have no memory. That’s like trying to understand a sentence by looking at each word in isolation. RNNs solve this by passing information forward through the sequence.
How It Works: The Core Loop
Let’s break down what happens at each step. Don’t worry about the math yet — just the intuition:
At each timestep:
new_memory = combine(current_input, old_memory)
prediction = transform(new_memory)
That’s it! The network learns how to combine and transform through training.
Here’s that loop in action — watch how each step feeds into the next:
What to look for: The loop cycles through four phases for each word: Read (take in the current word), Update (blend it with existing memory), Predict (output a guess for the next word), Repeat (move to the next word). Watch the word tracker at the bottom: after processing “I,” the model predicts “love.” After processing “love,” it predicts “my.” The same four-step cycle runs for every word in the sequence.
In the Forward Pass, we’ll unpack the real equations, including the weight matrices, the tanh activation, and softmax, and trace through the math step by step.
Key insight: At each step, the hidden state depends on two things:
- The current input (the word just read)
- The previous hidden state (everything seen before)
This is the recurrent connection — information flows forward through time.
Quick Summary
| Concept | What Happens | Intuition |
|---|---|---|
| Sequential data | Each input depends on what came before | ”I’m going to the ___” needs prior words to predict |
| Hidden state | Memory vector updated at each step | Like carrying clues forward through a mystery novel |
| Core loop | Combine(input, memory) → prediction | Two ingredients: what you see now + what you remember |
| Context | Same word means different things in different sequences | ”bank” = river edge or financial institution |
- I can explain why sequential data is harder than independent data
- I understand the “mystery novel” analogy for how RNNs carry memory forward
- I know the two inputs to each RNN step (current input + previous hidden state)
- I can give an example of why context changes a word’s meaning
- I understand why traditional neural networks can’t handle sequences well
Ready to see the real equations and watch the computation unfold? Head to the Forward Pass →