đ Note: This article was originally written in April 2023. Even though Iâve updated parts of it, some parts may feel a bit dated by todayâs standards. However, most of the key ideas about LLMs remain just as relevant today.
Large Language Models
So, what happens when a regular Language Model gets bigger? You get a Large Language Model (LLM).
But we canât just blow these things up infinitely. Three big roadblocks stand in the way:
- Training Data: You need a ridiculous amount of it.
- Algorithms: Scaling requires smarter and more powerful algorithms.
- Compute Power: Think massive clusters of top-tier GPUs/TPUs.
The fact that we can train LLMs today means these problems are being solved, at least partially. Interestingly, the same three factorsâââdata, algorithms, and computeâââare exactly what allowed the leap from traditional machine learning to deep learning. And history suggests theyâll be the levers again when the next paradigm shift comes.
Training Data
Every machine learning model needs data. And the stronger the model you want, the more data you need.
This has always been one of the hardest parts of ML: collecting data, and then labeling it with the right answers (positive/negative, named entity positions, etc.).
But hereâs the twist: language models have a cheat code.
Self-Supervised Learning
Labeling by hand is expensiveâââtime, money, human effort. Which means scaling is painful.
Take a simple sentence: âI went to school yesterday.â From that one sentence, you can generate your own training examples automatically:
- âIâ â predict âwentâ
- âI wentâ â predict âtoâ
- âI went to schoolâ â predict âyesterdayâ
No humans required. As long as you have text, you can create training data automatically.
This approach is called self-supervised learning. Unlike classic unsupervised learning (where no labels exist at all), self-supervised methods generate labels directly from the raw data itself. Thatâs why modern LM training almost always falls under the self-supervised umbrella.
Web-Scale Data
Back in the early days, available text datasets were tiny: a few MBs of news articles, some licensed books, or manually curated corpora. Even Wikipedia dumps in the single-digit GB range felt massive.
Then the internet changed everything. The web is fundamentally text-driven, and its scale is mind-boggling. Wikipedia? Thatâs just a drop in the bucket.
Projects like Common Crawl began collecting enormous swaths of web dataâââtens of terabytes and growing. And the best part? Itâs freely available.
On top of that, many platforms have released their own cleaned-up datasets (within legal limits), which, while smaller, often have much higher quality than raw crawled text.
When the Two Collide
Now put these pieces together:
- Self-supervised learning means we donât need humans to label text.
- Web-scale data means we suddenly have oceans of training material.
The result? A perfect storm for building todayâs LLMs. Thatâs how we got from tiny datasets in the MB range to massive, automatically labeled corpora in the TB rangeâââthe fuel that makes GPTs, PaLMs, and LLaMAs possible.
â ď¸ Spoiler Alert
This section dives into the geeky, technical weeds. If thatâs not your thing, feel free to just take away this: Transformers are insanely powerful algorithms. Then, skip ahead and scroll straight down to the Compute Power section.
Algorithms
Even if you have oceans of data, you still need a good algorithm to digest it.
And here enters the celebrity of modern AI: the Transformer.
Released by Google in 2017, the Transformer is both an architecture and a set of structural ideas. Youâll hear people call it the Transformer model, the Transformer architecture, or just Transformer. Doesnât matterâââitâs the engine under the hood of nearly every LLM today.
But why is this thing so powerful? To explain that, we need to take a quick detour into a core concept: Sequence-to-Sequence models.
Sequence to Sequence
First things first: whatâs a sequence? Itâs just a list of items in order.
- 1, 5, 3, 2, 1 â a sequence of numbers
- ant, frog, dog, horse â a sequence of animals
- I, went, to, school, yesterday â a sequence of words
In NLP, our main interest is the last one: word sequences, or simply, sentences.
Now, Sequence-to-Sequence (seq2seq) literally means sentence â sentence. In other words, one sentence gets transformed into another.
The most obvious example? Translation.
- âëë ě´ě íęľě ę°ë¤.â â âI went to school yesterday.â
But translation isnât the only seq2seq task:
- Summarization: long text â shorter text
- Sentiment classification: review text â âpositiveâ or ânegativeâ (classification framed as text output)
- Named Entity Recognition: input sentence â same sentence but with tags/highlighted entities (also cast as seq2seq)
Once you think this way, you realize seq2seq is almost a universal recipe for NLP tasks.
How Do We Translate?
Hereâs the million-dollar question: how does your brain actually translate âëë ě´ě íęľě ę°ë¤â into âI went to school yesterdayâ?
Answer: we donât really know.

A classic hypothesis is the Inter-lingua theory: instead of going word-by-word, the brain converts the sentence into some abstract, universal âmeaning languageâ (the inter-lingua) and then expresses it in the target language.
Conceptually:
- Korean sentence â Inter-lingua
- Inter-lingua â English sentence
In ML terms:
- Encoding: convert source text into a hidden representation
- Decoding: generate the target text from that hidden representation
That hidden representation isnât human language. Itâs an abstract spaceâââwhat we in ML usually call latent vectors. The âinter-linguaâ metaphor is useful, but in practice itâs math.
Encoding and DecodingâââWith an Analogy
Think data formats:
- Encoding: turning light into video files, or compressing files into ZIP format. Same content, different form.
- Decoding: playing that video file, unzipping that compressed folder, or decrypting a spyâs coded message.
Sometimes we call decoding generation, especially in NLP, since the model isnât just restoring the originalâââitâs producing new text in a different form.
Thatâs exactly what translation does:
- Encode: Korean â latent meaning representation
- Decode: latent meaning â English
Why does this matter?
This encode/decode structure is perfect for deep learning because ML excels at learning A â B mappings from lots of examples. With enough bilingual pairs (or any sourceâtarget pairs), a model can learn how to encode and decode by itself.
And thatâs where Transformers come in: theyâre the best seq2seq engine weâve discovered so far.
Back to Transformers
At its core, a Transformer is a very clever encoderâdecoder model.
If youâve Googled âTransformerâ before, youâve almost certainly seen a diagram like this: (left = encoder stack, right = decoder stack).

Flow:
- The input sentence (âI went to school yesterdayâ) goes into the encoder stack on the left.
- It passes through several encoder blocks, gradually turning into a Context representation.
- That Context is fed into the decoder stack on the right, where it guides generation.
- The decoder outputs probabilities for each possible next word.
Letâs make this concrete. Imagine our vocabulary has 10,000 words:
- ID 1 = âaâ
- ID 2 = âappleâ
- âŚ
- ID 8789 = âwentâ
If the decoder is trying to predict the next word after âI,â it might output something like:
- Word 1 (âaâ): 0.00001
- Word 2 (âappleâ): 0.0004
- âŚ
- Word 8789 (âwentâ): 0.901
Clearly, âwentâ is the winner.
Stacking Blocks
Those âEncoderâ and âDecoderâ boxes are actually stacks of blocks:
- Each Encoder Block feeds the next Encoder Block.
- After stacking N of them, the final blockâs output becomes the encoderâs Context.
- The Decoder works the same way, with multiple Decoder Blocks stacked.
Why stack blocks? Same reason we make deep neural networks âdeep.â More layers = more expressive power = better performance.
Caveats:
- If you scale the model without enough data, performance can get worse.
- Bigger models demand far more compute and memory for both training and serving.
In other words: stacking is powerful, but it comes with a billâââsometimes a very expensive one.
So, Whatâs the Relationship Between Transformers and Language Models?
Weâre not studying Transformers in isolationâââweâre asking why they made LLMs possible.
At its core, a Language Model (LM) has a very simple job:
Predict the next word, given the text so far.
For example:
- Input: âThe flowers by the roadside are blooming âŚâ
- Bad guess: âpunched.â
- Good guess: âbeautifully.â
And guess what? Transformers are ridiculously good at this game.
Back to Our Example
Take the sentence: âëë ě´ě íęľě ę°ë¤.â (Korean: I went to school yesterday.)
- The encoder processes this input and produces a hidden Context representation (a compressed âmeaningâ in vector form).
- The decoder turns that Context into Englishâââbut it uses two inputs:
- The Context (from the encoder)
- Outputs (the decoderâs previously generated tokens)
Why âOutputsâ as input? Because the decoder is auto-regressiveâââit feeds its own past predictions back in.
The Auto-Regressive Loop
Walkthrough:
- Encoding: The encoder converts âëë ě´ě íęľě ę°ë¤â into Context vectors.
- First step: Context +
<start>â predict âI.â - Second step: Context + âIâ â predict âwent.â
- Third step: Context + âI wentâ â predict âto.â
- Repeat until âthe school yesterday.â
- Stop at
<end>.
Result: âI went to the school yesterday.â
Two Key Ideas
- One word at a time: The decoder generates token by token (why ChatGPT looks like itâs âtypingâ).
- Predictions feed back in: Each new token becomes input for the next step (auto-regression).
Perfect alignment:
- The job of an LM is âpredict the next word.â
- The mechanism of the Transformer decoder is auto-regressive next-word prediction.
If we want a plain LM that predicts the next word in the same language, we make a small but important tweakâŚ
Encoder-Only, Decoder-Only
The full EncoderâDecoder Transformer is powerful, but not everyone needs both halves. Researchers asked: What if we only used the encoder? What if we only used the decoder?
Encoder-Only

The most famous encoder-only model? BERT.
BERT keeps just the encoder stack. Sometimes all you need is a good representation of text (context vectors), not generation.
Great for classification tasks:
- Is this review positive or negative?
- Does this sentence contain a personâs name?
Classification works on embeddings. Better embeddings â better classifiers. BERT looks at text bidirectionally, encodes whole sentences, and produces rich representations. Plug them into a classifier and accuracy jumps.
Is BERT a language model? Strictly, noâââit doesnât do auto-regressive next-word prediction. Itâs trained as a masked language model (predict the missing word), which is different from traditional LMs.
Decoder-Only

On the other side: GPT.
GPT (GPT-2/3, ChatGPT, GPT-4âŚ) keeps only the decoder stack.
Why drop the encoder? If your goal is just next-word predictionâââthe pure LM taskâââyou can feed the decoder with the text so far and let it continue auto-regressively.
- Input: âThe flowers by the roadside are bloomingâ
- Decoder predicts: âbeautifully.â
- That prediction feeds back in, and generation continues.
This is why GPT and its cousins (LaMDA, PaLM, LLaMA, Claude, etc.) follow the decoder-only recipe. Itâs the simplest and most direct way to scale LMs into generative engines.
Encoder +Â Decoder
Models like T5 and BART keep the full structure and shine at clear input â output transformations (translation, summarization, etc.).
Encoder vs. Decoder
Historically, encoder-only exploded first (BERT) because many NLP tasks were classification-heavy. Decoder-only models initially looked like ânonsense generators.â
Key difference:
- Encoder-only models canât generate text.
- Decoder-only models canâââand with scale, their potential is enormous. Even classification can be reframed as generation (âThe review is ⌠[positive/negative]â).
Thatâs why decoder-only LMs became the dominant LLMs.
A Long Tradition
Transformers didnât invent encoderâdecoder. Before 2017, RNNs/LSTMs/GRUs were the standard way to build it. Transformers replaced RNNs.
Biggest reason people cite: Self-Attention.
Why Do Transformers Work So Well? Self-Attention
Two concepts are central:
- The EncoderâDecoder structure
- Self-Attention
Letâs start with Attention itself.
Attention
Attention first showed up in RNN-based seq2seq models. Recall the pipeline:
Input â Encoder â Context â Decoder â Output
The decoder generates tokens one by one. Early models used a fixed Context for every step, but different output words need to âlook backâ at different parts of the input.
Example:
âëë ě´ě íęľě ę°ěľëë¤.â â âI went to school yesterday.â
If the model could focus on ę°ěľëë¤ (went) and ě´ě (yesterday) at the right time, it would more reliably pick âwentâ (past tense) over âgo.â
Thatâs Attention: at each step, re-weight which parts of the input matter most.
Self-Attention
Seq2seq Attention asks: Which parts of the source should I attend to while generating the target?
Self-Attention asks: Within a single sentence, which words should each word attend to?

Example:
âThe animal didnât cross the street because it was too tired.â
Here, âitâ should link strongly to âanimalâ, but also relates to âtired.â
Why is this powerful for LMs?
- To predict âbloomedâ in âThe flowers by the roadside ⌠bloomed,â âflowersâ should get the highest weight.
- To pick tense, âyesterdayâ matters more than âschool.â
Self-Attention lets the model discover this automatically.
Multi-Head Self-Attention
Language has multiple relationship types:
- Grammatical (subject â verb)
- Semantic (animal â it)
- Attributes (it â tired)
One attention map canât capture every view. The fix: run multiple attention heads in parallel, each with a different âview.â

Under the hood, word embeddings are split into subspaces (chunks of numbers). Each head attends within a different subspace, encouraging different aspects (grammar, meaning, style) to emerge.
Instead of one spotlight, give the model a dozen flashlights, each shining on a different relationship.
Thatâs the magic of Multi-Head Self-Attentionâââone of key reasons Transformers dethroned RNNs.
175B? 540B? What Do Parameter Counts Actually Mean?
Youâll often hear sizes like 175B (GPT-3) or 540B (PaLM). These are the number of parametersâââthe weights in the Transformer.
More parameters â more capacity. Hence the popular (but flawed) shortcut:
Bigger model â better performance.
In reality, performance depends on more than size:
- How much data was used?
- How high-quality was that data?
- Were the hyperparameters tuned well?
- How long (and how thoroughly) was the model trained?
So why do parameter counts dominate? Theyâre easy to understand.
If someone asks, âWhich model is better, A or B?â you could unpack data quality, training steps, and optimizers⌠or say:
âModel A is 70B. Model B is 200B. Model B is better.â
Itâs not necessarily trueâââbut itâs simple.
â ď¸ Pro tip: If someone talks about model quality only in terms of parameter count, be cautious. They either donât fully understand, or theyâre trying to sell you something.
Transformer in a Nutshell
- Transformers were designed for Sequence-to-Sequence tasks.
- The most common form is the EncoderâDecoder structure.
- Variants exist: Encoder-only (BERT), Decoder-only (GPT), Encoder+Decoder (T5, BART).
- To generate language, you need a Decoder.
- A core innovation is Self-Attention.
- To capture different perspectives (grammar, semantics, style), Transformers use Multi-Head Self-Attention.
Compute Power
The last ingredient: compute.
LLMs wouldnât exist without massive progress in hardware and infrastructure:
- GPUs (and TPUs) unlocked massively parallel training. GPUs were the rocket fuel of the deep learning boom, and today Nvidia still dominates with CUDA, optimized libraries, and cutting-edge hardware.
- Parallel training techniques allow hundreds (or thousands) of GPUs to train a single model in sync.
- Cloud infrastructure made it practical. Buying racks of GPUs is brutally expensiveâââand they start depreciating the moment you unbox them. Renting from AWS, Azure, or GCP lets teams scale without opening a hardware graveyard in the office.
In short: faster chips + smarter software + elastic cloud = the horsepower that makes LLMs possible.
Why LLMs Happened Now
Weâve walked through the three big ingredients:
- Data: Web-scale text + self-supervised learning â oceans of training material.
- Algorithms: Transformers (self-attention, scalable stacks) replaced RNNs.
- Compute: GPUs/TPUs + cloud infrastructure â enough horsepower to train monster models.
Each piece alone wouldâve been impressive. Put together, they sparked a step-change.
A decade ago, we had:
- Limited datasets (a few gigabytes at most).
- Algorithms (RNNs, LSTMs) that struggled with long sequences.
- GPUs that couldnât realistically handle 100B+ parameter models.
Today, we have:
- Tens of terabytes of training data at our fingertips.
- Transformer architectures that scale beautifully.
- GPU/TPU clusters that can train trillion-parameter models.
No single breakthrough âinventedâ LLMs. It was the intersection of trendsâââdata, algorithms, computeâââthat finally clicked into place.
Thatâs why LLMs feel like they appeared âall of a sudden.â The truth is, researchers were laying the groundwork for years. The moment the three factors aligned, the field exploded.
And thatâs where we are now: riding the wave of models that are bigger, smarter, and more capable than anyone thought possible five years ago.
In the next post, Iâll dive into zero-shot, few-shot, prompting, and the rest of the story.