Skip to the workspace
Pebellslearn by building
Introduction to AI Engineering  ›  Lesson

Embeddings and Vector Databases

Embeddings 12 minAn embedding turns a piece of text into a list of numbers so that texts with similar meaning land close together, and a vector database finds the nearest ones quickly.

ai engineer / Embeddings and Vector Databases

Explore each scene at your own pace.

01 · The rule

The rule

Embeddings and Vector Databases

A customer types "Can I send my bike back?". Pedal Point has a page titled "Returns policy" that answers exactly this. The old keyword search finds nothing, because the two texts share no useful words. People search by meaning; computers searched by spelling. Embeddings close that gap.

The rule

Embeddings turn meaning into coordinates; close points mean similar meaning.

An embedding model reads a piece of text and outputs a vector: a fixed-length list of numbers, often hundreds or thousands long. You can picture each vector as a point in a space with many dimensions.

The model is trained so that texts with similar meaning land near each other:

  • "Can I send my bike back?" and "Returns policy" land close.
  • "How do I fix a squeaky brake?" lands somewhere else entirely.

"Near" is measured with a similarity score. The most common is cosine similarity, which compares the direction two vectors point. Pointing the same way scores close to 1; unrelated directions score near 0.

A vector database stores many vectors, each linked to its original text and some labels, and answers one question fast: "Which stored vectors are nearest to this one?" With millions of vectors, checking every one is slow, so these databases use clever indexes that find very good matches without comparing everything.

Embeddings power semantic search, recommendations ("customers who read this also read"), grouping similar tickets, and spotting unusual ones. They are also the heart of the next lesson, RAG.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.