An embedding represents something as a list of numbers, called a vector. An embedding model learns to give related things similar vectors, so an application can compare them using math.
Geographic coordinates
Geographic coordinates are a familiar way to represent a place with numbers. A city's latitude and longitude tell us where it is on the globe. Chicago is roughly 41.9° north, 87.6° west. Those two numbers let us calculate how far it is from another city.
City Coordinates
People define the coordinate system for places. For text embeddings, a model learns to assign coordinates based on relationships between pieces of text. Those coordinates form a vector in an embedding space.
Real text embeddings often have hundreds or thousands of numbers. Unlike latitude and longitude, each number usually has no simple meaning on its own. What matters is how the vectors compare.
Search by meaning
Semantic search uses embeddings to find relationships between text with similar meaning. For example, a search for “a purring pet” should be able to find “a sleeping cat,” even though the phrases share no words.
The demo below uses three-dimensional vectors to visualize the idea.
Semantic Search
The query and each phrase have a vector. The demo ranks phrases by cosine similarity, which compares the directions of two vectors. A higher score means their directions are more alike.
In an application, you would embed documents once and save their vectors. For each search, embed the query into the same space, compare it with the saved vectors, and return the best matches.