Spaces and Directions (Vectors)

Why AI constantly works with arrows in n-dimensional space.

Fundamentals 11 min Beginner May 11, 2026

What do a photo, a sentence, and a song have in common? Before any AI model can process them, they all become the same thing: a list of numbers. That list is called a vector. Vectors are the universal data format of artificial intelligence.

In this article, you will learn what vectors are, how to work with them (add, scale, measure), and why the dot product — a simple sum of multiplied components — is the operation that makes search engines find relevant results and neural networks recognize patterns.

Scalar vs. Vector — Single Value vs. List

Scalar and Vector

AnalogyDefinition
GPS coordinates: A single latitude value (52.52) is a scalar — it only pins you to a line. Add longitude [52.52, 13.41] and you have a 2D vector that locates Berlin. Add altitude [52.52, 13.41, 34] — a 3D vector. AI embeddings work identically, just with 768+ dimensions.

Example

GPS has 2-3 dimensions with clear physical meaning. AI embedding dimensions are emergent — learned by optimization — and not directly interpretable.
1
Latitude: 52.52 — a scalar (1D). Pins only a line.
2
+ Longitude: [52.52, 13.41] — a 2D vector. Locates Berlin.
3
+ Altitude: [52.52, 13.41, 34] — a 3D vector.
4
Embedding: 768 dimensions — the math stays identical.

Every data point becomes a vector: A house with Area=120, Rooms=4, Year=1990, Price=350,000 becomes [120, 4, 1990, 350000] — a 4D feature vector. 1,000 houses = 1,000 vectors = an ML dataset.

import numpy as np

# A house as a 4D feature vector
house = np.array([120, 4, 1990, 350000])
print(house.shape)  # (4,) — 4 dimensions

Misconception: A Vector Is an Arrow

In 2D/3D you can draw a vector as an arrow — useful for getting started. But in higher dimensions (e.g. 768D for a sentence embedding), there are no arrows. A vector is an abstract ordered list of numbers. The arrow intuition is a starting point, not the full picture.

EVERY input to a neural network — text, image, audio — is first converted into a numerical vector. No vectors, no AI.

Vector Operations — Add, Scale, Measure

Three fundamental operations make vectors the workhorse of AI: addition, scalar multiplication, and the norm (length).

Vector Addition

Vector Addition
[a₁, a₂] + [b₁, b₂] = [a₁+b₁, a₂+b₂]

Componentwise: Each position is added separately. Geometrically, this means chaining vectors end-to-end (parallelogram rule).

Scalar Multiplication

Scalar Multiplication
c · [a₁, a₂] = [c·a₁, c·a₂]

Each component is multiplied by the same scalar. This stretches (c > 1), shrinks (0 < c < 1), or reverses (c < 0) the vector.

Norm (Length)

Euclidean Norm
‖v‖ = √(v₁² + v₂² + … + vₙ²)

The norm generalizes the Pythagorean theorem to any number of dimensions. For [3, 4]: sqrt(9 + 16) = sqrt(25) = 5.

import numpy as np
v1 = np.array([3, 4])
v2 = np.array([1, 2])

print(v1 + v2)              # [4, 6]  — Addition
print(2 * v1)               # [6, 8]  — Scalar multiplication
print(np.linalg.norm(v1))   # 5.0    — Norm
print(v1 / np.linalg.norm(v1))  # [0.6, 0.8] — Normalization

Normalization: Only Direction Matters

Dividing a vector by its norm produces a unit vector (length 1). Direction is preserved, scale is removed. In embedding pipelines this is essential: Two documents about the same topic should be similar regardless of their length.

The Dot Product — Measuring Similarity

Dot Product
a · b = a₁b₁ + a₂b₂ + … + aₙbₙ

The sum of componentwise products. The result is a scalar — a single number.

Geometric Interpretation
a · b = ‖a‖ · ‖b‖ · cos(θ)

Same direction → cos(0°) = 1 → maximum dot product. Perpendicular → cos(90°) = 0. Opposite → cos(180°) = -1.

Dot Product

Measures directional similarity, but is also influenced by vector length.

Euclidean Distance

Measures how far apart two points are in space (distance).

Cosine Similarity

Cosine Similarity
cos(θ) = (a · b) / (‖a‖ · ‖b‖)

The normalized dot product yields a value between -1 and +1, independent of vector length. In word embeddings, cosine similarity is the standard metric for semantic relatedness.

0.66
King / Queen
0.41
King / Apple
768
Embedding Dimensions
import numpy as np

king  = np.array([0.9, 0.1, 0.8])
queen = np.array([0.9, 0.8, 0.1])
apple = np.array([0.1, 0.3, 0.05])

def cosine_sim(a, b):
    return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

print(cosine_sim(king, queen))  # ~0.66
print(cosine_sim(king, apple))  # ~0.41

Misconception: The Dot Product Measures Distance

The raw dot product is influenced by vector length — double a vector, and its dot product with any other vector doubles too. It measures a combination of direction and magnitude. Cosine similarity removes the length factor and compares pure direction. Distance is measured by Euclidean distance ||a - b||.

Neuron Computation
z = w · x + b

Every neuron in a neural network computes exactly one dot product: weight vector w times input vector x plus bias b. The perceptron demo on this portal shows this operation in action.

Interactive: How Operations Scale with Dimension

Move the slider to change the number of dimensions d — from a simple 2D coordinate to a 1000-dimensional embedding. Observe how differently the costs of various operations grow: vector addition and dot product scale linearly with d, but the number of data points needed for adequate coverage explodes exponentially.

21000
O(log d)6.6
O(d)100
O(d²)10.000
O(2ᵈ)1.073.741.824
Moderate Input

At n=100, the difference becomes visible: O(n²) requires 10.000 operations, while O(n) needs only 100. O(log n) needs just 6.6 — that's 15x less than O(n).

Ratio to O(n)

ComplexityOperationsFactor vs. O(n)
O(log d)6.615x faster
O(d)1001x (Reference)
O(d²)10.000100x slower
O(2ᵈ)1.073.741.82410737418x slower

"More dimensions = better" is a common misconception. In very high dimensions, all pairwise distances converge — everything becomes equally far from everything else.

Distance-based algorithms (k-NN, clustering) lose their effectiveness. This is why dimensionality reduction techniques like PCA and t-SNE exist: They project high-dimensional data into a lower-dimensional space that preserves the most important structures.

Key Takeaways

  • A scalar is one number; a vector is an ordered list of numbers. Every AI input — text, image, audio — gets converted into a vector.
  • Vectors can be added, scaled, and measured. The norm gives length; normalization preserves only direction.
  • The dot product measures how aligned two vectors are. Cosine similarity normalizes this to [-1, +1] and is the standard metric for embeddings. Every neuron computes a dot product.

Quiz: Vectors

Question 1 / 4
Not completed

What is the difference between a scalar and a vector?

Select one answer
Answer Key: 1) B · 2) C · 3) B · 4) B

Learning Goals

  • Explain what a 768-dimensional vector describes in a language model and why this space cannot be visualized.
  • Describe what happens geometrically when you multiply a vector by the scalar -1.
  • Why is cosine similarity better suited for comparing word embeddings than the raw dot product?