# Vector database

> A database that finds things by similar meaning instead of exact matching words.

- Level: Intermediate
- Topics: AI, Data
- URL: https://tidbit.legios.com.ar/vector-database/
- In Spanish: [Base de datos vectorial](https://tidbit.legios.com.ar/es/vector-database/)

A **vector database** stores **embeddings**: lists of numbers that an AI model produces to represent the meaning of a piece of text, an image or a sound. Things with similar meaning get similar numbers, so they end up close together, like points on a map. 'Puppy' lands near 'dog' and 'kitten', far from 'invoice'. A vector database is built to answer one question fast: which stored items are closest to this one?

That is different from a regular database search. Searching a help center for 'cannot log in' with plain keywords misses an article titled 'Resetting your password'. Searching by vectors finds it, because the meanings are close even though the words are different. To do this over millions of items without comparing against every single one, vector databases use special indexes (names like HNSW come up) that find nearly the closest matches very quickly, trading a tiny bit of precision for a lot of speed.

Vector databases became popular with large language models because they are the usual memory behind **RAG**: your documents are split into chunks, each chunk is embedded and stored, and when someone asks a question, the closest chunks are fetched and handed to the model as context. They also power semantic search, 'similar products' recommendations and duplicate detection. Some are dedicated products; others are features added to existing systems, like the `pgvector` extension for PostgreSQL.

## An analogy

A library where books are shelved by what they are about rather than by title. Walk to the shelf for the book you have in mind, and the neighbors on that shelf are the ones most similar to it, whatever their titles say.

## Keep in mind

- Stores embeddings: numbers that represent meaning.
- Finds the nearest items to a query, not exact word matches.
- Uses approximate search to stay fast with millions of items.
- The usual storage behind RAG and semantic search.

## Go deeper

- [What is a vector database? (AWS)](https://aws.amazon.com/what-is/vector-databases/)
- [Vector database on Wikipedia](https://en.wikipedia.org/wiki/Vector_database)
- [What is a vector database? (IBM)](https://www.ibm.com/think/topics/vector-database)

## Related terms

- [Embeddings](https://tidbit.legios.com.ar/embeddings/): Turning words, images or documents into lists of numbers that capture meaning.
- [Artificial intelligence](https://tidbit.legios.com.ar/artificial-intelligence/): Getting computers to do things that, until recently, only people could do.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
- [Database index](https://tidbit.legios.com.ar/database-index/): A sorted shortcut that lets a database find rows without reading the whole table.
- [RAG](https://tidbit.legios.com.ar/rag/): Let the model look things up in your documents before it answers.
