Skip to content
Latchkey

What Is an Embedding? Turning Data Into Vectors Explained

An embedding is a numerical vector that represents the meaning of a piece of data, so that semantically similar items end up close together in vector space.

Computers cannot reason about raw text or images directly, but they handle numbers well. An embedding is the bridge: a learned vector that encodes the meaning of an input so that similar inputs map to nearby vectors. Embeddings are the foundation of modern search, recommendation, and generative AI.

What an embedding is

An embedding is a fixed-length list of numbers - often hundreds or thousands of dimensions - produced by a model for a piece of input. The key property is that distance in this vector space reflects semantic similarity: similar items are close, unrelated items are far apart.

How embeddings are made

A trained embedding model (such as a sentence transformer or an OpenAI embedding model) maps each input to its vector. The model has learned, from large amounts of data, to place similar concepts near each other, so "dog" and "puppy" land closer than "dog" and "spreadsheet".

What embeddings enable

Once data is embedded, you can search by similarity, cluster related items, deduplicate, recommend, and feed relevant context to an LLM in retrieval-augmented generation. Embeddings are stored and searched in a vector database for fast similarity lookup.

Embeddings in CI

Pipelines that generate or rely on embeddings are tested in CI, often by embedding sample inputs and asserting that expected items rank as most similar.

Testing embedding logic in CI
steps:
  - run: pip install sentence-transformers
  - run: pytest tests/embeddings   # assert nearest-neighbor order

Latchkey note

Embedding models are large and run far faster on a GPU. On Latchkey, run embedding generation on GPU or larger runners, cache the model weights between runs so they are not re-downloaded each time, and auto-retry the transient fetch of the model or sample data.

Key takeaways

  • An embedding is a numerical vector that encodes meaning, placing similar items close together.
  • A trained model maps each input to its vector based on patterns learned from large data.
  • Embeddings power similarity search, clustering, and RAG, and are stored in a vector database.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →