TECHNOLOGY

Token embeddings and contextual hidden states do different jobs

In this article
THE QUICK TAKE

An input embedding identifies a token in a learned space; contextual layers transform that starting representation according to the available sequence.

The same token can appear in different sentences without changing its vocabulary identifier. A model nevertheless needs representations that reflect those different contexts. The distinction between an embedding lookup and a contextual hidden state explains how these facts can coexist.

The lookup supplies a learned starting point

A vocabulary table associates token identifiers with learned vectors. Repeated occurrences of an identifier normally select the same table row before position information and contextual processing are applied. This shared starting point does not assign one final meaning to every occurrence. The token can be part of a word, punctuation or another learned unit. Its role is to provide coordinates that subsequent layers can transform, not to deliver a complete interpretation of the sentence before those layers have run.

Context changes the representation at each occurrence

Attention combines information from eligible positions, while feed-forward and normalization operations transform the resulting features. After these layers, occurrences that began with the same lookup can have different hidden states. A causal model only uses the context its attention pattern permits; a bidirectional encoder has a different visibility contract. The phrase contextual representation therefore needs a layer identity and an access pattern. A vector from an early layer and one from the final layer need not support the same downstream interpretation.

Follow an ambiguous example through the distinction

Consider the word bank in a financial sentence and in a sentence about a river. The actual tokenizer may split either text into units, so first identify the relevant token sequence. A repeated token’s initial table value can remain shared, while surrounding words lead contextual computation toward different representations. This is an illustrative explanation, not a claim about an identified neuron or a measured model result. The example clarifies why comparing raw table rows cannot establish how the full model disambiguates complete sentences.

Select the representation for its intended consumer

A retrieval system, a classifier and an output vocabulary projection may consume different representations or pool them differently. Reusing the phrase embedding does not make their vectors interchangeable. Record the tokenizer, selected layer, pooling rule and normalization alongside an extracted vector. Then test whether it preserves the distinctions the downstream task needs. This connects a conceptual explanation to an artifact that can be reproduced: the vocabulary row supplies a starting identity, while the full extraction procedure specifies the contextual object actually used by an application.

Primary research and implementation references

Reproducible inference stacks: preserving a GPU pilot’s result; A GPU inference benchmark you can trust.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles