Module vectorstore (0.2.0)

API documentation for vectorstore module.

Classes

FLATConfig

FLATConfig(
    name: str,
    field_name: typing.Optional[str] = None,
    vector_size: int = 128,
    distance_strategy: langchain_community.vectorstores.utils.DistanceStrategy = DistanceStrategy.COSINE,
)

Configuration class for FLAT vector indexes, utilizing brute-force search.

HNSWConfig

HNSWConfig(
    name: str,
    field_name: typing.Optional[str] = None,
    vector_size: int = 128,
    distance_strategy: langchain_community.vectorstores.utils.DistanceStrategy = DistanceStrategy.COSINE,
    initial_cap: int = 10000,
    m: int = 16,
    ef_construction: int = 200,
    ef_runtime: int = 10,
)

Initializes the HNSWConfig object.

Parameters
NameDescription
name str

The unique name for the vector index, serving as an identifier within the vector store or database system.

field_name str

The name of the field in the dataset that holds the vector data to be indexed. This specifies which part of the data structure is used for indexing and searching.

vector_size int

The dimensionality of the vectors that the index will accommodate. All vectors must match this specified size.

distance_strategy DistanceStrategy

The metric used for calculating distances or similarities between vectors, influencing how search results are ranked.

initial_cap int

Specifies the initial capacity of the index in terms of the number of vectors it can hold, impacting the initial memory allocation.

m int

Determines the maximum number of outgoing edges each node in the index graph can have, directly affecting the graph's connectivity and search performance.

ef_construction int

Controls the size of the dynamic candidate list during the construction of the index, influencing the index build time and quality.

ef_runtime int

Sets the size of the dynamic candidate list during search queries, balancing between search speed and accuracy.

IndexConfig

IndexConfig(name: str, field_name: str, type: str)

Base configuration class for all types of indexes.

RedisVectorStore

RedisVectorStore(
    client: redis.client.Redis,
    index_name: str,
    embeddings: langchain_core.embeddings.embeddings.Embeddings,
    content_field: str = "page_content",
    vector_field: str = "vector",
)

Initialize a RedisVectorStore instance.

Parameters
NameDescription
client redis.Redis

The Redis client instance to be used for database operations, providing connectivity and command execution against the Redis instance.

index_name str

The name assigned to the vector index within Redis. This name is used to identify the index for operations such as searching and indexing.

embeddings Embeddings

An instance of an embedding service or model capable of generating vector embeddings from document content. This service is utilized to convert text documents into vector representations for storage and search.

content_field str, optional

The field within the Redis HASH where document content is stored. This field is read to obtain document text for embedding during indexing operations. Defaults to 'page_content', which can be overridden if document content is stored under a different field.

vector_field str, optional

The field within the Redis HASH designated for storing the vector embedding of the document. This field is used both when adding new documents to the store and when retrieving or searching documents based on their vector embeddings. Defaults to 'vector'.

VectorIndexConfig

VectorIndexConfig(
    name: str,
    field_name: str,
    type: str,
    distance_strategy: langchain_community.vectorstores.utils.DistanceStrategy,
    vector_size: int,
    data_type: str = "FLOAT32",
)

Initializes the VectorIndexConfig object.

Parameters
NameDescription
name str

The unique name for the vector index. This name is used to identify and reference the index within the vector storage system.

field_name str

The name of the field in the data structure that contains the vector data to be indexed. This specifies the target data for indexing.

type str

The type of vector index. This parameter determines the indexing algorithm or structure to be used (e.g., "FLAT", "HNSW").

distance_strategy DistanceStrategy

Enum specifying the metric used to calculate the distance or similarity between vectors. Supported strategies include COSINE, EUCLIDEAN_DISTANCE (L2), and MAX_INNER_PRODUCT (IP), influencing how search results are ranked and returned.

vector_size int

The dimensionality of the vectors that will be stored and indexed. All vectors must conform to this specified size.

data_type str, optional

The data type of the vector elements (e.g., "FLOAT32"). This specifies the precision and format of the vector data, affecting storage requirements and possibly search performance.