mem0ai/mem0 · error · ValueError

embedding_model_dims must be provided either during initiali

Error message

embedding_model_dims must be provided either during initialization or when creating collection

What it means

Raised in Supabase.create_col when the effective dimension is falsy: `dims = embedding_model_dims or self.embedding_model_dims` evaluates to None/0. A pgvector collection via vecs needs an explicit vector dimension to build its index, so mem0 refuses to create one with unknown dims. Note that because `or` is used, a dims value of 0 is also treated as missing.

Source

Thrown at mem0/vector_stores/supabase.py:85

            # For single filter, keep the simple format
            key, value = next(iter(filters.items()))
            return {key: {"$eq": value}}

        # For multiple filters, use $and clause
        return {"$and": [{key: {"$eq": value}} for key, value in filters.items()]}

    def create_col(self, embedding_model_dims: Optional[int] = None) -> None:
        """
        Create a new collection with vector support.
        Will also initialize vector search index.

        Args:
            embedding_model_dims (int, optional): Dimension of the embedding vector.
                If not provided, uses the dimension specified in initialization.
        """
        dims = embedding_model_dims or self.embedding_model_dims
        if not dims:
            raise ValueError(
                "embedding_model_dims must be provided either during initialization or when creating collection"
            )

        logger.info(f"Creating new collection: {self.collection_name}")
        try:
            self.collection = self.db.get_or_create_collection(name=self.collection_name, dimension=dims)
            self.collection.create_index(method=self.index_method.value, measure=self.index_measure.value)
            logger.info(f"Successfully created collection {self.collection_name} with dimension {dims}")
        except Exception as e:
            logger.error(f"Failed to create collection: {str(e)}")
            raise

    def insert(
        self, vectors: List[List[float]], payloads: Optional[List[dict]] = None, ids: Optional[List[str]] = None
    ):
        """
        Insert vectors into the collection.

View on GitHub (pinned to 001c235229)

Solutions

  1. Add embedding_model_dims to the vector store config matching your embedder: `"config": {"collection_name": "mem", "embedding_model_dims": 1536}`.
  2. Or pass it per call: `store.create_col(embedding_model_dims=1536)`.
  3. If you use a custom embedder, set dims to its actual output width — mismatched dims fail later at insert time with a pgvector dimension error.

Example fix

# before
memory = Memory.from_config({
    "vector_store": {"provider": "supabase", "config": {"collection_name": "mem"}}
})
store.create_col()  # ValueError

# after
memory = Memory.from_config({
    "embedder": {"provider": "openai", "config": {"model": "text-embedding-3-small"}},
    "vector_store": {
        "provider": "supabase",
        "config": {"collection_name": "mem", "embedding_model_dims": 1536},
    },
})
Defensive patterns

Strategy: validation

Validate before calling

EMBEDDER_DIMS = {"text-embedding-3-small": 1536, "text-embedding-3-large": 3072}
model = "text-embedding-3-small"
dims = EMBEDDER_DIMS.get(model)
assert dims, f"Unknown dims for embedder {model}; set vector_store.config.embedding_model_dims explicitly"

Try / catch

try:
    store.create_col()
except ValueError as e:
    if "embedding_model_dims" in str(e):
        store.create_col(embedding_model_dims=1536)  # supply explicitly and retry
    else:
        raise

Prevention

When it happens

Trigger: Constructing the Supabase store without embedding_model_dims in config and then calling create_col() with no argument; passing embedding_model_dims=0; a config dict where the embedding provider section is absent so mem0 never propagates dims into the vector store config.

Common situations: Minimal vector_store config that relies on defaults which don't exist for dims; swapping embedding providers (e.g. 1536-dim OpenAI to a custom model) without updating the dims; copy-paste config examples that omit the field.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/507f4538753b6b31. Report an issue: GitHub.