liveBook · Manning

Bidirectional language model

As explained in Natural Language Processing in Action, Second Edition

A bidirectional language model represents or predicts text using contextual information from both preceding and following tokens.

A bidirectional language model uses context from both earlier and later tokens. Unlike a causal model, it can infer a missing or damaged word because the surrounding text is available in both directions. section 10.2.2 section 8.1.3

Its practical boundary is straightforward:

  • Treats text as noncausal when predicting words that occur before or within already known context. section 8.1.3
  • Fits masked-language tasks, such as recovering illegible report text or correcting optical character recognition errors. section 8.1.3
  • Cannot generate ordinary prose strictly left to right, because future-token information would not be available during normal causal generation. section 10.2.2

Recovering corrupted text

Given a report with an intentionally masked word, or a sentence damaged by OCR, a bidirectional model can use both the preceding and following words to infer the missing content. This broader context can improve question-answering accuracy by roughly 5%–10% compared with a default forward-direction model. section 8.1.3

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains bidirectional recurrence, contextual balance, and causal limitations, but stops short of a complete bidirectional training walkthrough.
Examples
Uses masked reports, OCR-corrupted text, question answering, BERT, and bidirectional RNNs as concrete examples.
What you can do after
Apply bidirectional models to recover masked text, correct OCR errors, and improve question-answering systems.
How it connects
Connects bidirectional recurrence with RNNs, gated recurrent units, LSTMs, transformers, masked language models, BERT, and causal language models.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.