liveBook · Manning

Computer vision

As explained in How Large Language Models Work

Computer vision is the field concerned with enabling computational systems to analyze and interpret visual data.

Computer vision enables computational systems to analyze and interpret visual data such as images and videos. It supports tasks including object detection, object identification, image interpretation, and image generation. section 6.0

Transformers can work with images without changing their core layers. Instead of treating words as tokens, the system converts an image into a sequence of numeric vectors, processes that sequence, and converts the result back into image data. section 6.0 section 6.3

A transformer-based vision pipeline typically works as follows:

  • Break the image into square tiles called patches. section 6.3.1
  • Represent each pixel by its red, green, and blue values, then combine each patch into a long vector. section 6.3.1
  • Use a small neural network to extract basic local features before the full transformer processes the vectors. section 6.3.1
  • Use a patch combiner to reshape transformer outputs into patches when producing an image. section 6.3.1

A 16-by-16 patch

A 16 × 16 pixel patch with three RGB values per pixel becomes a vector containing 768 values. A small network can process this vector, while later layers combine processed vectors into an image representation or output. 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 the analogy between text tokenization and image patch extraction, then compare text unembedding with image patch combination. section 6.3.1

Vision transformers use this arrangement to give the model global cohesion across an image. Other systems combine transformers with architectures such as convolutional neural networks, VQGAN, or U-Net transformer designs. section 6.3 section 6.3.1

How How Large Language Models Work covers it

How deep it goes
Traces image-to-vector patch extraction and reverse reconstruction, but stops short of detailed training procedures or mathematical derivations.
Examples
Uses image patches, RGB vectors, a 16 × 16 patch containing 768 values, and patch extraction and combination diagrams.
What you can do after
Evaluate/understand how images become transformer inputs and how transformer outputs become images.
How it connects
Connects computer vision with transformers, tokenization, convolutional neural networks, object detection, and image generation.

Also explained in

Compare how 8 books explain computer vision →

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.