liveBook · Manning

Patch

As explained in How Large Language Models Work

A localized rectangular portion of an image converted into a numerical representation for processing by a model.

A patch is a small, fixed-size piece of an image represented as numbers. Dividing an image into patches gives a transformer a sequence of inputs, much as tokenization gives a language model a sequence of text units. section 6.3.1 section 6.4

A typical patch-processing pipeline works like this:

  • Divide the image into fixed-size tiles, commonly 16 × 16 pixels. section 6.3.1
  • Convert each pixel’s red, green, and blue values into one long numerical vector; a 16 × 16 RGB patch contains 768 values. section 6.3.1
  • Pass the vectors through a small neural network before sending the resulting sequence to the transformer. 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

Trace how patch extraction replaces tokenization 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 extraction, RGB vectorization, preprocessing, and reconstruction, but omits detailed neural-network mathematics.
Examples
Uses 16 × 16 RGB tiles, each converted into a 768-value vector.
What it assumes
Assumes familiarity with pixels and RGB values while explaining their conversion into vectors.
What you can do after
Evaluate how an image becomes transformer input and how model outputs can return to patch-shaped image data.
How it connects
Connects image patches with tokenization, embeddings, transformers, vectors, and multimodal models.

Also explained in

Compare how 5 books explain patch →

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.