Skip to content
tezvyn:
Menu

Vector Databases: Searching by Meaning, Not Matches

Source: Wikipedia: Vector databaseMediumHow cards are made

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.

Interview question

For which application would a vector database typically be the *least* appropriate choice?

  • a.A. A system that suggests similar products to online shoppers.
  • b.B. An AI chatbot needing to retrieve relevant company policies for user questions.
  • c.C. A financial system tracking precise account balances and transfers.Correct
  • d.D. A search engine that finds documents based on the conceptual meaning of a query.
Why?

The card explicitly states that vector databases are not suitable for 'Transactional Systems' requiring ACID compliance, such as financial ledgers, due to their focus on approximate matches rather than exact data integrity. The other options (recommendation engines, RAG for chatbots, and semantic search) are all listed as primary use cases for vector databases.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on database — each one lists the topics its interview covers.

See open roles