Bidirectional recurrent neural network

Also known as: BRNN · bidirectional RNN · BiLSTM

On this page 7

A bidirectional recurrent neural network (BRNN) is a recurrent architecture that processes a sequence with two separate hidden layers running in opposite directions, one from the first element to the last and one from the last to the first, and combines their states at every position. In neural networks for artificial intelligence, it gives each output access to both preceding and following context, which a standard unidirectional recurrent neural network cannot provide.

Introduced by Schuster and Paliwal in 1997, the design became a workhorse of speech recognition and natural language processing, most often in its BiLSTM form built from long short-term memory cells. A bidirectional RNN requires the entire input sequence to be available before producing outputs, which makes it ideal for labeling and encoding tasks but unsuitable for real-time generation.

How a bidirectional RNN combines two passes

A bidirectional recurrent neural network contains a forward layer that computes hidden states from time step 1 to T and a backward layer that computes states from T to 1. The two layers have independent weights and do not exchange information during their passes. At each position t, the forward state summarizes everything before and including t, while the backward state summarizes everything after and including t.

The two states are then merged into one representation, most commonly by concatenation, which doubles the hidden size seen by the next layer. An output layer, such as a softmax classifier, reads this merged vector. Training uses backpropagation through time in both directions, and the two passes can be computed in parallel because neither depends on the other.

The table below lists the main components and what each contributes.

ComponentInput it readsRole
Forward layerElements 1 to tEncodes left or past context
Backward layerElements T to tEncodes right or future context
Merge operationBoth hidden states at tBuilds one context-rich vector
Output layerMerged vectorProduces label, score or embedding
Recurrent cellPrevious state and current inputVanilla RNN, LSTM or GRU unit
Components of a bidirectional recurrent layer

Cell types and merge strategies

The bidirectional pattern works with any recurrent cell, but the choice of cell strongly affects performance. Plain RNN cells suffer from the vanishing gradient problem, so practical systems almost always use gated cells that preserve information over longer spans.

CellGatingTypical use
Vanilla RNNNoneTeaching and very short sequences
LSTM (BiLSTM)Input, forget and output gatesTagging, speech, long dependencies
GRU (BiGRU)Update and reset gatesSimilar tasks with fewer parameters
Recurrent cells used inside bidirectional layers

Merge strategy is a second design choice. Concatenation preserves both directions fully and is the default; summation and averaging keep the hidden size constant; elementwise multiplication is rare. Deep models stack two to four bidirectional layers, with each layer reading the merged outputs of the layer below, and often add dropout between layers.

How BRNNs compare with neighboring architectures

A bidirectional RNN sits between the unidirectional recurrent neural network and the Transformer encoder in its handling of context. The comparison below shows where it fits.

ArchitectureContext per positionParallelism over time
Unidirectional RNNPast onlySequential
Bidirectional RNNPast and futureSequential within each direction
Transformer encoderFull sequence via self-attentionFully parallel
Decoder with causal maskingPast onlyParallel in training
Bidirectional state space modelPast and futureParallel scan
Bidirectional RNNs and related sequence models

Transformer encoders such as BERT largely replaced BiLSTMs because self-attention connects any two positions directly and trains efficiently on modern accelerators. Nevertheless, a BRNN still has linear cost in sequence length and a small memory footprint, which keeps it attractive for long sequences on limited hardware.

Typical applications and when to choose one

A bidirectional recurrent neural network suits offline sequence labeling, where the full input is known and each position needs a decision informed by its surroundings. Classic applications include named entity recognition, part-of-speech tagging, phoneme classification, handwriting recognition and protein secondary structure prediction.

SituationRecommendationReason
Tagging complete sentencesUse a BiLSTM or BiGRUFuture words disambiguate labels
Streaming speech with strict latencyAvoid full bidirectionalityBackward pass needs future frames
Text generationAvoidFuture tokens do not exist yet
Encoder for sequence-to-sequence modelUse a BRNN encoderSource sentence is fully known
Edge device with long sensor windowsConsider a small BiGRULinear cost and low memory
Deciding whether a bidirectional RNN fits the task

A frequent pairing is BiLSTM with a conditional random field output layer, often called BiLSTM-CRF, which enforces valid label transitions in tagging schemes. For near-real-time use, engineers apply limited lookahead, running the backward layer over short chunks of future frames instead of the whole utterance.

Limitations and common mistakes

The defining limitation is non-causality: a bidirectional layer cannot produce an output until the sequence ends. Computation is also twice that of a unidirectional layer of the same width, and sequential recurrence limits training speed on long sequences.

  • Using a BRNN for autoregressive generation leaks future information during training and fails at inference.
  • Ignoring padding in the backward pass lets padding tokens corrupt backward states; sequence masking or packed sequences prevent it.
  • Comparing hidden sizes naively overlooks that concatenation doubles the output dimension.
  • Expecting very long-range memory remains unrealistic, since gated cells still degrade over thousands of steps.

Understanding it simply

Picture reading a sentence where one word is smudged. You look at the words before it. You also look at the words after it. Together they tell you what the word must be.

A bidirectional recurrent neural network does the same thing. One part reads the sentence from start to end. Another part reads it from end to start. At each word, the network combines both readings to decide. The only drawback is that it must wait for the whole sentence first.

Applied in practice

A hospital analytics team needs to extract medication names, doses and frequencies from free-text discharge notes. The phrase “5 mg” can belong to a drug mentioned before or after it, so each word needs context from both sides to be labeled correctly.

The team trains a two-layer BiLSTM-CRF tagger with 256 hidden units per direction on about 3,000 annotated notes. Because notes are processed in nightly batches, the model’s need for the complete text causes no delay. The tagger reaches strong agreement with clinical annotators on dose and frequency fields, runs on a standard CPU server in minutes for a full day of notes, and gives pharmacists a structured medication list for reconciliation without requiring a large Transformer deployment.