Skip to main content
YDB is a versatile open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions. It accommodates transactional (OLTP), analytical (OLAP), and streaming workloads simultaneously.
This notebook shows how to use functionality related to the YDB vector store.

Setup

First, set up a local YDB with Docker:
You’ll need to install langchain-ydb to use this integration

Credentials

There are no credentials for this notebook, just make sure you have installed the packages as shown above. If you want to get best in-class automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Initialization

Manage vector store

Once you have created your vector store, you can interact with it by adding and deleting different items.

Add items to vector store

Prepare documents to work with:
You can add items to your vector store by using the add_documents function.

Delete items from vector store

You can delete items from your vector store by ID using the delete function.

Query vector store

Once your vector store has been created and relevant documents have been added, you will likely want to query it during the execution of your chain or agent.

Query directly

A simple similarity search can be performed as follows:

Similarity search with score

You can also perform a search with a score:

Filtering

You can search with filters as described below:

Query by turning into retriever

You can also transform the vector store into a retriever for easier usage in your chains. Here’s how to transform your vector store into a retriever and then invoke the retriever with a simple query and filter.

Usage for retrieval-augmented generation

For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections: