Skip to content
StackDecode
AI & ML Atlas
Deep LearningarchitectureInteractive simulation

Bidirectional LSTM

Two LSTMs, one reading each direction, joined at every step.

The idea

The same idea as a bidirectional RNN but with LSTM cells, giving longer memory in each direction. For each token, the forward LSTM summarises the left context and the backward LSTM the right context. BiLSTM-CRF was the standard for sequence labelling before transformers.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

1.50.15-0.10.10.05-0.050.1
  • positive
  • negative
  • gate (taller = more open)

A bidirectional RNN reads the sequence forwards and also backwards, so each position sees both sides. The first input (1.5) is the thing worth remembering.

step:
0
1/10

One memory unit unrolled across seven time steps. Try a bigger first input and compare the cells.

Step by step

  1. 1Run a forward LSTM over the sentence.
  2. 2Run a backward LSTM over the reversed sentence.
  3. 3Concatenate their states at each position.
  4. 4Predict a label per position (optionally with a CRF layer).

Where it is used

Named entity recognition, part-of-speech tagging, ELMo-style embeddings.

Watch out for

Twice the compute of a single LSTM.

Related