Your model does not see images.
It does not see text. It does not see customer records or product descriptions or audio waveforms. It sees none of those things the way you see them.
It sees numbers.
Everything that goes into an AI model gets converted into numbers first. Always. Without exception. A 256x256 image becomes 196,608 numbers. A sentence becomes hundreds of numbers. A customer's purchase history becomes a list of numbers.
The container that holds those numbers is called a vector.
The Simplest Definition
A vector is a list of numbers.
That's it. Start there. Don't let anyone make it more complicated than that at the beginning.
import numpy as np
height = np.array([5.9]) # one number, one dimension
point = np.array([3, 4]) # two numbers, two dimensions
color = np.array([255, 128, 0]) # three numbers, RGB
profile = np.array([28, 1, 3, 7]) # age, married, kids, purchases
Each of these is a vector. A structured list of numbers where each position means something specific.
Why Not Just Use a Python List
You could store numbers in a regular Python list. So why does everyone use NumPy arrays instead?
Speed. And operations.
import numpy as np
import time
size = 1_000_000
python_list = list(range(size))
numpy_array = np.arange(size)
start = time.time()
python_result = [x * 2 for x in python_list]
print(f"Python list: {time.time() - start:.4f} seconds")
start = time.time()
numpy_result = numpy_array * 2
print(f"NumPy array: {time.time() - start:.4f} seconds")
Output (roughly):
Python list: 0.1823 seconds
NumPy array: 0.0021 seconds
NumPy is about 80 to 100 times faster for numerical operations. It achieves this by storing numbers in contiguous memory blocks and using optimized C code underneath. When you are working with millions or billions of numbers in AI, that difference is not optional.
Direction and Magnitude
Here is where vectors become more than just lists.
A vector has two properties. Magnitude (its length) and direction (which way it points).
Imagine you are standing in a city. Someone says "go 3 blocks east and 4 blocks north." That instruction is a vector. [3, 4]. It has a direction (northeast) and a magnitude (how far total).
v = np.array([3, 4])
magnitude = np.linalg.norm(v)
print(f"Magnitude: {magnitude}")
Output:
Magnitude: 5.0
The magnitude is 5 because of the Pythagorean theorem. 3 squared plus 4 squared equals 25. Square root of 25 is 5. Your high school math, right here in AI code.
Why does magnitude matter? In AI, the magnitude of a vector often represents intensity or importance. A loud sound has a higher magnitude audio vector than a quiet one. A highly active user has a higher magnitude behavior vector than a passive one.
Vectors as Data Points
This is the mental shift that matters.
Every data point in your dataset is a vector. A row in a spreadsheet. A user. A product. A medical record. Each one becomes a point floating in mathematical space.
Take a simple dataset of two house features: size in square feet and number of bedrooms.
house1 = np.array([1200, 2]) # 1200 sqft, 2 bedrooms
house2 = np.array([2400, 4]) # 2400 sqft, 4 bedrooms
house3 = np.array([800, 1]) # 800 sqft, 1 bedroom
Three houses. Three vectors. Three points in a two-dimensional space.
Now here is the useful part. Houses that are similar to each other will have vectors that point in similar directions and have similar magnitudes. Houses that are different will have vectors that point in different directions.
This is not just a nice way to think about it. This is the actual mathematical basis for recommendation systems, nearest neighbor search, clustering, and more. Similar things have similar vectors. Your model learns to put similar things near each other in vector space.
Basic Vector Operations
Vectors support math operations that work element by element.
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(a + b) # add element by element
print(a - b) # subtract element by element
print(a * 2) # multiply every element by 2
print(a * b) # multiply element by element
Output:
[5 7 9]
[-3 -3 -3]
[2 4 6]
[4 10 18]
Adding two vectors combines their components. Multiplying by a scalar scales the whole vector. Multiplying two vectors element by element gives you a new vector.
These operations run on every element simultaneously without a loop. That is why NumPy is fast.
What Vectors Look Like in Real AI
Three concrete examples of what vectors represent in actual AI systems.
Word embeddings. The word "king" might be represented as a vector of 300 numbers. "queen" also has a vector of 300 numbers. The famous result: king - man + woman is very close to queen in vector space. The meaning of words is encoded in the direction and position of their vectors.
Image pixels. A 28x28 greyscale image (like the MNIST handwritten digits dataset) becomes a vector of 784 numbers. Each number is a pixel brightness from 0 to 255. The entire image is one point in 784-dimensional space.
User behavior. A user on a streaming platform might be represented by a vector where each dimension represents how much they have watched a genre. Action movies score high in the action dimension. Romance fans score high in the romance dimension. Similar users have similar vectors. That is how recommendations work.
user_alex = np.array([8, 2, 9, 1, 7]) # [action, romance, sci-fi, horror, thriller]
user_priya = np.array([7, 3, 8, 2, 6]) # similar taste to Alex
user_sam = np.array([1, 9, 2, 1, 2]) # completely different taste
Just looking at the numbers you can already tell Alex and Priya have similar preferences. Sam is different. In the next post you will see the exact mathematical operation that measures this similarity precisely.
High Dimensional Vectors
In real AI, vectors are not two or three dimensional. They can be hundreds or thousands of dimensions.
GPT-style models use vectors of 768, 1024, or even 12288 dimensions per token. Image models work in spaces of millions of dimensions.
You cannot visualize this. Nobody can. But the math works the same way whether you have 2 dimensions or 12,288. Addition still adds. Magnitude is still the square root of the sum of squares. Direction still matters.
This is one of the key mental leaps in AI. You do not need to visualize high-dimensional spaces. You need to trust that the same geometric intuitions you have for 2D and 3D extend to any number of dimensions. They do.
word_vector = np.random.randn(768) # a 768-dimensional word embedding
print(f"Shape: {word_vector.shape}")
print(f"First 5 values: {word_vector[:5]}")
print(f"Magnitude: {np.linalg.norm(word_vector):.4f}")
Output:
Shape: (768,)
First 5 values: [ 0.4832 -1.2341 0.7823 0.1029 -0.5541]
Magnitude: 27.6819
768 numbers. One word. That is how language models see the word "python."
Try This
Create vectors_practice.py.
Part one: create three vectors representing three students. Each vector should have four elements: study hours per day, sleep hours per day, practice problems solved, and attendance percentage. Make up realistic numbers for each student.
Calculate the magnitude of each student vector. Which student has the highest magnitude vector overall?
Part two: you have a model prediction vector and a ground truth vector.
predictions = np.array([2.5, 0.0, 2.1, 1.5, 3.2])
actual = np.array([3.0, 0.5, 2.0, 1.0, 3.0])
Calculate the difference vector. Calculate the squared difference vector. Calculate the mean of the squared differences. This number is called the Mean Squared Error and it is one of the most important measurements in all of machine learning. You just calculated it from scratch.
Part three: create two user preference vectors of length 5. Scale one of them by 0.5. Add them together. What does the resulting vector represent intuitively?
What's Next
You know what vectors are. You know they represent data. But how do you measure whether two vectors are similar or different?
There is one specific operation that answers that question. It is called the dot product and it is the single most important mathematical operation in all of AI. Almost every meaningful computation in neural networks, transformers, and recommendation systems traces back to it.
Next post.
Top comments (0)