Sequence Models (RNNs & LSTMs)
RNNs/LSTMs introduce the sequential, stateful modeling that motivated attention and transformers, so understanding them explains what came next.
Learn it
Recurrent networks process tokens one step at a time, passing a hidden state forward; vanilla RNNs struggle with long dependencies, which LSTMs solve with input/forget/output gates. You will build a bidirectional LSTM over an embedding layer in TensorFlow/Keras and train it on a sentiment task.
By the end you’ll be able to
- Explain why order matters and how RNNs carry state
- Describe the LSTM gating that fixes vanishing gradients; build one
Free resources
Practice
Train a bidirectional LSTM on the IMDB reviews dataset and compare its accuracy to your TF-IDF baseline.
Build it — your output
A trained LSTM sentiment classifier notebook with a metrics comparison against the earlier baseline.
Prove it — check yourself
You’re ready to move on when you can honestly say yes to each:
- Explain the vanishing gradient problem and the LSTM's fix
- Describe what a bidirectional layer adds
- State why RNNs are hard to parallelize
Do it with AI
Use a free AI tool as your tutor and pair-programmer. Copy a prompt below into Claude, ChatGPT, or Gemini (for building, try Cursor or Copilot).
The habit: Try it yourself first — a little struggle is where the learning actually happens. Then ask for a hint before the answer — never copy blindly.
- Understand itClaude / ChatGPT / Gemini
I'm a beginner learning "Sequence Models (RNNs & LSTMs)". Explain it in simple terms with a real-world analogy, then ask me ONE question to check my understanding — don't reveal the answer.
- PracticeClaude / ChatGPT / Gemini
Give me 3 short practice problems on "Sequence Models (RNNs & LSTMs)" (my goal: explain why order matters and how rnns carry state), from easy to hard. Don't include the solutions yet — I'll try them first, then ask you to check.
- Get unstuckClaude / ChatGPT / Gemini
I'm stuck on this exercise about "Sequence Models (RNNs & LSTMs)": [paste your attempt here]. Give me ONE small hint to move forward — do NOT give me the full solution.
- Build & reviewCursor / Copilot
Here is my work for a "Sequence Models (RNNs & LSTMs)" task: [paste your code or answer]. Review it: point out what's wrong and WHY, and suggest improvements — but let me make the fixes myself.
- Prove itClaude / ChatGPT / Gemini
Quiz me on "Sequence Models (RNNs & LSTMs)". Ask me 5 questions one at a time, wait for my answer each time, then tell me if I'm right and briefly why.