Case Study 07

Char-RNN Text Generation

Character-level RNN & LSTM language models, cells built by hand

2025
PythonPyTorchNumPyMatplotlib
Key impact
Built RNN and LSTM cells from scratch in PyTorch — explicit input/hidden/bias weight matrices and gate computations (input, forget, output with tanh/sigmoid) — instead of relying on the built-in nn.RNN / nn.LSTM modules.
CHAR-RNN / LSTMheelllloo·cells built by hand · gating
Representative mockup

What I did

4
  1. 01

    Built RNN and LSTM cells from scratch in PyTorch — explicit input/hidden/bias weight matrices and gate computations (input, forget, output with tanh/sigmoid) — instead of relying on the built-in nn.RNN / nn.LSTM modules.

  2. 02

    Assembled character-level language models on top of those cells and trained them for autoregressive text generation.

  3. 03

    Engineered the sequence-construction data pipeline (windowed character sequences) and a sampling-based generation loop.

  4. 04

    Contrasted the basic RNN against the LSTM to demonstrate how gating mitigates vanishing gradients on longer dependencies.

Tech stack

PythonPyTorchNumPyMatplotlib