Concepts / Understanding the Transformer Architecture

Understanding the Transformer Architecture

The transformer is a neural network architecture, while an LLM is a model category defined by its purpose of language processing.

  • Programming

Why the Two Labels Blur Together

Read a recent machine learning paper, a product announcement, or a forum thread, and you will often see the words transformer and LLM used as if they meant the same thing. The habit is understandable. The language models that have attracted the most attention in recent years are built on the transformer architecture, so the two labels tend to travel together.

The two labels do not name the same kind of thing. One is a neural network architecture, which is a design for how a network's computations are organized. The other is a category of AI model defined by what it does, namely processing language. Keeping these two ideas apart is the purpose of this article.

A common error here is a pair of mirror-image assumptions. The first says that every transformer is an LLM. The second says that every LLM is a transformer. Each assumption feels reasonable because the two sets overlap heavily in practice, but each one fails for a different reason. It helps to test them rather than accept them.

Design Versus Purpose

Definition

Transformer: a neural network architecture. It is a specific design, meaning a way of organizing a network's computations. Large Language Models are derived from this design.

Definition

LLM (Large Language Model): a model category defined by its purpose, which is processing language. An LLM is identified by what it is built to handle, not by the particular internal layout it uses.

A useful way to hold the relationship in your head is to separate the design from the purpose. The transformer is a design. An LLM is a purpose-driven category: a model built to handle language. Today's LLMs happen to be constructed from transformers, which is why the two overlap so much. Overlap is not identity, though.

Where the Two Labels Overlap

The diagram below shows the three places where the terms part ways. Today's LLMs sit in the region where the two categories overlap, because they are built from the transformer design. Outside that region, the transformer design is also used beyond language, and LLMs are also built on other designs.

Transformerneural network architectureTransformer-basedLLMsthe overlapLLMmodel category for languageTransformers forcomputer visiontransformer, not an LLMRecurrent orconvolutional LLMsLLM, not a transformerconstructsincludescan be used forcan be built on
Which parts of the two categories overlap, and where do they diverge?

Testing the Mirror-Image Assumptions

What do you think happens?

Is every transformer an LLM?

  • Yes, because transformers are only used for language

  • No, because transformers can be used for computer vision

Reveal answer
Answer:

No, because transformers can be used for computer vision.

The first assumption fails because the transformer is a design, and that design is not limited to language work. The source notes that transformers can be used for computer vision, so a transformer in that setting is not an LLM.

Now test the second assumption, that every LLM is a transformer. The source states that some LLMs are based on recurrent and convolutional architectures. An LLM built on one of those designs is still an LLM, because its purpose is processing language, but it is not a transformer. The second assumption fails for the opposite reason: the category is defined by purpose, and purpose does not force a particular architecture.

The Direction of the Derivation

The key idea is the direction of the relationship. The transformer architecture is the starting point, and LLMs are what get derived from it. The architecture is therefore the more general design, and LLMs are built on top of it. Understanding the architecture is one of the routes to understanding LLMs.

The architecture is a design, not a single trained model. LLMs are built on top of it. The direction runs from the base architecture to the derived LLMs, not the reverse. The diagram below shows that direction, naming only the two things the source establishes.

Transformerarchitecturebase designLarge Language Modelsderived from the baseLLMs are derived from
Which system is the base, and which is derived from it?

A Template for Reasoning About Base Designs

A useful way to reason about a base design is to imagine it as a template that several products are built from. The template is not any one product. Each product starts from the same template and then takes its own shape. The template idea is an illustration of the relationship, not a description of how transformers are built internally.

Worked example

Reasoning About a Template Relationship

A company says its product is built on a particular base design. A colleague asks whether the base design is the same thing as the product. How should you reason about it?

  1. 1
    Identify the base

    The base is the design the product starts from. In this article's terms, the transformer architecture is the base for LLMs.

  2. 2
    Identify the derived system

    The product is a system built from that base. It is not the template itself.

  3. 3
    Check the direction

    The relationship runs from base to derived. The base does not become the product, and the product does not define the base.

  4. 4
    Check the claim's limit

    The source supports only the derivation relationship. It does not say that every LLM is built the same way, nor that the architecture is a trained model.

Result

The base design and the product are different things. The product is derived from the base, and the reasoning should stop at the level the source supports.

Why Build LLMs on Other Foundations

If transformer-based LLMs are the dominant design, why would anyone build LLMs on recurrent or convolutional foundations? The source gives a direct answer: the main motivation behind these alternatives is to improve the computational efficiency of LLMs. The goal is to make language models cheaper to run in terms of computation, not to make a different kind of language model.

This explains why recurrent and convolutional LLMs still count as LLMs. Their purpose, processing language, is unchanged. What differs is the architecture chosen to carry out that purpose, and the stated reason for choosing it is computational efficiency.

Cases on Each Side of the Overlap

The comparison below sorts the cases the source supports. A transformer that is not an LLM is one used for computer vision. An LLM that is not a transformer is one based on a recurrent or convolutional architecture. The middle region holds transformer-based LLMs, the systems where the two labels coincide.

Transformer forcomputer visiontransformer, not LLMTransformer-based LLMbothRecurrent-based LLMLLM, not transformerConvolutional-basedLLMLLM, not transformer
Which examples fall inside the transformer category but outside the LLM category, and which fall the other way?

Notice what the source does and does not name. It names computer vision as a setting where transformers are used, and recurrent and convolutional designs as the basis for some LLMs. It does not provide a full list of transformer-based LLMs or of computer vision systems, so the diagram shows only the categories the source supports.

What the Source Does and Does Not Establish

The available material establishes the derivation relationship only: LLMs are derived from the transformer architecture, and the architecture is a design rather than a trained model. Several links are not stated, so they should not be added as facts.

Mistakes to Avoid When Using These Terms

  • Common mistake

    Treating transformer and LLM as synonyms

    What it looks like

    Reading a paper that says 'transformer' and assuming it means 'language model' in every case.

    Why it fails

    The transformer is a neural network architecture, while an LLM is a model category defined by its purpose. The two labels name different things, even though they overlap in practice.

    Do this instead

    Ask whether the claim is about the design or about the purpose before deciding what the term means.

  • Common mistake

    Assuming every transformer is an LLM

    What it looks like

    Concluding that a transformer used for computer vision must be a language model.

    Why it fails

    The source states that transformers can be used for computer vision, so not all transformers are LLMs.

    Do this instead

    Check whether the system is designed to process language before calling it an LLM.

  • Common mistake

    Assuming every LLM is a transformer

    What it looks like

    Concluding that a language model built on recurrent layers cannot be an LLM.

    Why it fails

    The source states that some LLMs are based on recurrent and convolutional architectures, so not all LLMs are transformers.

    Do this instead

    Keep purpose and architecture separate when classifying a model.

  • Common mistake

    Reversing the direction of the derivation

    Why it fails

    The source says the relationship runs from the base architecture to the derived LLMs, not the reverse.

    Do this instead

    Describe the transformer as the base design and LLMs as systems derived from it.

  • Common mistake

    Equating the architecture with a single trained model

    Why it fails

    The source describes the architecture as a design, not a single trained model. LLMs are built on top of it.

    Do this instead

    Treat the architecture as the template and each trained LLM as a product built from it.

Practice Reasoning About the Relationship

MEDIUM

A forum post says: 'The transformer is an LLM, so any transformer you find is a language model.' Using the distinction between design and purpose, explain why this statement is not supported, and state the direction of the relationship that the source does support.

Hints
  • Ask whether the post is talking about the architecture or the purpose of the model.
  • Recall the source's example of transformers used for computer vision.
  • The source states that LLMs are derived from the transformer architecture, not the other way round.

Key Takeaways

  • The transformer is a neural network architecture, a design for organizing a network's computations, while an LLM is a model category defined by its purpose of processing language.
  • The terms are often used interchangeably because today's LLMs are built on the transformer architecture, but overlap is not identity: transformers can be used for computer vision, and some LLMs are based on recurrent or convolutional architectures.
  • The main motivation for recurrent and convolutional LLM designs, as stated in the source, is improving the computational efficiency of LLMs.
  • LLMs are derived from the transformer architecture, which is the base design. The relationship runs from base to derived, and the source does not establish internal details or the specific systems built on the base.

Related concepts

More concepts starting with U