Xata is a serverless data platform, based on PostgreSQL. It provides a Python SDK for interacting with your database, and a UI for managing your data. Xata has a native vector type, which can be added to any table, and supports similarity search. LangChain inserts vectors directly to Xata, and queries it for the nearest neighbors of a given vector, so that you can use all the LangChain Embeddings integrations with Xata.This notebook guides you how to use Xata as a VectorStore.
Setup
Create a database to use as a vector store
In the Xata UI create a new database. You can name it whatever you want, in this notepad we’ll uselangchain
.
Create a table, again you can name it anything, but we will use vectors
. Add the following columns via the UI:
content
of type “Text”. This is used to store theDocument.pageContent
values.embedding
of type “Vector”. Use the dimension used by the model you plan to use. In this notebook we use OpenAI embeddings, which have 1536 dimensions.source
of type “Text”. This is used as a metadata column by this example.- any other columns you want to use as metadata. They are populated from the
Document.metadata
object. For example, if in theDocument.metadata
object you have atitle
property, you can create atitle
column in the table and it will be populated.
https://demo-uni3q8.eu-west-1.xata.sh/db/langchain
.