Back to Blog

understanding vector in ai

5 min read
Date
Mar 18, 2026
Description
about vectors in computer science
Published
Published
Slug
vector
vectors are fundamental mathematical structures that play a crucial role in artificial intelligence and machine learning. they provide a way to represent data in a format that computers can process efficiently.
notion image

what is a vector?

in mathematics and computer science, a vector is an ordered collection of numbers. these numbers are called components or elements of the vector. vectors can represent various types of information in ai systems.
for example, a simple 2-dimensional vector might look like this: [3, 5]
a 3-dimensional vector could be: [2.5, -1.0, 4.3]

why vectors matter in ai

vectors are essential in ai because they allow us to:
  • represent complex data in numerical form
  • perform mathematical operations on data
  • measure similarity between different pieces of information
  • enable machine learning algorithms to learn patterns

common applications of vectors in ai

word embeddings

in natural language processing, words are converted into vectors. similar words have similar vector representations.
example:
  • the word "king" might be represented as: [0.5, 0.8, 0.3, 0.1, ...]
  • the word "queen" might be: [0.52, 0.79, 0.31, 0.12, ...]
these vectors are close to each other in vector space because the words have similar meanings.

image representation

images can be represented as vectors where each pixel's color values become elements in the vector.
example: a small 2x2 grayscale image might be represented as:
[255, 128, 64, 200]
where each number represents the brightness of one pixel.

feature vectors in machine learning

when training machine learning models, we represent each data point as a feature vector.
example: a house might be represented by features like:
[square_feet, number_of_bedrooms, age_of_house, distance_to_city]
[2500, 4, 15, 5.2]

vector operations in ai

vector addition

adding two vectors combines their components element-wise.
example:
[2, 3] + [1, 4] = [3, 7]
in word embeddings, this enables interesting relationships:
vector(king) - vector(man) + vector(woman) ≈ vector(queen)

dot product

the dot product measures how similar two vectors are in direction.
example:
[2, 3] · [4, 1] = (2×4) + (3×1) = 8 + 3 = 11
this is used extensively in recommendation systems and similarity calculations.

cosine similarity

cosine similarity measures the angle between two vectors, indicating how similar they are.
values range from -1 (opposite) to 1 (identical).
this is widely used in:
  • document similarity comparison
  • recommendation engines
  • semantic search systems

vector databases

modern ai systems use specialized vector databases to store and search through millions of vectors efficiently.
example use case: a semantic search engine converts your query into a vector and finds the most similar document vectors in the database.

practical example

when you search for "best italian restaurants", the system:
  1. converts your query into a vector: [0.2, 0.9, 0.1, ...]
  1. compares it against all restaurant description vectors in the database
  1. returns the restaurants with the most similar vectors

vector dimensions

the dimensionality of a vector refers to how many numbers it contains.
  • low-dimensional vectors (2-10 dimensions): easy to visualize but may lose information
  • medium-dimensional vectors (50-300 dimensions): common in word embeddings
  • high-dimensional vectors (512-4096+ dimensions): used in modern language models and image recognition

real-world example: recommendation system

imagine a music recommendation system:
  1. each song is represented as a vector based on features: [tempo, energy, danceability, acousticness, valence]
  1. song a: [120, 0.8, 0.9, 0.1, 0.7]
  1. song b: [118, 0.82, 0.88, 0.12, 0.69]
  1. song c: [80, 0.3, 0.2, 0.9, 0.4]
the system calculates that songs a and b are similar (close vectors) and recommends them together. song c is different (distant vector) and would be recommended to different users.

key takeaways

  • vectors transform complex data into numerical representations that ai can process
  • vector operations enable similarity comparisons and pattern recognition
  • modern ai systems rely heavily on vector representations for tasks like language understanding, image recognition, and recommendations
  • understanding vectors is fundamental to grasping how ai systems work internally
vectors are the mathematical foundation that powers much of modern artificial intelligence, enabling machines to understand, compare, and learn from data in ways that were previously impossible.