- A user sends a natural language query (e.g., “hello”) to an assistant such as ChatGPT or Claude.
- The query text is converted into a numeric vector (an embedding) by an embedding model.
- That query embedding is compared against a persisted index of document embeddings in a vector database (or other retrieval store).
- The system retrieves the closest matching documents or passages and passes them as context to the language model.
- The model combines the retrieved context with its reasoning to generate the final response shown to the user.
- Typically, documents and long-lived content are pre-embedded and stored; queries are embedded at request time.
- Retrieval quality depends on the embedding model, index structure (ANN, exact), and similarity metric (cosine similarity, dot product).

- Embedding model: a neural network that maps natural language (or other modalities) into numeric vectors. This can be a dedicated embedding model or an embedding endpoint provided by a larger LLM.
- Vector database / index: persists embeddings and supports fast nearest-neighbor search (ANN indexes like HNSW, IVFPQ, IVF+PQ, or in-memory FAISS).
- Query-time workflow: embed the incoming text, query the vector index for nearest neighbors, and return the retrieved content to the model as additional context.
- Monitoring and lifecycle: some systems also embed model outputs for analytics, conversational memory, or to detect drift; plan for privacy, retention, and reindexing strategies.
- “The cat sleeps” → [0.23, −0.45, …]
- “A feline resting” → [0.25, −0.44, …]

| Model Type | Typical Use Case | Example applications |
|---|---|---|
| Text embeddings | Semantic search, RAG (retrieval-augmented generation), clustering, summarization | Document search, FAQ matching, conversational memory |
| Image / video embeddings | Visual similarity, image retrieval, clustering of visual assets | Reverse image search, deduplication, visual recommendations |
| Audio embeddings | Speaker identification, semantic search across audio, clustering | Podcast search, keyword spotting, speaker diarization |
- Match modality: use a text model for text, an image model for images, and so on.
- Precision vs. cost: larger embeddings or higher-dimensional vectors can increase retrieval fidelity but also storage and compute costs.
- Indexing strategy: ANN indexes (HNSW, IVF) balance search speed and accuracy for large corpora; FAISS and Milvus are common choices.
- Metric: cosine similarity and dot product are most common for text embeddings—pick the metric your embedding model was trained with.
- Pre-embed static content to reduce query latency.
- Normalize vectors (L2 normalization) when using cosine similarity if required by your index.
- Periodically re-embed or reindex when your embedding model changes or when the corpus evolves.
- Monitor recall and precision of retrieved results; use relevance feedback to improve prompts or embeddings.
Embeddings are numeric representations of meaning. When designing systems, choose an embedding model aligned to your data modality (text, image, audio), plan for storage and indexing costs, and implement a reindexing strategy to handle model updates and data drift.
- Vector databases and similarity search (overview)
- FAISS: https://github.com/facebookresearch/faiss
- Milvus: https://milvus.io/
- Pinecone: https://www.pinecone.io/
- Annoy: https://github.com/spotify/annoy