A computer cannot multiply the word “soup” by a weight. It needs a numerical representation first. The representation is the form we give information so a model can work with it.
One number, a list, a grid
A scalar is a single numerical value, such as a queue length of 3. A vector is an ordered collection of numbers. An order could have the vector [2, 3], meaning two sandwiches and three people ahead in the queue.
Order matters. Swapping those numbers changes the description. A matrix is a rectangular arrangement of numbers in rows and columns. Stack several equal-length order vectors as rows and we have a matrix.
These are containers for quantities, not magic meanings. We decide that the first column means sandwiches. A different representation could use very different numbers for the same order.
Cut text into pieces
A tokenizer converts text into a sequence of pieces a particular model can use. A token is one of those pieces, which may correspond to a word, part of a word, punctuation, or other encoded text.
Think of cutting a written recipe into reusable tiles. One tokenizer might keep “soup” together. Another might split it. Spaces, spelling, language, and the tokenizer's rules affect the boundaries. There is no universal number of characters per token.
A vocabulary is the tokenizer's collection of recognized token entries. A token ID is the numerical identifier assigned to an entry. In our invented tile set, “soup” might have ID 17. That number is an identifier, not a measurement of soupiness, and it is not a real model's advertised ID.
Encoding converts information into a specified representation. Tokenizing text and looking up IDs is one encoding process. The tokenizer must match the model. Using another tokenizer's IDs is like using the shelf numbers from the wrong library.
Replace identifiers with learned coordinates
An embedding is a numerical vector representing an item in a learned space. A model can look up a token's initial embedding from a table of learned values. Other models compute an embedding for a whole sentence, document, image, or sound.
Our earlier [sandwiches, queue] vector used features we named by hand. Learned embedding coordinates are adjusted through training, and their individual dimensions usually do not have convenient names such as “sweetness.”
Imagine arranging recipe cards so related uses tend to be nearby. That is an intuition for the arrangement, not a claim that a model literally uses a kitchen floor map. Real embeddings often have many more coordinates than we can draw.
Similarity is a measure of how alike two representations are under a chosen comparison. Comparing vector directions, for example, can help retrieve related notes. Nearby representations do not establish that either note is true. “The cafe is open” and “The cafe is not open” can share much of their subject matter.
The same word in a different sentence
A contextual representation is a numerical representation affected by the surrounding input. The word “bat” in “a flying bat” should be processed differently from “a wooden bat.” Later network layers can incorporate that surrounding information.
A retrieval embedding is a representation produced for finding related items, such as a recipe note matching a question. It is often one vector for a whole passage. It should not be confused with every changing token representation inside a text-generating model. Use compatible embedding models for questions and stored notes; vectors from unrelated spaces are not interchangeable.
- A flying batSurrounding words help a model represent the animal meaning.
- A wooden batDifferent surroundings support the sports-equipment meaning.
- A whole passageA retrieval model can represent a complete passage for matching related queries.
If two token IDs differ by one, are their meanings close?
No. IDs are identifiers. Any useful closeness belongs to a learned representation and a particular comparison, not ordinary subtraction of the identifiers.