TL;DR
A bidirectional recurrent neural network reads a sequence twice: once from left to right, and once from right to left. Each position then gets two hidden states, one that summarises everything before it and one that summarises everything after it. Joining them gives a representation that uses the whole sequence around that position.
This matters when the meaning of an element depends on what comes later as well as earlier. The price is that the model must see the whole sequence before it can answer, so it cannot be used to predict the next item in real time.
Where you'll see it: in part-of-speech and named-entity tagging, in speech recognition systems that transcribe a complete utterance, and in early pretrained language encoders before transformers took over.
Intuition
Consider the word "Washington" in two sentences. In "Washington signed the bill", you cannot tell whether it is a person or a place from the first word alone. The clue is "signed the bill", which comes after it. A plain left-to-right recurrent network has already committed to its reading of "Washington" by the time it reaches "signed". It never gets to revisit the decision.
A bidirectional network fixes this by reading the sentence twice. One reader goes left to right and keeps a running summary of the past. A second reader goes right to left and keeps a running summary of the future. For each word, you then hold both summaries side by side. When you ask what "Washington" means, you have the words before it and the words after it in front of you.
The plot below makes the trade-off concrete for a sequence of ten tokens. A forward reader at position has seen tokens so far, counting the current one. A backward reader at the same position has seen the current token and the that follow, so in all. Together they cover the whole sequence, with the current token counted twice. The two lines cross at the middle, between positions 5 and 6.
- tokens seen by the forward reader
- tokens seen by the backward reader
Two readers that never talk to each other, merged at the end, is the whole idea. Nothing about the recurrence changes. The network still applies the same update rule at each step; it simply does so twice, in opposite directions.
The math
Setup
Let the input sequence be , where each is a vector, for example an embedding of a word. The forward network produces hidden states in , and the backward network produces in . The arrows only indicate direction; they are not vectors. The two networks have separate weights.
The forward and backward recurrences
The forward recurrence is the usual one from the recurrent neural network, started at the left end:
The backward recurrence runs the same kind of update from the right end, with its own weights:
Here map the input into the hidden space, carry the state from one step to the next, and is applied elementwise. The only difference between the two recurrences is the direction of the index.
Combining the two states
At each position the two states are joined. The most common choice is concatenation:
Other choices include summing the two states or averaging them. Concatenation keeps all the information, at the cost of doubling the size of the next layer. Summing keeps the size the same but mixes the two directions before anything downstream can separate them.
For an output such as a tag or a class, a further layer reads :
where is an output matrix of size (number of classes) by , and is a bias vector.
Training
The network is trained by backpropagation through time, using a loss summed over positions. Gradients flow back through each direction along its own chain of time steps, and the two directions meet only in the loss, through the concatenated states. Because the forward and backward passes do not depend on each other, they can run in parallel. Each pass on its own is still sequential across time, so parallelism helps with throughput but does not remove the step-by-step nature of the recurrence.
Worked examples
For hand arithmetic, the examples below use ReLU, , in place of . The structure is identical. All weights are scalars, with input weight 1 and recurrent weight 0.5 in both directions, and no biases.
The input sequence is , , .
Forward pass (left to right, starting from ):
- .
- .
- .
Backward pass (right to left, starting from the end):
- .
- .
- .
Combined states (concatenation):
- At : . The forward half has seen only , but the backward half already contains information from and .
- At : .
- At : . The backward half has seen only , and the forward half has seen all three inputs.
Notice that the position-1 state, which a forward-only network would have as just , now carries 2.75 from the other direction.
A tagger labels each word of a 12-word sentence. Consider the decision at position .
- The forward state has read positions 1 through 4, so it knows the four words up to and including the current one.
- The backward state has read positions 12 down to 4, so it knows the nine words from the current one to the end.
- Together the two states cover all 12 positions. The current word is seen by both halves, so it is represented twice, and each half contributes a different view of it.
- A forward-only tagger would see only 4 positions. For a decision that depends on a later cue, such as a verb at position 9 that determines whether the word at position 4 is a subject or an object, the bidirectional version has the cue available and the forward version does not.
A chat system must produce a word before the user has typed the next one. Suppose it uses a bidirectional encoder.
- To compute for the current word, the backward reader must start at the end of the sequence.
- The end of the sequence is not known until the user finishes.
- So the backward state cannot be computed at the moment it is needed, and the bidirectional model is unusable for real-time next-word prediction.
Tradeoffs and failure modes
Bidirectionality buys context at the price of latency and a different kind of model. Use it when the whole input is available up front and the answer depends on context from both sides. Avoid it when you must produce outputs as the input arrives.
| Situation | Problem | Better choice |
|---|---|---|
| Tagging or classifying a complete sentence or utterance | None; the full input is available | Bidirectional RNN, or a bidirectional transformer for longer inputs |
| Generating text one token at a time | The backward pass needs the future, which does not exist yet | A unidirectional (causal) model |
| Streaming speech recognition with a latency budget | The backward pass waits for the end of the utterance | Unidirectional model, or a bidirectional model over short chunks |
| Very long sequences | Both passes are still sequential over time, and the vanishing-gradient problem affects both directions | An attention-based model, or a gated cell such as an [[long-short-term-memory |
| Using the model as a language model for scoring | Each token's score uses the token itself through the backward path, so the probability is not a proper next-token distribution | Train a unidirectional model for the probability, and use the bidirectional model only as an encoder |
Some practical failure modes:
- Leakage in training. If the training target leaks into the input, the model learns to copy it and the validation score looks suspiciously good. Check that no label information reaches the input through either direction.
- Doubled cost. Each direction has its own weights, so the parameter count roughly doubles compared with a single RNN of the same width. The memory for activations also doubles during training.
- Asymmetric information. The two directions do not contribute equally at every position. Near the start, the backward half is strong and the forward half is weak. A model that treats them symmetrically may underuse one of them.
History
Mike Schuster and Kuldip Paliwal introduced bidirectional recurrent neural networks in 1997 for speech, where a full utterance is available before recognition begins, and their paper set out the two-direction structure used today.
Alex Graves and Jürgen Schmidhuber combined bidirectional networks with LSTM cells in the mid-2000s and showed strong results on phoneme classification, which made the approach standard for speech tasks. It spread to natural language once researchers started building sequence taggers on top of pretrained word vectors. Huang, Xu and Yu's 2015 bidirectional LSTM-CRF tagger was a widely used example, pairing the two-direction encoder with a conditional random field on top to model dependencies between output tags.
In the late 2010s, pretrained language encoders such as ELMo used bidirectional LSTMs, and then BERT used a bidirectional transformer instead of a recurrent network. Transformers process all positions at once and attend to both sides directly, so the recurrent form of bidirectionality became less common for pretraining. The core idea that context from both sides helps the representation of each position remained.
Check yourself
QuestionA bidirectional RNN runs over a sequence of length 8. How many tokens has the forward reader seen at position 3, and how many has the backward reader seen? Which positions does the combined state cover?Show answer
The forward reader has seen positions 1, 2 and 3, which is 3 tokens, counting the current one. The backward reader has seen positions 8 down to 3, which is 6 tokens. Together they cover all 8 positions, and the current position is seen by both.
QuestionCompute the combined state at for the input , , with scalar weights input 1 and recurrent 0.5 and ReLU activation, and no biases.Show answer
Forward: . Backward: , then . The concatenated state at is . The backward half contributes information from even though the position is at the start.
QuestionWhy is a bidirectional RNN unsuitable for generating text one word at a time, even though it can be trained on the same data?Show answer
Generation must produce the next word before the rest of the text exists. The backward state at a position depends on every later position, so it cannot be computed at generation time. Training works because the whole target sequence is known in advance, which hides the problem. A unidirectional model that uses only earlier positions is the right choice for generation.
QuestionYou are building a tagger for a system that must label each word of a finished document in batch overnight, and the labels depend on words that come later in the sentence. Would you use a bidirectional RNN, and what would you check before trusting the results?Show answer
Yes, a bidirectional RNN fits: the whole document is available, and the labels depend on context from both sides. Before trusting the results, check for leakage: confirm that no label information reaches the inputs through either direction. Compare against a forward-only baseline on sentences where later words matter, to confirm the backward half is actually helping rather than being ignored. Also check the memory budget, since the two directions roughly double the parameter count and activation memory.