# Text Embeddings

> Embedding models map text to vectors so that similar meanings land close together, powering semantic search, clustering and RAG. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/embeddings
Last updated: 2026-11-28

Embedding models map text to vectors so that similar meanings land close together, powering semantic search, clustering and RAG.

Beginner · about 4 hours · difficulty 2/5

Learn first: [Messages APIs and Provider SDKs](https://www.internhack.in/roadmaps/tracks/ai-engineer/first-api-calls), [Transformers and Attention, Intuitively](https://www.internhack.in/roadmaps/tracks/ai-engineer/transformers-attention)

An **embedding** is a list of numbers (a vector, often hundreds to a few thousand dimensions) that represents the meaning of a piece of text. Texts about similar things produce vectors that point in similar directions, even with no shared words: "reset my password" lands near "I cannot log in".

### Where embeddings are used

- **Semantic search** and the retrieval step of RAG.
- **Clustering and deduplication** of feedback, tickets or documents.
- **Classification** with a small classifier on top, or nearest-neighbour labelling.
- **Recommendations** and "similar items".

### Choosing an embedding model

- Hosted options come from OpenAI, Google, Cohere, Voyage and others; open models (for example from the sentence-transformers ecosystem, BGE, E5, Nomic families) run locally.
- Compare on the **MTEB leaderboard**, but test on your own data and language.
- Consider dimensions (storage cost), max input length, multilingual support and price.

### Rules to remember

- **Queries and documents must be embedded with the same model.** Switching models means re-embedding everything.
- Some models expect different prefixes or task types for queries versus documents; read the model card.
- Embeddings capture topic similarity, not truth or exact matches. Product codes and names are often better handled by keyword search.

### Good enough to move on

You can embed a set of texts, find the nearest neighbours of a query, and explain why a keyword search would have missed some of the results.

## Key concepts

- **What an embedding vector represents**
- **Hosted embedding APIs**
- **sentence-transformers and open models**
- **MTEB leaderboard**
- **Query vs document embeddings**
- **Dimensions and storage cost**
- **Clustering and visualization**

## Mini project

Embed 500 short texts (for example job titles or FAQ questions), build a tiny semantic search CLI with numpy, and plot clusters with a 2D projection.

## Check yourself

You upgraded your embedding model but only re-embedded new documents. What breaks and why?

## Free resources

- [Sentence Transformers documentation](https://www.sbert.net/) (SBERT)
- [MTEB leaderboard](https://huggingface.co/spaces/mteb/leaderboard) (Hugging Face)
- [OpenAI docs: embeddings](https://platform.openai.com/docs/guides/embeddings) (OpenAI)

Previous: [Prompt Templates, Versioning and Iteration](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-management) · Next: [Similarity Metrics and ANN Indexes](https://www.internhack.in/roadmaps/tracks/ai-engineer/similarity-and-ann)

## More in Embeddings and Vector Search

- [Text Embeddings](https://www.internhack.in/roadmaps/tracks/ai-engineer/embeddings)
- [Similarity Metrics and ANN Indexes](https://www.internhack.in/roadmaps/tracks/ai-engineer/similarity-and-ann)
- [Chunking Strategies](https://www.internhack.in/roadmaps/tracks/ai-engineer/chunking)
- [pgvector: Vectors in Postgres](https://www.internhack.in/roadmaps/tracks/ai-engineer/pgvector)
- [Dedicated Vector Databases](https://www.internhack.in/roadmaps/tracks/ai-engineer/dedicated-vector-dbs)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
