How does it work?
Text is split into tokens and each token becomes a vector. The model then runs those vectors through repeated layers of attention, where every token computes how relevant every other token is to it, and produces a new representation weighted by that relevance. Stack enough of those layers and the representation of a word ends up carrying the context it appeared in.
The word "bank" starts as one vector regardless of meaning. After a few attention layers in "river bank", it has absorbed information from "river" and no longer resembles the "bank" in "bank account". That is the whole idea, repeated at scale.
