Abstract class extending VectorStore that defines a contract for saving
and loading vector store instances.
The SaveableVectorStore class allows vector store implementations to
persist their data and retrieve it when needed.The format for saving and
loading data is left to the implementing subclass.
Subclasses must implement the save method to handle their custom
serialization logic, while the load method enables reconstruction of a
vector store from saved data, requiring compatible embeddings through the
EmbeddingsInterface.
class SaveableVectorStoreEmbeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.
Defines the filter type used in search and delete operations. Can be an object for structured conditions or a string for simpler filtering.
Returns a string representing the type of vector store, which subclasses must implement to identify their specific vector storage type.
Method to add documents to the memory vector store. It extracts the text from each document, generates embeddings for them, and adds the resulting vectors to the store.
Method to add vectors to the memory vector store. It creates
MemoryVector instances for each vector and document pair and adds
them to the store.
Creates a VectorStoreRetriever instance with flexible configuration options.
Deletes documents from the vector store based on the specified parameters.
Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Saves the current state of the vector store to the specified directory.
This method must be implemented by subclasses to define their own serialization process for persisting vector data. The implementation determines the structure and format of the saved data.
Searches for documents similar to a text query by embedding the query and performing a similarity search on the resulting vector.
Method to perform a similarity search in the memory vector store. It
calculates the similarity between the query vector and each vector in
the store, sorts the results by similarity, and returns the top k
results along with their scores.
Searches for documents similar to a text query by embedding the query, and returns results with similarity scores.
Static method to create a FakeVectorStore instance from an array of
Document instances. It adds the documents to the store.
Static method to create a FakeVectorStore instance from an array of
texts. It creates a Document for each text and metadata pair, and
adds them to the store.
The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.
Implemented as a static method to support loading logic.
Loads the documents.
Embeddings interface for generating vector embeddings from text queries,
Defines the filter type used in search and delete operations. Can be an
Returns a string representing the type of vector store, which subclasses
Method to add documents to the memory vector store. It extracts the
Method to add vectors to the memory vector store. It creates
Creates a VectorStoreRetriever instance with flexible configuration options.
Deletes documents from the vector store based on the specified parameters.
Return documents selected using the maximal marginal relevance.
Searches for documents similar to a text query by embedding the query and
Method to perform a similarity search in the memory vector store. It
Searches for documents similar to a text query by embedding the query,
Static method to create a FakeVectorStore instance from an array of
Static method to create a FakeVectorStore instance from an array of
The name of the serializable. Override to provide an alias or
A path to the module that contains the class, eg. ["langchain", "llms"]