liveBook · Manning

Digital image

As explained in How Large Language Models Work

An image is a structured visual representation composed of values that encode colors or other pixel properties.

A digital image is organized numeric data: pixels store color values, commonly as red, green, and blue (RGB). For transformer processing, an image can be divided into small square patches, converted into vectors, and treated somewhat like a sequence of tokens. section 6.3.1

A patch-based representation works as follows:

  • Divide the image into fixed-size patches, such as 16 × 16 pixel squares. section 6.3.1
  • Convert every pixel’s red, green, and blue values into one long numeric vector. section 6.3.1
  • Pass the patch vectors through a small preprocessing network before the transformer. section 6.3.1

A 16 × 16 patch

A 16 × 16 patch has 256 pixels. With three RGB values per pixel, its initial vector contains 768 values. section 6.3.1

Figure 6.12 On the left, this simplified diagram shows how text input is tokenized and embedded before going to the transformer. An unembedding layer then converts the transformer output into the desired text representation. The input and output will be images when performing a computer vision task. The transformer stays the same, but then we modify the method for breaking the image into a sequence of vectors to perform patch extraction instead of tokenization. The LLM produces image output using a patch combiner, analogous to the unembedding layer for text LLMs.
figure

Shows how patch extraction replaces tokenization for image input while the transformer remains central, and how a patch combiner reconstructs image output. section 6.3.1

How How Large Language Models Work covers it

How deep it goes
Explains pixels, RGB values, fixed-size patches, vector dimensions, preprocessing, and reconstruction.
Examples
Uses 16 × 16 patches and calculates their resulting 768-value RGB vectors.
What you can do after
Understand how images become numeric patch sequences suitable for transformer processing.
How it connects
Connects pixels and RGB values with patches, vectors, tokenization, embedding, transformers, and patch combination.

Also explained in

Compare how 16 books explain digital image →

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.