Embeddings and vector search
Turning text into vectors to find similar items, alone or with keywords.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Overview
An embedding model turns a piece of text into a list of numbers so that texts with similar meaning end up close together. Vector search stores those vectors and finds the nearest neighbours to a query, which powers semantic search, recommendations, deduplication and the retrieval step of RAG.
Useful knowledge here includes choosing an embedding model and dimension, picking a similarity measure, understanding approximate indexes such as HNSW and their recall trade-offs, filtering on metadata, and knowing when plain keyword search (BM25) does better, for example on product codes and names. Combining both, hybrid search, is a common default.
What you will practise
- Embed documents and queries with the same model
- Choose an index and tune its recall against speed
- Filter vector results on metadata
- Combine keyword and vector results with rank fusion
Learning paths
- RAG engineer
A RAG course for engineers who want results they can measure: embeddings, pgvector, a pipeline built in a day, golden datasets, LLM judges and tracing.
Tutorials
- Chunking strategies for RAG, tested
Compare fixed-size, heading-based and semantic chunking on the same documents and questions, measure retrieval hit rate, and pick a strategy with evidence.
- Hybrid search and reranking in Postgres
Combine Postgres full-text search and pgvector with reciprocal rank fusion in one SQL query, rerank the top results with a cross-encoder, and measure the gain.
- Embeddings and vector search, hands on
Embed documents, store them in Postgres with pgvector, index them and run similarity and hybrid search.
- RAG fundamentals: retrieval before generation
What RAG is and how retrieval-augmented generation works, when it beats long context or fine-tuning, and a minimal working pipeline in about 80 lines of Python.
Workflow recipes
- RAG pipeline in a day with Postgres and pgvector
Ingest your documents, answer with citations and measure retrieval against 20 questions written first.
Articles
- pgvector vs Pinecone, Qdrant and Weaviate
When storing embeddings in Postgres with pgvector is enough, and when a dedicated vector database such as Pinecone, Qdrant or Weaviate earns its extra cost.
Tools for this skill
9 of 13 tools tagged with this skill.
Chroma
Open-source embedding database that is quick to start locally, plus a hosted cloud.
Faiss
Meta's library for vector similarity search and clustering.
Hugging Face
Hub for models, datasets and Spaces, plus open-source ML libraries.
LanceDB
Embedded, open-source vector and multimodal database on the Lance columnar format.
LlamaIndex
Framework for document agents and retrieval over your data.
Mem0
Memory layer that extracts facts from conversations and retrieves them later.
Milvus
Open-source vector database built for large collections, from the team at Zilliz.
pgvector
Postgres extension for vector similarity search with HNSW and IVFFlat indexes.
Pinecone
Fully managed vector database with serverless indexes and built-in embedding models.
Key terms
Words you will meet while learning this, defined in the glossary.
- BM25
A classic keyword relevance function that scores documents by term frequency and rarity, adjusted for document length. Still a strong baseline.
- Cosine similarity
A measure of how similar two vectors are based on the angle between them, ranging from -1 (opposite) to 1 (same direction).
- Embedding
A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.
- Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.
- Metadata filtering
Narrowing a vector or keyword search with structured fields, such as date, language or access rights, before or during the search.
- Reciprocal rank fusion (RRF)
A way to merge ranked result lists into one by scoring each document on its positions in the lists, not their raw scores.
- Semantic search
Search that ranks results by how close their meaning is to the query rather than by shared keywords, usually by comparing embeddings.
- Vector database
A database designed to store embeddings and quickly find the nearest neighbours to a query vector, often with metadata filtering.