DSE411 · concept lessons

One Transformer, Two Kinds of Tokens

The GPT model of the course notebooks and Point Transformer V3, built side by side in five lessons. Every lesson answers the question the previous one raised, and every concept is defined once, with a hand-checkable example, the book's figure for the text instance and a figure drawn from the course's car point cloud for the 3-D instance, and the real output of the code that computes it.

flow and rationale: FLOW.md · how it is built: README.md

1The full picture first

Read both rows before zooming in. The numbered stages are the five lessons; every stage is a link.

GPT-2 small (LLMs-from-scratch) text"Every effort…" 1 BPE tokenizer ids in a vocab of 50 257 sliding windows → (input, target) 2 tok_emb + pos_emb 50 257 × 768, 1 024 × 768 (B, T, 768) TransformerBlock × 12, one resolution LN 3 attentionq·k / √d → softmax · v 4 causal mask12 heads × 64 + LN FFN768→3072→768 + 5 LN → out_head logits (B, T, 50 257) argmax → next token → repeat 124 M parameters (163 M untied) · 12 blocks · every tensor stays (batch, 1 024 tokens, 768) Point Transformer V3 points24 949 × (x y z i) 1 grid → curve codes sort: 4 orders (Z, TZ, H, TH) patches of 1 024 2 embed → 32 ch no position table position via xCPE in each block block × (2, 2, 6, 2) per encoder stage; grid pool ×2 between stages xCPEconv+skip LN 3 patch attentionsame q·k·v, in patches 4 no maskShift Order · heads + LN MLP×4, GELU + 5 decoder (U-Net) → head unpool + skip, 4 stages logits per point, original order 46.2 M parameters · encoder 24 949 → 2 009 → 501 → 116 → 29 points (car, grid 5 cm → 80 cm) · channels 64 → 512 · heads 4 → 32 Same: q·k·v attention · pre-norm LayerNorm block · ×4 MLP with GELU · residuals · multi-head · a tokenizer-like front end Different: order (given vs imposed) · position (table vs conv) · mask (causal vs none) · scope (window vs patch + Shift Order) · shape (×12 vs U-Net)
Click any numbered stage to open its page. Stage numbers match the pages; stage 2 also covers the xCPE box inside the PTv3 block.
The five lessons in a row with the question each one answers Both pipelines bottom to top with real example values

The two pipelines, drawn with real values. Top: the five lessons and their questions. Bottom: GPT-2 small and PTv3 from input to output, book Figure 2.4 style; the token ids are tiktoken's, the cells and codes are the car's. Each lesson's page repeats this figure with its own rows marked.

2The five lessons

01 · Tokens and serialization

How does the input become a sequence of integers?

unit · id · encode/decode · unknown input · groups for attention

02 · Embedding and position

How does an integer or a point become a vector, and where is position?

embedding · order blindness · absolute table vs relative conv (xCPE)

03 · Attention

How does one vector absorb its context?

context vector · score · softmax weights · q k v · scaling · the layer · vector vs scalar

04 · Mask and interaction

What must attention not see, and how do groups exchange information?

causal mask · −∞ trick · dropout / Shuffle Order · Shift Order · multi-head

05 · Block and model

How are the pieces stacked into a model, and run?

LayerNorm · GELU-MLP · shortcuts · block · grid pooling · model · generate / label

3The rule for the order

Every lesson answers the question the previous one raised. Full table with "why we need it" per card: FLOW.md.
LessonQuestionWhat we buildHands on to the next lesson
01 TokensHow does the input become a sequence of integers?regex tokenizer, vocabulary, BPE, sliding windows · grid cells, Z/Hilbert codes, sort, patchesIntegers are labels. The network needs vectors.
02 EmbeddingHow does an id or a point become a vector, and where is position?nn.Embedding + position table · linear stem + xCPE toy convVectors that know their position, but not each other.
03 AttentionHow does one vector absorb its context?simple → trainable → scaled attention on six words and on three pointsAttention sees everything in its group. Should it? Can it see beyond?
04 Mask & interactionWhat must attention not see, and how do groups talk?causal mask, −∞, dropout, heads · no mask, Shift/Shuffle Order, heads over patchesOne attention is one sub-layer. A model is a stack.
05 Block & modelHow are the pieces stacked, and run?LayerNorm, GELU, shortcuts, block, GPTModel, generate · PTv3 block, grid pooling, U-Net on the carBack to lesson 1: ids out, decode.

4Conventions