How an embedding is made
- A model. A text model turns words into vectors, an image model turns pixels into vectors, and a joint text and image model is trained so that a photo and a caption describing it land close together.
- A fixed number of dimensions. Each model always outputs the same length, commonly 384, 512, 768 or 1,024 numbers. No single number has a readable meaning; the information is in the whole list.
- Normalisation. Vectors are often scaled to a length of 1, so that comparing them is a simple multiplication.
- One model per comparison. A query and the items it is compared with must be embedded by the same model. Vectors from two models cannot be compared, so changing the model means embedding the whole library again.
Measuring similarity
| Measure | What it compares | Typical use |
|---|---|---|
| Cosine similarity | The angle between two vectors, ignoring their length | Text and image embeddings |
| Euclidean (L2) distance | The straight-line distance between two points | Small fingerprints, some image models |
| Dot product | Angle and length together; equal to cosine for normalised vectors | Fast ranking of normalised vectors |
Vector databases and indexes
A vector database stores embeddings and answers one question quickly: which stored vectors are nearest to this one? Comparing a query with every vector is exact but slow once a library holds millions of items. Approximate nearest neighbour (ANN) indexes give up a small amount of recall for a large gain in speed. The most widely used is HNSW (Hierarchical Navigable Small World), a graph index described by Malkov and Yashunin in 2016.
There are two ways to run one:
- a dedicated vector database, kept in sync with the main database;
- a vector extension inside a general database, such as the open-source pgvector extension for PostgreSQL. Filters, permissions and joins then run in the same query as the similarity search, and there is no second system to synchronise.
What embeddings are used for in a DAM
| Content embedded | Used for |
|---|---|
| The asset's text: title, description, tags, captions, OCR text | Finding assets by the meaning of a query |
| The search query | Comparison with the stored text embeddings |
| The image itself | Finding look-alikes, crops and duplicates |
| Each detected face | Recognising the same person across photos |
Limits and common mistakes:
- Embeddings do not know identifiers. A SKU, a campaign code or a file name has no meaning to a language model. Keyword search still handles them, which is why most systems combine the two in hybrid search.
- An index always returns neighbours, even when none is relevant. A similarity threshold decides what counts as a match.
- Stale vectors. If an asset's description changes and its embedding is not recomputed, search keeps matching the old description.
- Face embeddings are personal data. Under the GDPR, biometric data processed to identify a person is a special category (Article 9), which needs a legal basis and a clear retention policy.
Vector embeddings in Freedam
- Embeddings are stored in PostgreSQL with the pgvector extension and searched through HNSW indexes, in the same database as the assets. There is no separate search service.
- Each asset gets a 768-dimensional multilingual text embedding built from its descriptive text (the fields are listed in the semantic search entry). It is computed again when that text changes, and skipped when the text is the same as last time.
- Images also get a vision embedding from their preview, used by visual search and near-duplicate detection. Detected faces get their own embeddings, and a recognition threshold (0.6 by default) decides when two faces count as the same person.
- Every search runs keyword ranking (BM25) and vector similarity together and merges the results. On the Search Configuration page, administrators set the weight of each, the number of vector candidates per search (200 by default) and similarity thresholds that depend on the length of the query.
- On the AI page, administrators choose which model produces asset embeddings and search phrase embeddings.
Details: Searching by meaning and Search Configuration in the Freedam docs, and the engineering article What it actually takes to build a good image search.
Frequently asked questions
What is the difference between a vector embedding and a vector database?
An embedding is the list of numbers that represents one item. A vector database stores many embeddings and finds the ones nearest to a query. The database can be a dedicated product or an extension of an existing database.
How many dimensions should an embedding have?
The model decides, not the user. More dimensions can hold finer distinctions but take more storage and slower comparisons. For search in a media library, models with 512 to 1,024 dimensions are common, and the quality of the model matters more than its size.
Can you search images with words using embeddings?
Yes, in two ways. A joint text and image model places a query and an image in the same space, so the query can be compared with the picture directly. Alternatively, the system describes each image in words first (tags, captions, OCR text) and compares the query with that text.
Related terms
Search Nordi's library by meaning and by image
Type a description into Nordi's library and find photos tagged with other words, then drop a photo into visual search to find images that look like it.
You enter Nordi’s workspace as an administrator.