# Embeddings

> The Embeddings are numerical vector representations of data that capture its meaning.

## What are embeddings in AI?

The vectors of numbers that represent text, images or other data so that similar meanings are located close to each other. Used for semantic search, recommendations and RAG.

- Topic: Retrieval
- Type: concept

## Example

Wrong:

```js
const docVectors = await embed('model-a', docs);
const queryVector = await embed('model-b', query);
```

Right:

```js
const EMBEDDING_MODEL = 'model-a';
const docVectors = await embed(EMBEDDING_MODEL, docs);
const queryVector = await embed(EMBEDDING_MODEL, query);
```

Each model has its own vector space, so documents and queries must be embedded with the same model.

## Common mistakes

- Mixing vectors from two embedding models in one index, so search returns nonsense.

## Key points

- Documents and queries are embedded with the same model.
- The vector size of the index matches the output size of the embedding model.
- Stored vectors are regenerated when the embedding model changes.

## Interview questions

### What are embeddings used for?

Semantic search, RAG retrieval, clustering, recommendations and duplicate detection: any task that compares meaning.

### How many dimensions should embeddings have?

The model sets it. More dimensions can hold more detail but need more storage and slower search.

### Can I compare embeddings from different models?

No. Mixed vectors give meaningless scores. Re-embed all documents when you switch models.

## Related cards

- [Vector Database](https://wonderium.dev/ai/vector-database.md)
- [Cosine Similarity](https://wonderium.dev/ai/cosine-similarity.md)
- [Semantic Search](https://wonderium.dev/ai/semantic-search.md)
- [Chunking](https://wonderium.dev/ai/chunking.md)
- [RAG](https://wonderium.dev/ai/rag.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/embeddings
- Last updated: 2026-11-25
