liveBook · Manning

Embedding

As explained in How Large Language Models Work

A vector is an ordered numerical quantity that represents magnitude and direction or encodes data in a multidimensional space.

A vector is a group of continuous numbers used to represent a token in a form a neural network can manipulate. Unlike a token’s fixed numeric identity, a vector can encode several aspects of meaning and relationships at once. section 3.0 section 3.2.1

Vectors matter because they give language models a workable representation:

  • They use multiple numbers rather than one number, allowing a token to occupy a position in a multidimensional semantic space. section 3.2.1
  • Nearby vectors can represent related meanings, while transformations between vectors can express recurring relationships. section 3.2.1
  • A vector alone does not provide token order; positional information must be added so the transformer can distinguish different arrangements. section 3.2.1
  • The model repeatedly converts tokens into numeric representations and later converts its numeric output back into tokens. section 3.0

Why one number is not enough

Suppose stock is assigned 5.2, capital 5.3, rare -5.2, and debt another opposing value. Treating opposites as simple negatives makes rare and debt appear related even though that relationship is nonsensical. Multiple dimensions provide more room to represent different meanings and relationships without forcing every similarity or opposition onto one line. section 3.2.1

Figure 3.3 If you use just one number to represent a token, you quickly encounter problems where similar/dissimilar words cannot be made to fit each other. Here we see how trying to represent simple synonym/antonym relationships quickly becomes nonsensical even with just a handful of words.
figure

The figure makes the limitation of one-number representations visible by showing how synonym and antonym relationships quickly become inconsistent. section 3.2.1

How How Large Language Models Work covers it

How deep it goes
Explains multidimensional representations, semantic relationships, and positional additions, but stops short of mathematical derivations.
Examples
Uses stock, capital, rare, and debt to show why one-number representations cannot capture varied word relationships.
What it assumes
Assumes familiarity with tokens but builds the role of continuous numerical representations from the beginning.
What you can do after
Evaluate how language models turn tokens into multidimensional numerical representations and why positional information is necessary.
How it connects
Connects vectors with tokens, embeddings, neural networks, transformers, semantic space, and positional embeddings.

Also explained in

Compare how 47 books explain embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.