Embeddings are numerical representations of data that capture meaningful relationships between items such as text, images, audio, or code. Similar items are represented by vectors that are closer together in an embedding space, allowing systems to compare and find relationships between data mathematically.
Embeddings are commonly used for semantic search, recommendations, clustering, retrieval-augmented generation (RAG), and classification. For example, two pieces of text can use different words but have similar meanings, and their embeddings may still be close to each other.
From a testing perspective, embeddings introduce a different challenge because there is rarely a single correct vector or exact expected value. Testing focuses more on whether similar inputs remain meaningfully close, unrelated inputs remain sufficiently separated, and small changes to input do not cause unexpected changes in relationships. The choice of distance or similarity measure can also affect how these relationships are interpreted.
Testers can evaluate embeddings using similarity measures, representative datasets, nearest-neighbour checks, clustering behaviour, and task-specific evaluation. Testing should consider sensitivity to spelling, language, formatting, domain-specific terminology, and changes to the embedding model.
Embeddings from different models or model versions are generally not directly comparable, even when they have the same dimensions. This can create silent failures in systems that store vectors over time. For example, upgrading an embedding model without re-embedding existing data can reduce retrieval quality in a RAG system while the underlying application continues to appear functional.
Testers should also consider whether embeddings encode unwanted bias from their training data, such as associating unrelated concepts based on historical or cultural patterns.
An embedding model can produce technically valid vectors while still producing poor results for the application using them. A useful testing question is therefore not simply βIs the embedding correct?β, but βDoes the embedding preserve the relationships the system depends on?β