BLOGAnnounced at MongoDB.local NYC 2024: A recap of all announcements and updates — Learn more >

What are Vector Databases?

Table of contents

You’ve heard the hype about generative AI (aka artificial intelligence). Across the economy — from healthcare to finance, retail to government agencies — organizations are looking for ways to leverage it. It seems like every CEO wants to roll out applications as fast as possible.

It’s more than just hype. According to a McKinsey report, generative AI could infuse trillions into the global economy.

Central to this transformational technology is the mathematical concept of the vector. Through vectorization and the prowess of large language models (LLMs), generative AI achieves its game-changing potential. In the era of generative AI, vector embeddings lay the groundwork; vector databases amplify its impact.

What is a vector database? How does it work? What are some common use cases? And why is MongoDB Atlas Vector Search playing a significant role in the generative AI discussion?

What are vector databases?

To understand vector databases, you need to first understand the vector.

In math and physics, a vector is a quantity that has both magnitude (or size) and direction. A vector can be broken down into components. For example, in a two-dimensional space, a vector has an X (horizontal) and Y (vertical) component.

In data science and machine learning, a vector is an ordered list or sequence of numbers that represents data. A vector can represent any type of data, including unstructured data (or data without a pre-defined data model or schema) – from text to image, audio to video. A vector is usually represented as arrays or lists of numbers where each number in the list represents a specific feature or attribute of that data.

For example, imagine you have a large collection of cat photos. Each image is a piece of unstructured data. But you can represent each image as a vector by extracting features, such as the following:

  • Average color
  • Color histogram
  • Texture histogram
  • The presence or absence of ears, whiskers, and a tail

Vector embeddings (or vectorization) is the process of converting such words and other data into numbers, where each data point is represented by a vector in high-dimensional space.

A vector database — also known as a vector search database or vector similarity search engine — stores, retrieves, and searches for vectors.

Instead of rows and columns typical of relational databases, vector databases represent data as points in a multi-dimensional space. Vector databases are ideal for applications that require rapid and accurate matching of data based on similarity rather than exact values.

“Imagine a vector database as a vast warehouse and the artificial intelligence as the skilled warehouse manager. In this warehouse, every item (data) is stored in a box (vector), organized neatly on shelves in multidimensional space,” writes Mark Hinkle in The New Stack.

If you’re building generative AI applications, a vector database is tailored to efficiently process vast volumes of vectorized data, ensuring faster queries and processing speeds.

An image of vector databases featuring vector embedding and the embedding model.
How do vector databases work?

Central to the functionality of a vector database is the principle of embeddings. In essence, a vector or embedding model translates data into a consistent format: vectors.

While a vector is fundamentally an ordered set of numbers, an embedding transforms it into a representation of various data types, including text, images, and audio.

Transformations — the process of converting data from one format to another — situate vectors in multi-dimensional vector space. One of the most striking features of this spatial arrangement is that data points with similar attributes or characteristics naturally gravitate toward each other, forming clusters.

Vector embeddings are not just numerical translations; they encapsulate the deeper semantic essence and the contextual nuances of the original data. This makes them invaluable assets for a range of AI applications — from natural language processing (NLP) to sentiment analysis to text categorization.

Querying a vector database is different than querying a conventional database. Instead of hunting for precise matches between identical vectors, a vector database uses similarity search to identify vectors that reside in close proximity to the given query vector, within the multi-dimensional space. This approach not only more closely aligns with the inherent nature of the data but also offers a speed and efficiency that traditional search can't match.

Words, sentences, and even entire documents can be transformed into vectors that capture their essence. For example, a standard word embedding method is Word2Vec. With Word2Vec, words with similar meanings are represented by vectors that are close in a multi-dimensional space. The most famous example is: king – man + woman = queen. Adding the vectors associated with the words “king” and “woman” while subtracting “man” is equal to the vector associated with “queen.”

An image describing how vector database search works including pink dots, a cat, banana, etc.

Even with their intricate patterns and colors, images can be translated into vectors. For instance, in a dataset teeming with animal images, a trained convolutional neural network (CNN) would cluster all dog images close together, distinctly separate from, say, clusters of cats or birds.

By capturing the inherent data structure, and patterns within the data, vector embeddings offer semantically enriched portrayals. This richness not only facilitates a deeper understanding of the data but also expedites computations related to determining relationships and gauging similarities between different entities.

Why is vector search critical?

Vector search is critical for vector databases because of its distinct data retrieval method.

Unlike traditional databases that rely on exact matches, in a vector database, vector search operates based on similarity. This semantic understanding means that even if two pieces of data aren't identical but are contextually or semantically similar, they can be matched.

Traditional keyword searches excel when pinpointing specific terms within documents or tables. However, they fall short with unstructured data, such as videos, books, social media posts, PDFs, and audio files.

Vector search fills this gap by enabling searches within unstructured data. It doesn't just look for exact matches but identifies content based on semantic similarity, understanding the inherent relationships between search terms.

An image of a voronoi diagram describing "nearest neighbor"

The efficiency of vector search becomes evident when dealing with high-dimensional data. Vector databases are adept at handling data points that span hundreds or even thousands of dimensions. Algorithms optimized for vector search of high dimensional vectors, such as approximate nearest neighbor (ANN) search, can swiftly identify the most similar vectors in this vast space without the need to scan every vector. This efficiency translates to faster and more resource-effective searches.

From a user experience perspective, the benefits of vector search are manifold. Applications like recommendation systems or image recognition can provide results based on similarity rather than exact matches. For instance, in an e-commerce setting, showing products similar to a user's search query can enhance customer satisfaction and increase sales. As datasets expand, the scalability of vector search becomes evident. While exact match searches might become progressively slower with growing data, vector search maintains consistent query performance throughout, ensuring timely results even with vast datasets.

The flexibility offered by vector search is another notable advantage. It accommodates new data types, evolving data structures, and changing search requirements with minimal adjustments.

Moreover, flexibility is invaluable in the rapidly evolving data management landscape, especially as many of today’s AI and machine learning models, particularly those rooted in deep learning, produce data in vector form. A database that can natively search through vector data becomes indispensable for advanced applications like facial recognition or voice recognition.

An image describing vector search including unstructured data, an encoder, and vector store.
Use cases for vector databases

The global economic landscape is complex and competitive — and data remains at its core. In the past, many have called data the “new oil.” In the generative AI era, vector embeddings are the oil and vector databases have emerged as sophisticated refineries, adept at processing high-dimensional data and executing similarity searches.

For the C-suite, generative AI isn’t just a buzzword; it’s a strategy. For developers, the primary allure of vector databases is efficiency. Traditional databases might require complex query structures to fetch relevant data, especially when dealing with vast datasets. Vector databases simplify this, allowing developers to retrieve data based on similarity, reducing both the complexity of the code and the time taken for data retrieval.

A sampling of vector database use cases
An image describing vector search including unstructured data, an encoder, and vector store.

Image and video recognition: Visual content dominates our visual culture, and vector databases shine brightly in it. They are adept at sifting through vast repositories of images and videos to pinpoint those that bear a striking resemblance to a given input. This isn't just about matching pixel-by-pixel; it's about understanding the underlying patterns and features. Such capabilities are crucial for applications like facial recognition, object detection, and even copyright infringement detection in media platforms.

Natural language processing and text search: Synonyms, paraphrasing, and context can make exact text matching a daunting task. However, vector databases can discern the semantic essence of phrases or sentences, enabling them to identify matches that might not be identical in terms of wording but are contextually similar. This prowess is a game-changer for chatbots, ensuring they respond aptly to user queries. Similarly, search engines can deliver more relevant results, enhancing user experience.

Recommendation systems: Vector databases play a pivotal role in personalization. By understanding user preferences and analyzing patterns, these databases can suggest songs that resonate with a listener's taste or products that align with a shopper's preferences. It's all about gauging similarity and delivering content or products that strike a chord with the user.

Emerging applications: The horizon of vector databases is ever-expanding. In healthcare, they're aiding drug discovery by analyzing molecular structures for potential therapeutic properties. In the financial sector, vector databases are assisting in anomaly detection, spotting unusual patterns that might indicate fraudulent activities.

With the ascent of generative AI, vector databases emerge as vital enablers, assisting developers in transforming intricate AI blueprints into practical, value-driven tools.

MongoDB Atlas Vector Search: A game-changer

MongoDB Atlas Vector Search is the latest addition to the MongoDB developer data platform. It enables customers to build intelligent applications powered by semantic search and generative AI over any type of data.

Historically, development teams seeking a vector database for tasks like image or efficient similarity search faced a dilemma: Opt for a bolt-on vector database, adding another tool to the tech stack, or juggle a mix of search tools and open-source solutions. Using a full-text search for semantic capabilities often meant developers were bogged down with extensive synonym mapping. The limitations were clear: If users weren't precise in their queries, the results were far from relevant.

Such challenges meant:

  • An added system to oversee.
  • The need for specialized skill sets.
  • The mental strain of constantly updating synonym mappings.
  • A subpar user experience for imprecise queries.
  • Valuable engineering time diverted from core tasks.

Atlas Vector Search simplifies designing applications enriched by semantic search and generative AI, capable of processing a range of data types, from videos to social media content. Harnessing the robustness of MongoDB Atlas, Vector Search allows developers to craft cutting-edge, relevance-based search tools on a trusted platform with a unified query interface.

Vector Search provides MongoDB Atlas with the knowledge required to understand a query without the need to define synonyms. Even when users don’t know what they’re looking for, Vector Search is able to return relevant results based on the meaning of the query. For example, a search for “ice cream” would return “sundae,” even if the user didn't know sundaes existed.

When you use Vector Search, you’ll store vector embeddings alongside the original data and metadata in Atlas. This ensures any updates or additions to your vector data are instantly synchronized, streamlining the architecture and offering a unified developer experience.

With Vector Search, you’ll index and query data using one of the most powerful vector search algorithms: approximate k-nearest neighbors (or “k-NN,” which uses hierarchical navigable small world, or HNSW, graphs to find vector similarity).

Spiral model

You can create vastly improved search experiences that address use cases that traditional search tools can’t, including:

  • Semantic search: This allows for context-driven searches. For instance, a search for “ice cream” might yield results like “sundae” without any pre-set synonyms.
  • Enhanced recommendations: If a user searches for a lawn mower, the system might also suggest related lawn-care items.
  • Diverse media searches: Whether it's hunting for images resonating with terms like “happy families” or sifting through audio logs for specific phrases, Vector Search is up to the task.
  • Hybrid search: This combines the strengths of vector search with traditional full-text search, enriching the results.
  • Long-term memory for LLMs: This provides proprietary business data context to large language models, refining their output accuracy.

Atlas Vector Search is compatible with popular application frameworks like LlamaIndex and LangChain. It also integrates seamlessly with ecosystem partners such as Google Vertex AI, AWS, Azure, and Databricks, ensuring proprietary business data enhances the performance and accuracy of AI-powered applications.

Vector databases, with their unique approach to data storage and retrieval, are changing the way we think about databases. Their ability to perform rapid similarity searches makes them indispensable in today's data-driven world. And when combined with the power and flexibility of MongoDB Atlas, they offer a solution that's hard to beat.

Atlas Vector Search powers advanced use cases — like semantic search, image search, and similarity search — that can’t be addressed by traditional full-text search. Developers can store their vector embeddings in MongoDB, supplement their existing search functionality with machine learning models, and query them to get relevant, contextual results. Engineering leaders benefit from the peace of mind that comes with running Atlas: a fully managed, battle-tested, multi-cloud developer data platform.

Whether you're building a recommendation system, a search engine, or any other application that requires fast and accurate data matching, consider leveraging the combined power of vector databases and MongoDB. The future is vectorized, and MongoDB is here to help you navigate it.


What is MongoDB Atlas Vector Search?
MongoDB Atlas Vector Search is the latest addition to the MongoDB developer data platform. It enables customers to build intelligent applications powered by semantic search and generative AI over any type of data.
What is the approximate nearest neighbor search?
Approximate nearest neighbor search is when an algorithm is allowed to return points whose distance from the query is at most c times the distance from the query to its nearest points. In other words, the returned points can be up to c times further away from the query point than its nearest neighbor. This is useful because it allows the algorithm to find good enough neighbors quickly.
What is a vector index?
A vector index is a data structure designed to store and manage vector embeddings from a large dataset of data objects.

Get Started With MongoDB Atlas

Try Free