Vector Database Handbook from zero to production Bipin Singh
The basics

Vectors and embeddings

2 min readChapter 02 of 25By Bipin Singh

Before a database can find "similar" things, those things need to become numbers. This chapter explains what a vector is, how an embedding model turns text or images into vectors, and why that works.

A vector is just a list of numbers

A vector is an ordered list of numbers. [3, 4] is a vector with two numbers — two dimensions. You can draw it as an arrow from the origin to the point (3, 4) on a graph.

Vectors can describe anything you can measure. A house could be [bedrooms, area_in_100_sqft, age_in_years] = [3, 12, 5]. Two houses with similar vectors are similar houses.

Embeddings: vectors that capture meaning

Hand-picking features works for houses, but not for sentences — what would the "features" of "my card got declined" be? This is where embedding models come in. An embedding model is a neural network trained on huge amounts of data so that:

The vector the model produces is called an embedding.

catkittendogpuppycartruckbusapplebananamangoquery: "kitty"
A toy 2-D embedding space. Related words cluster together; the query "kitty" lands next to cat and kitten.

Real embeddings don't have two dimensions — they typically have hundreds or thousands — but the principle is exactly what the picture shows: meaning becomes position.

What do the dimensions mean?

In the house example, each number had a clear meaning. In a learned embedding, individual dimensions usually don't have a human-readable meaning. Meaning is spread across all of them together. You can't point at dimension 417 and say "this is the animal-ness dimension." What matters is the overall position, and therefore distance to other vectors.

Common embedding sizes are in the hundreds to a few thousand dimensions. More dimensions can capture finer detail but cost more storage and compute; we cover this trade-off in Sizing and scaling.

What can be embedded?

Input Example embedding models do
Text Sentences, paragraphs, document chunks, queries
Images Photos, screenshots, product images
Text + images together Multimodal models put both in the same space, so text can find images
Code Functions and snippets, for code search
Audio Clips of speech or music
Users and items Learned from behaviour, for recommendations

Getting embeddings in practice

You send text to an embedding model — via a hosted API or a model you run yourself — and get a vector back:

// Illustrative: the exact client and model name depend on your provider.
const response = await embeddings.create({
  model: "your-embedding-model",
  input: "My card got declined at the shop",
});
const vector: number[] = response.data[0].embedding; // e.g. [0.012, -0.044, 0.31, ...]

Rules that save you pain later

  1. Use the same model for storing and querying. Vectors from different models live in different spaces and can't be compared — like measuring one house in feet and another in metres, but worse.
  2. Record which model (and version) produced each vector. If you change models, you must re-embed everything. See Operations.
  3. Embed the right unit. A whole 50-page manual squeezed into one vector loses detail; split long content into chunks first. The RAG Handbook covers chunking in depth.
  4. Respect the model's input limit. Text beyond the maximum length is truncated or rejected.
Key idea

An embedding model is a translator from "meaning" to "position in space". A vector database is the system that stores those positions and finds neighbours quickly.

Bipin Singh
Written by Bipin Singh

Senior Full-Stack Engineer · AI & AWS. I build production search, RAG and AI systems on AWS and Postgres.

Work with me