AIQ AIQ
How Computers Read · Lesson 2.1.3

Teaching "How Computers Read" to Architect mode (ages 15–18)

Part of the How Computers Read lesson guide. Teaching a different grade? 🌈 Explorer (5–7) · 🔧 Builder (8–10) · 💻 Hacker (11–14)

Hook & Warm-Up

Open at the level this age band can actually engage with technically:

"From bag-of-words to Transformer architectures, NLP has evolved from statistical frequency analysis to contextual language understanding. Let's examine modern language representation and generation."

Ask: "Who here has used a large language model — ChatGPT, Claude, Gemini, whatever's on your phone? Now: can any of you actually describe, mechanically, what happens between you hitting 'send' and text appearing on screen?" Most students will describe the experience, not the mechanism. Say: "That gap — between using something fluently and understanding how it works — is exactly what today closes. We're going past 'it's smart' into tokenization, embeddings, attention, and the actual architectural difference between models like BERT and GPT."

Frame the stakes plainly, since this age band is old enough for it to matter directly: "Some of you will use these systems for schoolwork, some of you may end up building on top of them professionally, and all of you will need to evaluate what they get right and wrong for the rest of your lives. None of that is possible with 'it's magic' as your mental model — it requires knowing, at least at a working level, what's actually computing the output."

Main Activity

Treat this as a technical walkthrough building toward the Transformer, using the lesson's three scenes as checkpoints rather than the whole content.

Tokenization. Before any model sees text, it must be tokenized. Introduce Byte-Pair Encoding (BPE) and WordPiece as the two dominant subword tokenization schemes: both work by starting from individual characters and iteratively merging the most frequent adjacent pairs into single tokens, building a vocabulary that balances coverage against size — common words end up as single tokens, rare or novel words get split into smaller familiar pieces. This is why a model can process a word it's never seen before: it falls back to subword fragments it has seen.

Embeddings and positional encoding. Each token maps to a learned vector — a word embedding — in a high-dimensional space where geometric proximity approximates semantic similarity. The king − man + woman ≈ queen result is the standard illustration: consistent vector-arithmetic relationships emerge from training on raw text, with no explicit supervision on gender or royalty. One subtlety worth adding for this age band: because a Transformer processes all tokens in parallel rather than sequentially, it has no inherent notion of word order — positional encoding is added to each token's embedding specifically to inject that ordering information back in.

Self-attention and multi-head attention. This is the architectural core. Self-attention lets each token compute a weighted combination of every other token's representation, with weights determined by learned relevance — effectively, "how much should interpreting this token depend on that token." Walk through the classic disambiguation example on the board: "The trophy didn't fit in the suitcase because it was too big." Ask students to resolve what "it" refers to, then ask what would need to happen computationally for a model to get that right — the answer is that the representation for "it" needs to draw information from "trophy" specifically, across several intervening words, which is exactly what a learned attention weight between those two tokens accomplishes. Multi-head attention runs several of these attention computations in parallel with different learned parameters, letting the model capture different types of relationships simultaneously (say, syntactic dependency in one head and coreference in another). Layer normalization stabilizes training by normalizing activations between these sublayers, letting the very deep stacks used in real models train reliably.

BERT vs. GPT. Present these as two applications of the same Transformer building block, diverging on one key design choice: BERT is trained bidirectionally — it can condition on tokens both before and after the one it's predicting (via masked-language-model pretraining, where random tokens are hidden and the model learns to reconstruct them using surrounding context), which produces representations well-suited to classification and understanding tasks. GPT is trained autoregressively — each token is predicted using only preceding context, never future tokens — which is exactly the constraint that makes it usable for open-ended generation, since at inference time there is no "future" to condition on yet; you can't condition on text that doesn't exist yet. Close with fine-tuning: a pre-trained model, already holding broad language patterns from massive unlabeled text, can be adapted to a specific task using a comparatively small labeled dataset, which is why building a useful NLP system today rarely means training a model from scratch. It's worth naming the practical implication directly: pretraining on huge unlabeled text corpora is extremely expensive and done by a small number of well-resourced labs, but fine-tuning a pre-trained model is comparatively cheap, which is exactly what's made specialized NLP applications accessible to far more developers than a decade ago.

Worth flagging as an aside for this age band: the Transformer paper that introduced this architecture was titled "Attention Is All You Need" — the name itself was a claim that self-attention alone, without the recurrence or convolution earlier architectures relied on, was sufficient to achieve state-of-the-art results. That framing is a useful shorthand for what made the architecture such a significant departure from what came before it.

Run the practice round fast, then use it as a springboard: for each AI example (spam filter, auto-translate, autocomplete, chatbot), ask which of BERT-style or GPT-style behavior it more resembles — spam filtering and translation-quality scoring look like classification (BERT-family), autocomplete and chatbots look like generation (GPT-family), even though real production systems often blend both.

Discussion

Quiz Walkthrough

Byte-Pair Encoding (BPE) tokenization works by... (Splitting at spaces / Single character splitting / Iteratively merging frequent character pairs into subword tokens / Using a dictionary)
Iteratively merging frequent character pairs into subword tokens. BPE starts from individual characters and repeatedly merges the most frequent adjacent pair into a new token, building a vocabulary that keeps common words compact while letting rare words fall back to smaller, still-recognizable pieces. "Using a dictionary" is the closest wrong answer conceptually, but a fixed dictionary can't handle words it's never seen — BPE's whole advantage is that it degrades gracefully to smaller known fragments instead of failing outright.
Self-attention in Transformers allows... (Smaller models / Less data usage / Each token to attend to all other tokens capturing dependencies / Faster training)
Each token to attend to all other tokens capturing dependencies. This is what lets a Transformer resolve relationships across an entire sequence at once — like a pronoun referring back several words — rather than being limited to nearby context the way older sequential architectures (like RNNs, processing one token at a time in order) were.
The key difference between BERT and GPT architectures is... (Programming language / The physical size of the hardware / BERT uses bidirectional context; GPT is autoregressive (left-to-right) / Training data)
BERT uses bidirectional context; GPT is autoregressive (left-to-right). Both are built on the Transformer, but BERT's pretraining lets it condition on context from both directions, suiting understanding tasks, while GPT predicts strictly left-to-right, which is what makes it usable for open-ended text generation. This is a structural, mathematical difference in how each model is trained and used — not an implementation detail like hardware or programming language.
Few-shot learning in LLMs refers to... (Training with few parameters / Quick inference / Using small datasets primarily / Performing tasks from just a few examples in the prompt)
Performing tasks from just a few examples in the prompt. Rather than retraining the model, a handful of examples given directly in the prompt is often enough for a large pre-trained model to infer the pattern of the task and apply it to a new input — no gradient updates or weight changes happen at all. It's worth distinguishing this from fine-tuning, which does update the model's weights using a labeled dataset.

Wrap-Up & Extension

Close with: "Every fluent sentence a language model produces is the output of tokenization, learned embeddings, layered self-attention, and either bidirectional or autoregressive training — nothing more mystical than that, and nothing less genuinely sophisticated either. Understanding the mechanism is what lets you evaluate these systems critically instead of either worshipping or dismissing them."

Extension activity — architecture comparison table: Have students research and build a short comparison table (BERT vs. GPT vs. a third model of their choice — T5, LLaMA, or a current model they use) across: training objective, typical use case, context handling (bidirectional vs. autoregressive), and one real product built on it. Have a few students present their table and defend why a company might pick one architecture family over another for a specific product (say, a resume-screening tool vs. a customer service chatbot).

For a group with extra time or a strong technical baseline, add a second layer to the exercise: ask each group to identify one thing that could realistically go wrong if their chosen architecture were deployed for their chosen product without safeguards — a BERT-based resume screener trained on biased historical hiring data, or a GPT-based chatbot that confidently states an incorrect return policy. Require the failure mode to be traceable to something covered today (embeddings encoding real-world bias, or autoregressive generation optimizing for plausibility rather than truth) rather than a generic "AI can be wrong" statement. This extends the 10–15 minute core lesson into a full period and connects the architecture concepts to real engineering trade-offs and responsibilities, which is the level this age band should be operating at.

← Lesson overview ← How Computers Hear (Architect) Sensors and Data (Architect) →