0001 β€” Vectors: The Atom of AI Data

Linear Algebra Pillar Β· ~20 minutes

🧩 Puzzle Piece: In the transformer pipeline (Lesson 0000), the first step after tokenization is the embedding layer β€” converting each token into a vector. Every word, every image patch, every piece of data flowing through a transformer is a vector. This lesson builds the foundation: what a vector is, and what you can do with one.
Every word you type into ChatGPT, every image Midjourney generates, every song a recommendation system suggests β€” all of them start as vectors. A vector is the fundamental unit of data in AI. If you understand vectors deeply, you understand the alphabet that every AI system reads.

What Is a Vector?

There are two ways to see a vector, and you need both:

The Geometric View

A vector is an arrow in space. It has:

In 2D, a vector v = (3, 1) means "go 3 steps right, 1 step up." Draw it from the origin β€” it's an arrow pointing to the point (3, 1).

The Algebraic View

A vector is a list of numbers:

v = [3, 1]
2 dimensions
w = [0.2, βˆ’0.8, 0.5, 0.1]
4 dimensions
e = [0.12, βˆ’0.03, …, 0.41]
768 dimensions

The number of entries is the vector's dimension. A vector in 2D lives on a flat plane. A vector in 768D lives in a space you cannot visualize β€” but the same rules apply. This is the core trick of AI: math that works in 2D works in 768D exactly the same way.

Key insight: The geometric view builds intuition. The algebraic view scales to any number of dimensions. AI systems use vectors with hundreds or thousands of dimensions β€” but the operations are identical to what you do in 2D. If you can reason about arrows on a plane, you can reason about word embeddings, image features, and user preferences.

Three Operations That Matter

1. Addition: v + w

Geometrically: place the tail of w at the tip of v. The result is the arrow from origin to the new tip. Algebraically: add component by component.

[3, 1] + [1, 2] = [4, 3]

In AI terms: if one vector represents "king" and another represents a "gender direction," adding them might approximate "queen." This is not a metaphor β€” word embeddings literally work this way.

2. Scalar Multiplication: c Β· v

Geometrically: stretch or shrink the arrow by factor c. If c is negative, flip the direction.

2 Β· [3, 1] = [6, 2] (stretch)
βˆ’1 Β· [3, 1] = [βˆ’3, βˆ’1] (flip)

In AI terms: scaling changes the "strength" or "intensity" of whatever the vector represents.

3. Dot Product: v Β· w

Geometrically: measures how much two vectors point in the same direction. Positive = similar direction, zero = perpendicular, negative = opposite directions.

[3, 1] Β· [1, 2] = 3Γ—1 + 1Γ—2 = 5

In AI terms: the dot product is the fundamental measure of similarity. When an AI system tells you two things are "similar," it computed a dot product (or its normalized cousin, cosine similarity). This is how recommendation systems find songs you'll like, how search engines rank documents, and how attention mechanisms in transformers decide which words are relevant to each other.

The dot product is arguably the single most important operation in all of applied AI. It appears in: similarity search, attention mechanisms, recommendation systems, classification, clustering β€” essentially anywhere an AI system needs to compare two things.

Vectors in AI: Three Real Examples

Domain What Gets Vectorized Dimension What the Dot Product Measures
LLMs (GPT, Claude) Words / tokens 768–12,288 Semantic similarity β€” "king" is close to "queen," far from "bicycle"
Image Generation Image patches Typically 512–1,024 Visual similarity β€” which patches of an image relate to each other
Recommendation Users & items 50–200 Preference match β€” how much a user's taste vector aligns with an item's feature vector

In every case, the AI system is doing the same thing: representing things as vectors, then comparing them with dot products. The magic is in how the vectors are constructed β€” that's where learning (training) comes in β€” but the operations are just the three you learned above.

Check Your Understanding

Q1: A vector v = [βˆ’2, 5] is multiplied by the scalar c = 0.5. Geometrically, what happens to the arrow?

A. It flips direction and doubles in length B. It shrinks to half its length, direction unchanged C. It stays the same length but changes direction D. It rotates 90 degrees clockwise

Q2: Two vectors have a dot product of zero. What does this tell you?

A. They are identical B. They point in exactly opposite directions C. They are perpendicular β€” as dissimilar in direction as possible in that plane D. One of them must be the zero vector

Q3: An AI company claims their new model represents documents as 1,536-dimensional vectors and finds similar documents by computing dot products. Based on what you know, is this claim plausible?

A. No β€” dot products only work in 2D or 3D B. Yes β€” dot products work in any number of dimensions, and this is exactly how modern semantic search works C. No β€” similarity between documents requires a neural network, not vector math D. Yes, but only for documents shorter than 1,536 words

Q4 (Challenge): You have a word embedding where king = [0.5, 0.8, 0.1], queen = [0.5, 0.6, 0.1], and man = [0.2, 0.7, 0.1]. Without computing the exact number, which pair likely has the largest dot product?

A. king Β· man B. king Β· queen C. queen Β· man D. They are all equal
πŸ“Ί Primary Source Watch: Vectors, what even are they? β€” 3Blue1Brown (Essence of Linear Algebra, Ch. 1) This 10-minute video is the best first-pass geometric intuition for vectors ever made. Watch it before the next lesson.
πŸ“– Recommended Reading Strang, Linear Algebra and Its Applications β€” Sections 1.1–1.2 (Vectors and Linear Combinations) Read these sections after the video. Strang's geometric emphasis complements 3Blue1Brown perfectly.
If anything in this lesson didn't click β€” vector addition, the dot product, why high-dimensional vectors work the same as 2D ones β€” ask me. I can explain it differently, work through examples, or connect it to something you already know.
← 0000: The Transformer North Star Next: 0002 β€” Matrices as Transformations β†’