Vector database

APPLIES TO: NoSQL MongoDB vCore PostgreSQL

You have likely considered augmenting your applications with large language models (LLMs) and vector databases that can access your own data through retrieval-augmented generation (RAG). This approach allows you to

  • Generate contextually relevant and accurate responses to user prompts from AI models
  • Overcome ChatGPT, GPT-3.5, or GPT-4’s token limits
  • Reduce the costs from frequent fine-tuning on updated data

Some RAG implementation tutorials demonstrate integrating vector databases that are distinct from traditional relational and non-relational databases. Instead of adding a separate vector database to your existing tech stack, you can achieve the same outcome using the vector database extensions for Azure Cosmos DB when working with multi-modal data. By doing so, you can keep your vector embeddings and original data together to achieve data consistency, scale, and performance while avoiding the extra cost of moving data to a separate vector database.

Here is how:

Description
Azure Cosmos DB for Mongo DB vCore Store your application data and vector embeddings together in a single MongoDB-compatible service featuring native support for vector search.
Azure Cosmos DB for PostgreSQL Store your data and vectors together in a scalable PostgreSQL offering with native support for vector search.
Azure Cosmos DB for NoSQL with Azure AI Search Augment your Azure Cosmos DB data with semantic and vector search capabilities of Azure AI Search.

What does a vector database do?

The vector search feature in a vector database enables retrieval-augmented generation to harness LLMs and custom data or domain-specific information. This process involves extracting pertinent information from a custom data source and integrating it into the model request through prompt engineering.

A robust mechanism is necessary to identify the most relevant data from the custom source that can be passed to the LLM. Our vector search features convert the data in your database into embeddings and store them as vectors for future use, thus capturing the semantic meaning of the text and going beyond mere keywords to comprehend the context. Moreover, this mechanism allows you to optimize for the LLM’s limit on the number of tokens per request.

Prior to sending a request to the LLM, the user input/query/request is also transformed into an embedding, and vector search techniques are employed to locate the most similar embeddings within the database. This technique enables the identification of the most relevant data records in the database. These retrieved records are then supplied as input to the LLM request using prompt engineering.

Here are multiple ways to implement RAG on your data by using our vector database functionalities.

Implement vector database functionalities using our API for MongoDB vCore

Use the native vector search feature in Azure Cosmos DB for MongoDB vCore, which offers an efficient way to store, index, and search high-dimensional vector data directly alongside other application data. This approach removes the necessity of migrating your data to costlier alternative vector databases and provides a seamless integration of your AI-driven applications.

Vector database implementation code samples

Implement vector database functionalities using our API for PostgreSQL

Use the native vector search feature in Azure Cosmos DB for PostgreSQL, which offers an efficient way to store, index, and search high-dimensional vector data directly alongside other application data. This approach removes the necessity of migrating your data to costlier alternative vector databases and provides a seamless integration of your AI-driven applications.

Vector database implementation code samples

Implement RAG patterns with Azure Cosmos DB for NoSQL and Azure AI Search. This approach enables powerful integration of your data residing in the NoSQL API into your AI-oriented applications. Azure AI Search empowers you to efficiently index and query high-dimensional vector data, thereby meeting your vector database needs.

Vector database implementation code samples