Valkey Vector Store

Valkey is an open source (BSD) high-performance key/value datastore that supports a variety of workloads and rich datastructures including vector search.

Installation

pip install mem0ai[vector_stores]

Usage

config = {
    "vector_store": {
        "provider": "valkey",
        "config": {
            "collection_name": "test",
            "valkey_url": "valkey://localhost:6379",
            "embedding_model_dims": 1536,
            "index_type": "flat"
        }
    }
}

m = Memory.from_config(config)
messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
    {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})

Parameters

Let’s see the available parameters for the valkey config:
ParameterDescriptionDefault Value
collection_nameThe name of the collection to store the vectorsmem0
valkey_urlConnection URL for the Valkey servervalkey://localhost:6379
embedding_model_dimsDimensions of the embedding model1536
index_typeVector index algorithm (hnsw or flat)hnsw
hnsw_mNumber of bi-directional links for HNSW16
hnsw_ef_constructionSize of dynamic candidate list for HNSW200
hnsw_ef_runtimeSize of dynamic candidate list for search10
distance_metricDistance metric for vector similaritycosine