All models

CharRNN

A two-layer LSTM language model that predicts the next character of a text, one character at a time.

Language · 2,102 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

This diagram has 2,102 operations (201 KB) and is drawn when you ask.

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
240.3K
Operations
2,102
Framework
PyTorch
Recurrent
Yes
Published
2015
Authors
Andrej Karpathy
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m338
Graph hash
4f82a5943709ef10af7b2b28f06117f7d8ca634b05a3d0f9c78d4856c35e12b1
Skeleton hash
bd21acfac23b93f9376c6cf76af17ba9af35927171ba422fa637cb08e7ffc2e9
Architecture hash
0b02be4d16308ef90bb8831d81103a87bdeb8177dc7d706a43c236666fa6792f
Diagram SHA-256
95918ad96dc919a38a7deb5e5eceac0c5e480c821c657ca2dfedf60dbd3d8e93
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

char-rnn is a character-level language model: a recurrent network that takes a text file and learns to predict the next character in a sequence. Once trained, it can generate new text character by character that looks like its training data. Andrej Karpathy released the code together with his blog post The Unreasonable Effectiveness of Recurrent Neural Networks.

The post describes encoding each character as a 1-of-k vector and feeding the characters to the network one at a time. The output at every step is a vector with one dimension per character, read as the confidence that each character comes next. The released code allows multiple layers and uses a Long Short-Term Memory (LSTM) network in place of a vanilla RNN. This model has two layers; the README advises always using two or three.

To generate text, the post samples a character from the predicted distribution and feeds it back in to get the next one. A temperature setting divides the predicted log probabilities before the Softmax, and lower values make the predictions more likely but more conservative. A paper that uses character-level language models as a testbed for analysis reports interpretable LSTM cells that keep track of long-range dependencies such as line lengths, quotes and brackets.

Key idea. The blog post released code for training character-level language models based on multi-layer LSTMs, which learn to generate text like their training data one character at a time.

  • char-rnn
  • CharRNN
  • character-level language model
  • character-level RNN
  • LSTM language model
  • text generation
  • recurrent neural network
  • next character prediction

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{characterrnnlanguagemodel2015,
  title = {The Unreasonable Effectiveness of Recurrent Neural Networks},
  author = {Andrej Karpathy},
  year = {2015}
}