liveBook · Manning

Unembedding layer

As explained in How Large Language Models Work

An unembedding layer is the final model component that maps a transformer’s numeric representation to scores or probabilities over output tokens.

An unembedding layer is the final part of a transformer pipeline. It turns the model’s numeric representation into candidate output tokens, making human-readable text possible. section 3.2.3 section 3.2

The output process works as a repeated loop:

  • The transformer produces a floating-point vector representing the input and text generated so far. section 3.2.3
  • The unembedding step converts that representation into scores or probabilities for tokens in the vocabulary. section 3.2.3
  • Sampling chooses one token, and the next prediction depends on every token selected previously; this is an autoregressive process. section 3.2.3
  • The loop ends when the model produces an end-of-sequence token or reaches a maximum generation limit. section 3.2.3

From “I love to eat” to a token

For the prompt “I love to eat,” food-related completions such as barbeque and sushi receive higher probabilities than a car or 42. Weighted random selection might choose “tacos,” after which the loop predicts the next token. section 3.4

Figure 3.11 We demonstrate text generation by starting with the phrase "I love to eat" and then showing that some possible completions that are foods, such as barbeque and sushi, have high proba-bilities, while a car and the number 42 have low probabilities. Weighted random selection chooses the word tacos. The generation loop is stopped when the EoS token appears.
figure

Use the figure to trace candidate probabilities, weighted selection, and stopping at the end-of-sequence token. section 3.2.3

How How Large Language Models Work covers it

How deep it goes
Traces vector conversion, probability-based sampling, autoregressive repetition, and stopping, without deriving the layer’s internal mathematics.
Examples
Uses “I love to eat,” candidate foods, weighted selection of “tacos,” and an end-of-sequence token.
What it assumes
Assumes tokens and transformer layers while connecting unembedding to embeddings, positions, and the broader LLM pipeline.
What you can do after
Evaluate how transformer vectors become probabilistic token choices in a recursively generated response.
How it connects
Connects embeddings, transformer layers, sampling, tokenization, autoregressive generation, and decoding.

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.