Skip to content
GenAI Learn/Neural Networks From First Principles
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

Architectures at a Glance: A Preview of Transformers

5 min read

You'll learn to

  • -Recognize that the "shape" of a network (its architecture) is chosen based on the structure of the data it processes
  • -Understand transfer learning: reusing a pretrained network instead of starting from random weights
  • -Preview why the transformer architecture, covered in depth in Phase 2, was such a significant development

Everything so far in this module described the generic building blocks: neurons, layers, activations, forward passes, backpropagation. But real networks are not just an undifferentiated stack of identical layers. They are arranged into specific architectures, shaped around the structure of the data they are meant to process.

Architecture Follows Data Shape

  • -Convolutional networks (CNNs) are shaped around images. They apply small, reusable filters across an image's grid of pixels, well suited to the fact that a pattern like an edge or a texture can appear anywhere in a photo.
  • -Recurrent networks (RNNs) were the traditional shape for sequential data like text or audio, processing one element at a time while carrying forward a running memory of everything seen so far.
  • -Transformers are the architecture that now dominates language, and increasingly other domains too. Instead of processing a sequence one step at a time like an RNN, they let every position in a sequence directly weigh how relevant every other position is, all at once, via a mechanism called self-attention.

Transfer Learning: You Rarely Start From Scratch

Nothing in this module ever mentioned where a network's starting weights actually come from in practice, beyond "small random numbers." Training a large network entirely from scratch on your own data is expensive and often unnecessary. Transfer learning instead starts from a network that has already been trained on a huge, general dataset, then adapts it to a new, more specific task.

There are two common ways to adapt a pretrained network. Freezing keeps most of the pretrained layers exactly as they are and only trains a small new layer added on top, treating the frozen layers as a fixed feature extractor. Fine-tuning goes further and continues training some or all of the pretrained layers too, usually with a much smaller learning rate than you would use from scratch, so the existing weights shift gently instead of being overwritten.

Why Transfer Learning Works
Edges and textures in vision, common word patterns in language: broadly reusable across tasks
Early layers learn general patterns
These are the layers most worth retraining or replacing for a new task
Later layers learn task-specific patterns
Far less data and compute needed than training an equivalent network from random weights
Practical payoff

This idea comes back with real weight in Phase 2. Fine-tuning a large language model is transfer learning applied to a pretrained transformer, and the freeze-versus-fine-tune tradeoff described here is exactly the decision that chapter walks through in the context of LLMs specifically.

Why the Transformer Preview Matters

The transformer architecture, introduced in a landmark 2017 paper, is specifically what makes modern large language models possible. It is why Phase 2 of this course exists as a distinct phase rather than being folded into this one. Understanding that it is "just" a specific architectural choice, neurons, layers, and backpropagation underneath, arranged in a particular shape well suited to language, should make it feel far less like magic once Phase 2 covers it in depth, including its own use of the exact dot-product operation from the Math module to compute attention scores.

Every architecture covered here, and every architecture you will ever encounter, is built from the exact same underlying pieces this module introduced: weighted sums, nonlinear activations, a forward pass, a loss function, and backpropagation-driven training. Architecture is about how those pieces are arranged and connected, not a different set of ingredients entirely.

Interview Signal is part of Pro

See a real weak answer next to a real strong one for this exact topic.

Quiz is part of Pro

Test what you just read with a short quiz, and bank the XP.

ScaleDojo Logo
Initializing ScaleDojo