Concepts / Transformer Architecture and Variants

Transformer Architecture and Variants

The original transformer is the 2017 architecture from Attention Is All You Need by Vaswani et al. Its variants descend from it, and the source groups those variants into two styles: encoder-style and decoder-style.

  • Programming

Not Every LLM Is a Transformer

Modern large language models are often assumed to share one design. Many of the best-known ones do build on a specific neural network design called the transformer architecture. The source for this section makes a direct point, however: LLMs need not all share that design. Some researchers are actively building language models with different internal machinery.

This article gives you the family map before the mechanics. You will start with the original transformer, see how its variants divide into two styles, look at the experimental alternatives that sit beside it, and then pin down a few supporting terms. Keep two questions in mind as you read: which architecture does each model use, and why is each reference included?

Starting From the Original Transformer

The transformer architecture was proposed in the paper titled Attention Is All You Need, published in 2017 by Vaswani et al. Every variant discussed in this section is a descendant of that original design. When you see the phrase original transformer, it refers to the architecture introduced in that paper.

Think of the original transformer as the root of a family tree. Researchers took that design and adapted it into several variants. The variants that matter most for this course are BERT and GPT-3, and knowing which variant is which is the first step toward reading the rest of the module with confidence.

Key point

The original transformer is the 2017 architecture from Attention Is All You Need by Vaswani et al. Its variants descend from it, and the source groups those variants into two styles: encoder-style and decoder-style.

Two Styles of Transformer Variant

The source groups the variants of the transformer into two styles. The name of each style tells you which kind of transformer it is, and the two styles are the main distinction to carry into the rest of the module. The diagram below shows how information moves through each style at a general level. It is a conceptual orientation, not a description of every internal layer.

Input tokensEncoder-style stackContextualrepresentationsPrompt tokensDecoder-style stackNext tokenreadencodedconsumedgenerates
How does information move through an encoder-style stack when it reads an input, compared with a decoder-style stack that produces the next token?

Read the diagram from top to bottom in spirit: the original architecture sits at the top, and the two styles sit beneath it as the two branches. The left branch reads an input and produces representations of it. The right branch works from a prompt and produces the next token. The source uses one named model as the example for each branch.

Matching BERT and GPT-3

The source gives each model a paper, a year, and a style. Placing these facts side by side makes the matching exercise concrete. Use the table to check which fact belongs to which model.

ModelStyleSource paperYear
BERTEncoder-style transformerDevlin et al.2018
GPT-3Decoder-style transformerBrown et al.2020
Original transformerRoot of the variantsAttention Is All You Need (Vaswani et al.)2017

BERT and GPT-3 matched by style, source paper, and year, with the original transformer as the reference point

Worked example

Placing a model on the timeline

A colleague says a model published in 2020 by Brown et al. must be an encoder-style transformer because it is the original one. Is that correct?

  1. 1
    Identify the source paper and year

    Brown et al. in 2020 is the source's description of GPT-3.

  2. 2
    Recall the style

    The source classifies GPT-3 as a decoder-style transformer.

  3. 3
    Check the original

    The original transformer is the 2017 Attention Is All You Need architecture, not a 2020 model.

Result

The claim is incorrect. The 2020 Brown et al. model is GPT-3, a decoder-style transformer. The encoder-style example is BERT from 2018, and the original architecture dates to 2017.

The source presents the three landmarks in order: the original architecture first, then the encoder-style BERT, then the decoder-style GPT-3. Following that order helps you see how the ideas arrived.

Experimental Alternatives to the Transformer

The source names three experimental designs that are not based on the transformer: RWKV, Hyena Hierarchy, and Mamba. Each reference is a 2023 paper, and each title hints at its core idea. The source uses the titles as clues. The hints point toward recurrent, convolutional, and state-space ideas respectively. Treat these as clues to be confirmed against the papers before relying on any detail.

Original transformerAttention Is All You Need,2017RWKVrecurrent idea hinted bytitleHyena Hierarchyconvolutional idea hintedby titleMambastate-space idea hinted bytitle
How do the experimental designs sit beside the transformer, and what does each name signal about its core mechanism?

The diagram places the transformer and the experimental group as siblings under the general heading of LLM architectures. It is a classification aid, not a ranking. The transformer is not the root of the tree, and the experimental group is not a lesser branch. They are two answers to the same question of how to build an LLM.

Tracing the Supporting References

The rest of the section is a reading path. Each reference explains a term used elsewhere in the material. Three of them connect directly to GPT-style models and their training: Llama 2, The Pile, and InstructGPT.

Llama 2 is Meta AI's model. The source describes it as a popular implementation of a GPT-like model that is openly available, in contrast to GPT-3 and ChatGPT. The reference is Llama 2: Open Foundation and Fine-Tuned Chat Models (2023) by Touvron et al.

The Pile is a publicly available dataset curated by Eleuther AI. The source calls it an 800GB dataset of diverse text for language modeling. It is the subject of the paper The Pile: An 800GB Dataset of Diverse Text for Language Modeling (2020) by Gao et al. Its role in the reading path is to connect to the dataset references mentioned earlier in the material.

InstructGPT is a fine-tuning method for GPT-3 that uses human feedback. Human feedback is not applied to GPT-3 as a single direct action. It guides a fine-tuning step, and that fine-tuning step starts from GPT-3 and produces a model that follows instructions.

Follow the chain from left to right: GPT-3 is the starting model, human feedback guides a fine-tuning step applied to it, and the result is a model that follows instructions. Llama 2 sits in the same GPT-like family as an openly available example, and The Pile is the public dataset reference that belongs to the language modeling material.

Vectors, Embeddings, and Latent Spaces

A vector representation is an ordered list of numbers. Each position in the list is a slot, and the whole list stands for one item. A short vector with four slots looks like a list of four numbers. The slot values in any example are placeholders, not real data.

The source also uses the terms embedding space and latent space. It notes that these are related concepts, and that the first chapter of its book discusses how they compare and how vector representations work in general. The source does not define either term, so treat the following only as orientation. A vector representation is one list of numbers. Embedding and latent space are the broader terms the source points you to for further study.

Vectorrepresentationordered list of numbersEmbedding spacerelated term, defined insource's book chapterLatent spacerelated term, defined insource's book chapterdiscussed alongsidediscussed alongsiderelated concept
How are the vector representation and the source's related terms, embedding space and latent space, connected?

Practice Sorting the Family Tree

MEDIUM

A reading list mentions four models: the original transformer, BERT, GPT-3, and Mamba. Sort each one into the correct group: transformer-based original, encoder-style, decoder-style, or experimental non-transformer. Then give the year and source paper for each.

Hints
  • The original transformer comes from the 2017 paper Attention Is All You Need.
  • The source ties BERT to encoder-style and GPT-3 to decoder-style.
  • Mamba is one of the three experimental designs, and its title hints at a state-space idea.

What do you think happens?

Before you look, guess: which style does GPT-3 belong to, and which year did the source attach to its paper?

Reveal answer
Answer:

GPT-3 is a decoder-style transformer, described by Brown et al. in 2020.

The source classifies GPT-3 as decoder-style and gives Brown et al. in 2020 as its paper and year.

Mistakes Learners Make With the Family Map

  • Common mistake

    Assuming every large language model is a transformer

    Why it fails

    The source states that LLMs need not all share the transformer design, and it names RWKV, Hyena Hierarchy, and Mamba as experimental alternatives.

    Do this instead

    Ask which architecture each model uses before assuming it is a transformer.

  • Common mistake

    Reading experimental as unreliable

    Why it fails

    In this section experimental means less popular and not based on the transformer. It does not describe quality or use.

    Do this instead

    Read experimental as a description of design lineage, not of trustworthiness.

  • Common mistake

    Mixing up the style labels for BERT and GPT-3

    Why it fails

    BERT is the source's encoder-style example and GPT-3 is its decoder-style example. Swapping them reverses the family classification.

    Do this instead

    Attach BERT to encoder-style (2018, Devlin et al.) and GPT-3 to decoder-style (2020, Brown et al.).

  • Common mistake

    Treating the three experimental titles as full explanations

    Why it fails

    The titles only hint at recurrent, convolutional, and state-space ideas. The source does not describe their internals.

    Do this instead

    Use the titles as clues and confirm details in the source papers.

  • Common mistake

    Defining embedding space or latent space from this section alone

    Why it fails

    The source does not define these terms. It points to a book chapter for them.

    Do this instead

    Treat the terms as related concepts to explore further, and keep vector representation as the ordered list of numbers.

Key Takeaways

  • The transformer architecture comes from Attention Is All You Need (Vaswani et al., 2017), and the variants in this section descend from it.
  • The source classifies variants into encoder-style (BERT, Devlin et al., 2018) and decoder-style (GPT-3, Brown et al., 2020) families.
  • RWKV, Hyena Hierarchy, and Mamba are experimental, non-transformer alternatives whose titles hint at recurrent, convolutional, and state-space ideas.
  • Llama 2, The Pile, and InstructGPT connect to GPT-style models: Llama 2 is an openly available GPT-like model, The Pile is a public dataset, and InstructGPT fine-tunes GPT-3 with human feedback.
  • A vector representation is an ordered list of numbers, while embedding space and latent space are related terms the source points you to for further study.

Related concepts

More concepts starting with T