Concepts

Vectors

4 min readbeginnerUpdated 28 Sept 2026
1 · In one line

A vector is an ordered list of numbers that you can also picture as an arrow in space. Machine learning stores examples, words and images this way.

1 · What it is

A vector is an ordered list of numbers, such as (3, 1). The order is part of the meaning: each position stands for one thing, and the number of positions is how many dimensions the vector has. So (3, 1) and (1, 3) are different vectors. You can also draw the list as an arrow that starts at the origin and ends 3 steps along and 1 step up. Mathematicians keep a third view too: a vector is anything you can add to another vector and stretch by a number.

Machine learning stores its data as vectors. Each example a model sees becomes a feature vector, one decimal number per feature. A small greyscale photo of 28 by 28 pixels is 784 brightness values from 0 to 255, which a network can flatten into one long row. Text goes in as embedding vectors, lists of learned numbers in which similar items get similar values. These lists are long. Google’s Gemini embedding models return 3,072 numbers by default and recommend 768 or 1,536 as smaller sizes, and OpenAI’s text-embedding-3-small returns 1,536.

Only a few moves are needed. Adding works position by position, and on the grid it means placing one arrow after the other. Scaling multiplies every number by the same amount, which stretches the arrow without turning it. Length, also called the norm, is the square root of the sum of the squared numbers. The distance between two vectors is the length of their difference. In an embedding, a small distance means two items are closely related, which is why search and recommendation compare vectors. The dot product and cosine similarity are two other ways to compare them.

In code, a vector is usually a one-dimensional array. NumPy’s norm function returns the ordinary length by default, and PyTorch holds a model’s inputs, outputs and parameters as tensors, which work like NumPy arrays but can run on GPUs. A table of vectors stacked together is a matrix, and the study of both is linear algebra.

2 · Why it exists

Computers need one shared shape for very different kinds of data.

Data is not numbersPrices, photos and words look nothing alike, and many features start out as text rather than numbers a model can use.
Similarity needs a measureTo say two things are alike, a program needs a calculation that turns two items into one number.
Code needs arraysProgramming languages and hardware are built to work on arrays of numbers, not on loose facts.
3 · How it works

Follow two small vectors through the basic moves.

Illustrative vectors. Every move on the right is plain arithmetic on the lists, and each one also has a picture on the grid.
  1. 1 · listWrite the vector as numbers in a fixed order, such as u = (3, 1), where each position is one dimension.
  2. 2 · drawRead the same list as an arrow from the origin, 3 steps along and 1 step up.
  3. 3 · addAdd two vectors position by position, so (3, 1) + (1, 2) = (4, 3), which is one arrow placed after the other.
  4. 4 · scaleMultiply every number by the same amount, so 2u = (6, 2) points the same way and is twice as long.
  5. 5 · measureTake the square root of the sum of the squares to get a length, and the length of a difference to get a distance.

The list and the arrow are the same object, so you can compute with one view and reason with the other.

4 · Where it's used
WhoWhat they askWhat it works with
Search team“Which stored passages sit closest to this question?”Embedding vectors of the question and every passage
Image classifier team“How do we feed a 28 by 28 photo into a dense layer?”784 pixel values flattened into one vector
House-price team“Does every row give its features in the same order?”One feature vector per house
Recommendation team“Would 768 numbers per item store as well as 3,072?”Embedding vectors for every product
5 · What it solves, and what it doesn't
solves
  • Gives numbers, pixels and words one shared format that a model can compute with.
  • Turns how alike two things are into a distance you can calculate.
  • Maps straight onto arrays in NumPy and tensors in PyTorch, which can run on GPUs.
  • The same add, scale and length rules work with two positions or thousands.
doesn't solve
  • A learned vector rarely tells you what each position means.
  • Longer vectors cost more compute, memory and storage.
  • Multiplying two vectors position by position is a coding shortcut, not a standard vector operation.
  • Array code does not always do the vector maths you intended, so results need checking.
6 · Go deeper

Sources used

This explainer is written in original language. The links below support its factual claims.

  1. paperMathematics for Machine Learning (book PDF), chapters 1 to 3, Cambridge University Press (Deisenroth, Faisal and Ong) · read 27 Sept 2026
  2. docsMachine Learning Glossary, Google for Developers · read 27 Sept 2026
  3. docsNumerical data: How a model ingests data using feature vectors (Machine Learning Crash Course), Google for Developers · read 27 Sept 2026
  4. docsEmbeddings: Embedding space and static embeddings (Machine Learning Crash Course), Google for Developers · read 27 Sept 2026
  5. docsnumpy.linalg.norm, NumPy · read 27 Sept 2026
  6. docsTensors (Learn the Basics), PyTorch · read 27 Sept 2026
  7. docsBasic classification: Classify images of clothing, TensorFlow · read 27 Sept 2026
  8. docsEmbeddings (Gemini API), Google AI for Developers · read 27 Sept 2026
  9. docsVector embeddings, OpenAI · read 27 Sept 2026