An arrow and a list
“Go 3 blocks east and 2 blocks north.” We have given a friend one trip using two numbers. Together they describe an arrow: a direction and a distance. A vector lets us move between those two views. Later these arrows will carry information about words.
What a vector is
Consider the 2D plane, written $\mathbb{R}^2$. The origin is where both axes read zero.
| Part | Movement |
|---|---|
| Across | 3 blocks east |
| Up | 2 blocks north |
| Endpoint | [3, 2] |
Our notation stays consistent: bold lowercase $\mathbf{v}$ means “the vector v.” Its components are $v_1=3$ and $v_2=2$, read “v-one” and “v-two.” The little numbers below the letter are subscripts.
$$\mathbf{v} = \begin{bmatrix} 3 \\ 2 \end{bmatrix}$$In words: the vector v is the pair of numbers 3 and 2. The first is how far to go across, the second is how far to go up.
Worked example
Turn the list back into the arrow by hand. Start at the origin. Walk 3 steps to the right, which puts you above the "3" on the across-axis. From there, walk 2 steps straight up. Draw an arrow from where you started to where you are standing. That arrow is $\mathbf{v}$. Given the list you just drew the arrow, and given the arrow you could read the list straight back off the grid.
Both direction and length are encoded. We can estimate the length by eye; the next chapter shows how to calculate it.
Adding arrows
The diagram labels $\mathbf{v}=[3,2]$ and $\mathbf{u}=[1,3]$. Follow the first trip, then start the second from its tip. The combined trip ends at [4,5].
In words: add the two first-components to get the new first component (3 plus 1 is 4), and add the two second-components to get the new second component (2 plus 3 is 5). Nothing mixes across the slots.
Worked example
Follow the labeled arrows in the figure. The mint arrow moves 3 right and 2 up; the amber arrow, starting from the mint tip, moves 1 more right and 3 more up. Total: $3 + 1 = 4$ squares right and $2 + 3 = 5$ squares up, landing where the violet arrow points. The picture and the arithmetic agree.
This is vector addition. Reversing the trip order reaches the same corner: the two routes form a parallelogram.
| Operation | Numbers | Picture |
|---|---|---|
| Read components | [3,2] | 3 across, 2 up. |
| Add | [3+1,2+3]=[4,5] | Walk one trip after the other. |
| Scale | 2[3,2]=[6,4] | Double both parts of the trip. |
Stretching and flipping
Scaling changes every component by the same factor. That factor is a scalar, written in ordinary italic type rather than bold.
| Scale | Endpoint | Effect |
|---|---|---|
| 1 | [3, 2] | Original trip |
| 2 | [6, 4] | Twice as long |
| 0.5 | [1.5, 1] | Half as long |
| −1 | [−3, −2] | Same length, opposite direction |
In words: to double a vector, double each of its numbers. 3 becomes 6 and 2 becomes 4. Halving works the same way: $0.5\,\mathbf{v} = [1.5, 1]$.
| Scalar | Result | Effect |
|---|---|---|
| 2 | [6,4] | Twice the length, same direction. |
| 0.5 | [1.5,1] | Half the length, same direction. |
| −1 | [−3,−2] | Same length, opposite direction. |
| 0 | [0,0] | Zero length; no direction. |
Positive scaling preserves direction. That separation will let us compare directions even when arrows have different lengths.
See it move
Watch the component lines become a list. Then use the playground to connect each number to a movement of the tip.
From two numbers to thousands
A third component adds height: [3,2,5] describes an arrow in a room. A dimension is one coordinate slot. We write $d$ for the number of dimensions.
With thousands of components, we lose the picture but keep the arithmetic. Add matching slots; multiply every slot by the scalar. Our two-dimensional drawings teach operations that work on longer lists too.
Why the LLM cares
A token becomes an embedding: a vector with many components. Its direction can encode relationships such as the similarity of “cat” and “dog.” We'll build that idea carefully in Chapter 8.
The additions and scalings we just checked will combine information inside a language model. The lists grow; the operations stay familiar.
What you now know
- A vector is both a list and an arrow.
- Components say how far to move in each coordinate direction.
- Add vectors by adding matching components.
- A positive scalar changes length; a negative one also reverses direction.
- More dimensions mean more entries, with the same arithmetic.
Where we're headed
We can draw, add, and stretch arrows. Next we'll measure how much two arrows agree with one number: the dot product.