๐Ÿงญ Roadmap
Difficultyโญโญโญ / 5 โฑ Read time30 minutes embeddingscontextual-embeddingstransformers

๐Ÿ”„ Static vs Contextual Embeddings

1. Static embeddings

A static embedding gives the same vector every time a token appears.

Example:

bank โ†’ always the same vector

This was common in older systems like:

  • Word2Vec
  • GloVe

That means:

river bank
bank account

would still start from the same token-level embedding for bank.

This is useful, but limited.


2. Why static embeddings are limited

Some words change meaning depending on context.

Examples:

  • bank
  • bat
  • light
  • blue

If one token always gets one fixed vector, the model cannot fully represent those differences at the embedding stage.

So static embeddings are good for general similarity, but weak for context-sensitive meaning.


3. Contextual embeddings

Contextual embeddings change depending on surrounding words.

Example:

bank in "river bank"   โ†’ one representation
bank in "bank account" โ†’ another representation

This is much closer to how language actually works.

Modern transformer-based models produce contextual representations by letting tokens interact with surrounding tokens.

That is where vectorization starts connecting directly to attention.


4. Why contextual embeddings are powerful

Contextual embeddings help models:

  • disambiguate meaning
  • understand sentence-level nuance
  • adapt token meaning to nearby words
  • represent the same token differently in different situations

This is one reason transformers became so powerful.


5. Important nuance

At the very input layer, transformer models still begin with token embeddings from an embedding table.

But after attention layers process the sequence, the token representations become contextualized.

So a useful mental model is:

input embedding โ†’ initial token vector
attention + layers โ†’ contextual representation

That means contextual embeddings are not just โ€œlookup table vectors.โ€ They are refined representations shaped by the full sequence.


6. Practical comparison

Static

  • one token โ†’ one vector
  • simpler
  • useful for similarity and older NLP systems
  • weaker for ambiguity

Contextual

  • one token โ†’ different vectors in different contexts
  • stronger for modern language understanding
  • essential for transformers and LLMs

7. Why this matters for your learning path

This topic is the bridge between:

  • embeddings
  • attention
  • transformers

Without this distinction, it is easy to think embeddings are always fixed.

But in modern AI, the most useful token representations are often contextual.