Vector Databases: Searching by Meaning, Not Matches
A vector database organizes data by meaning, not just exact values. Instead of finding a record by its ID, you find it by its similarity to a query. This powers AI features like Retrieval-Augmented Generation (RAG), where an LLM finds relevant documents, and recommendation engines. The main footgun is that it finds *approximate* matches, trading perfect accuracy for speed and the ability to search unstructured data.
### The mental model A traditional database is like a library's card catalog: you need the exact title or author (the key) to find a book. A vector database is like a librarian who has read every book and organized them by their conceptual meaning. You can ask for "books about lonely robots in space" and get relevant results, even if those exact words aren't in the titles.
### How it works Data like text, images, or audio is first converted into a numerical representation called an embedding or vector. This vector captures the semantic meaning of the data. The vector database stores these high-dimensional vectors. When you perform a search, your query is also converted into a vector. The database then uses an Approximate Nearest Neighbor (ANN) algorithm to rapidly find the vectors in its storage that are mathematically closest to your query vector. "Closest" means most semantically similar.
### When to use it * **Retrieval-Augmented Generation (RAG):** To find relevant documents or data chunks to feed into an LLM as context, improving the accuracy and relevance of its answers. * **Semantic Search:** Building search engines that understand user intent, not just keywords. For example, a search for "what to wear in cold weather" could return results for parkas and winter coats. * **Recommendation Engines:** Finding items (e.g., products, movies) or users with similar tastes based on their vector representations. * **Multi-modal Search:** Searching across different data types, like using a text description to find a matching image.
### When NOT to use it * **Transactional Systems:** For applications requiring ACID compliance, like financial ledgers or inventory management, stick to traditional relational databases. * **Exact-Match Lookups:** When you need to retrieve a record by a primary key with 100% accuracy and speed, a key-value store or indexed relational database is far more efficient.
### One canonical example A user asks an AI chatbot, "How does our company handle data privacy?" The user's question is converted into a vector embedding. This query vector is sent to a vector database containing embeddings of all internal policy documents. The database returns the top 3 document chunks whose vectors are closest to the query vector. These chunks are then passed to an LLM, which synthesizes them into a concise, context-aware answer for the user.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.