A vector is a list of numbers
Start with the whole idea in one line: a vector is an ordered list of numbers. Thatβs it. Hereβs one:
We write a vector with a bold letter and stack its numbers in square brackets. Each number is a component. We name them by position: is the first component, the second, the third β in general (βa-sub-β) is the number in slot . The count of numbers is the vectorβs dimension, written . Our has .
You already use vectors without the name. A color on a screen is three numbers β how much red, green, and blue β so a color is a 3-dimensional vector . Drag the sliders and watch the list and the color move together:
this colour = [80, 160, 240]
The same list is also an arrow
When a vector has 2 or 3 components, you can draw it. Read as directions: start at the origin, go 3 right and 1 up, and draw an arrow to where you land. Same numbers, now you can see them.
So every vector has two faces: a list (good for computing) and an arrow (good for seeing). Weβll switch between them freely.
Two quick but important details:
- Order matters. points to a different place than . Swapping components moves the arrow.
- Equal means equal everywhere. Two vectors are the same only if every component matches: , but .
- The zero vector is the arrow that goes nowhere β it just stays at the origin.
Adding vectors
To add two vectors of the same length, add them slot by slot:
Worked example. With and :
Geometrically, addition is tip-to-tail: walk along , then from where you stop, walk along . Where you end up is . Drag the blue and green arrows and watch the orange sum update:
a = (2, 1) Β· b = (-1, 2) Β· a+b = (1, 3) Β· cΒ·a = (3, 1.5)
element-wise aβb = (-2, 2) Β· dot aΒ·b = 0 (one number β multiply slot by slot, then add)
Optional depth: why add component-wise and not some other way
Each component tracks an independent quantity β in a color, red has nothing to do with blue. Combining two vectors should combine each quantity on its own terms: red with red, blue with blue. Mixing slots would let βredβ leak into βblue,β which is meaningless. So βkeep every axis separateβ is the definition.
Scaling vectors
To scale a vector by a single number (called a scalar), multiply every component by :
Worked example. With :
- β same direction, twice as long.
- β same direction, half as long.
- β same line, opposite direction. A negative scalar flips the arrow.
The slider in the playground above scales the blue arrow β drag it past zero to watch it flip.
Subtracting vectors
Subtraction is just adding a flipped vector: , which works out component-wise to
Worked example. With and :
Thereβs a clean picture: is the arrow from βs tip to βs tip β βwhat youβd add to to reach .β Drag the two arrows and watch the difference:
a = (3, 2) Β· b = (-1, 1) Β· a β b = (4, 1) β the arrow from b's tip to a's tip.
Same size or it doesnβt work
Addition, subtraction, and the element-wise product (next) all pair up matching slots β so both vectors must have the same dimension. You cannot add and : the first vector has no third slot to pair with the , so the operation is undefined.
Scaling is the one exception β itβs a single number times the vector, so it works on a vector of any size.
Two ways to multiply vectors
Thereβs no single βvector times vector.β The two products that matter for AI are:
1. Element-wise (the Hadamard product, written ). Multiply matching slots; the result is a vector of the same size.
Worked example. . Models use this to gate β turning some features of a vector up and others down.
2. The dot product (written ). Multiply matching slots, then add them all into one single number.
Worked example. .
That one number measures how much two vectors point the same way β itβs the engine behind attention and similarity search, so it gets its own lesson soon (Lesson 3). For now, just be able to compute it. The playground above shows both and live as you drag.
Why this matters
Transformers donβt read words β the first thing a model does is turn each token into a vector of learned numbers called an embedding, exactly like a color is a list of numbers. From there, the machinery is the moves you just learned: attention adds vectors together (weighted by how relevant they are), scales them, and uses the dot product to decide how much each token should attend to another; the residual stream is one long running sum. Get these operations, and the rest of the course has solid ground to stand on.
When youβre ready, the assessment mixes all of this β including a few that make you combine several moves in one go.