B1-I2 · Inline explainer · preview in article context

The encoder reads text with bidirectional attention. Each token can use context from both sides, which matters when a later word changes the meaning of an earlier one. A sentence representation needs that context before it can be compared with another sentence or passage.

Bidirectional contextThe sentence "The bank beside the river was quiet." with the word bank outlined. Schematic connectors run to bank from the earlier word and from the later words; the selected position becomes a contextual representation. Word-level illustration of context; not measured attention.selected wordcontext connectioncontextual representationcomputingWord-level illustration of context; not measured attention.Context from both sidesWith bidirectional attention, the representation of a word can use earlier and later words.Thebankbesidetheriverwasquiet.Earlier contextLater contextContextual representation Bidirectional contextThe sentence "The bank beside the river was quiet." with the word bank outlined. Schematic connectors run to bank from the earlier word and from the later words; the selected position becomes a contextual representation. Word-level illustration of context; not measured attention.selected wordcontext connectioncontextual representationcomputingWord-level illustration of context;not measured attention.Context from both sidesWith bidirectional attention, a word canuse earlier and later words.Thebankbesidetheriverwasquiet.Earlier contextLater contextContextual representation

Figure

Bidirectional attention lets a token representation use context from earlier and later positions. Connections are illustrative, not recorded attention weights.