Collection is configured without multiple named vectors, but received named vectors

I’m running into an issue with multi-vector setup and could use some help. I’m trying to implement a LongTermMemory class that stores objects with separate text_embedding and image_embedding vectors. These are external embeddings. I keep getting a 422 error:

weaviate.exceptions.UnexpectedStatusCodeError: Object was not added! Unexpected status code: 422, with response body: {'error': [{'message': 'invalid object: collection MemoryEvent is configured without multiple named vectors, but received named vectors: map[image_embedding:[...] text_embedding:[...]]'}]}.
from weaviate.classes.config import Property, DataType, Configure

def _initialize_schema(self):
    """Initializes the schema."""
    if not self.client.collections.exists(self.class_name):
        if Config.USE_SEPARATE_EMBEDDINGS_FOR_RETRIEVAL:
            # Multi-vector configuration
            self.client.collections.create(
                name=self.class_name,
                vectorizer_config=[
                    Configure.NamedVectors.none(name="text_embedding", vector_index_config=Configure.VectorIndex.hnsw()),
                    Configure.NamedVectors.none(name="image_embedding", vector_index_config=Configure.VectorIndex.hnsw())
                ],
                properties=[
                    Property(name="metadata", data_type=DataType.TEXT),
                    Property(name="importance", data_type=DataType.NUMBER),
                    Property(name="timestamp", data_type=DataType.DATE),
                    Property(name="last_accessed", data_type=DataType.DATE),
                    Property(name="category", data_type=DataType.TEXT,
                            description="safety_critical/routine"),
                    Property(name="access_count", data_type=DataType.NUMBER)
                ]
            )

        else:
            # Single-vector configuration
            self.client.collections.create(
                name=self.class_name,
                vectorizer_config=Configure.Vectorizer.none(),
                properties=[
                    Property(name="metadata", data_type=DataType.TEXT),
                    Property(name="importance", data_type=DataType.NUMBER),
                    Property(name="timestamp", data_type=DataType.DATE),
                    Property(name="last_accessed", data_type=DataType.DATE),
                    Property(name="category", data_type=DataType.TEXT,
                            description="safety_critical/routine"),
                    Property(name="access_count", data_type=DataType.NUMBER)
                ]
            )
Here is how I add events:
def add(self, embedding, metadata, initial_importance=0.7):
    """
    Stores an event.
    """
    metadata_str = json.dumps(metadata)
    collection = self.client.collections.get(self.class_name)
    
    uuid = metadata.get("image_path", "").split("/")[-1].split(".")[0] or None
    
    if Config.USE_SEPARATE_EMBEDDINGS_FOR_RETRIEVAL:
        vectors = {
            "text_embedding": metadata.get("embeddings", {}).get("text_embedding"),
            "image_embedding": metadata.get("embeddings", {}).get("image_embedding")
        }
    else:
        vectors = embedding

    collection.data.insert(
        properties={
            "metadata": metadata_str,
            "importance": initial_importance,
            "timestamp": datetime.now().astimezone().isoformat(),
            "last_accessed": datetime.now().astimezone().isoformat(),
            "category": self._determine_category(metadata_str),
            "access_count": 0
        },
        vector=vectors,
        uuid=uuid
    )

I have followed these documentations but I still cannot figure out the problem. Btw, I already delete the collection before running my agent. Also, my single vector setup works perfectly. I’m using Weaviate v4.11. Thank you!

Hi @exsvn !

Welcome to our community :hugs:

I was not able to reproduce this.

Here is a MRE:

from weaviate.classes.config import Configure, DataType, Property
client.collections.delete(name="Test")
client.collections.create(
    name="Test",
    vectorizer_config=[
        Configure.NamedVectors.none(name="text_embedding", vector_index_config=Configure.VectorIndex.hnsw()),
        Configure.NamedVectors.none(name="image_embedding", vector_index_config=Configure.VectorIndex.hnsw())
    ],
    properties=[
        Property(name="metadata", data_type=DataType.TEXT),
        Property(name="importance", data_type=DataType.NUMBER),
        Property(name="timestamp", data_type=DataType.DATE),
        Property(name="last_accessed", data_type=DataType.DATE),
        Property(name="category", data_type=DataType.TEXT,
                description="safety_critical/routine"),
        Property(name="access_count", data_type=DataType.NUMBER)
    ]
)
collection = client.collections.get("Test")
collection.data.insert(
    {"metadata": "new Object"},
    vector={
        "text_embedding": [0.1, 0.2, 0.3],
        "image_embedding": [0.4, 0.5, 0.6, 0.4,]
    }
)

Considering the error message, it seems you are trying to pass a multivector to your a single vector collection.

This will result in the same error message:

from weaviate.classes.config import Configure, DataType, Property
client.collections.delete(name="Test")
client.collections.create(
    name="Test",
    vectorizer_config=Configure.Vectorizer.none(),
    properties=[
        Property(name="metadata", data_type=DataType.TEXT),
        Property(name="importance", data_type=DataType.NUMBER),
        Property(name="timestamp", data_type=DataType.DATE),
        Property(name="last_accessed", data_type=DataType.DATE),
        Property(name="category", data_type=DataType.TEXT,
                description="safety_critical/routine"),
        Property(name="access_count", data_type=DataType.NUMBER)
    ]
)
collection = client.collections.get("Test")
collection.data.insert(
    {"metadata": "new Object"},
    vector={
        "text_embedding": [0.1, 0.2, 0.3],
        "image_embedding": [0.4, 0.5, 0.6, 0.4,]
    }
)

Output:
UnexpectedStatusCodeError: Object was not added! Unexpected status code: 422, with response body: {'error': [{'message': 'invalid object: collection Test is configured without multiple named vectors, but received named vectors: map[image_embedding:[0.4 0.5 0.6 0.4] text_embedding:[0.1 0.2 0.3]]'}]}.

Let me know if that helps!

THanks!

Thanks for the reply! The flag USE_SEPARATE_EMBEDDINGS_FOR_RETRIEVAL = True and I believe I’m creating a multi-vector schema correctly with named vectors (text_embedding and image_embedding). Here is the schema collection:

<weaviate.Collection config={
  "name": "MemoryEvent",
  "description": null,
  "generative_config": null,
  "inverted_index_config": {
    "bm25": {
      "b": 0.75,
      "k1": 1.2
    },
    "cleanup_interval_seconds": 60,
    "index_null_state": false,
    "index_property_length": false,
    "index_timestamps": false,
    "stopwords": {
      "preset": "en",
      "additions": null,
      "removals": null
    }
  },
  "multi_tenancy_config": {
    "enabled": false,
    "auto_tenant_creation": false,
    "auto_tenant_activation": false
  },
  "properties": [....some properties....],
  "references": [],
  "replication_config": {
    "factor": 1,
    "async_enabled": false,
    "deletion_strategy": "NoAutomatedResolution"
  },
  "reranker_config": null,
  "sharding_config": {
    "virtual_per_physical": 128,
    "desired_count": 1,
    "actual_count": 1,
    "desired_virtual_count": 128,
    "actual_virtual_count": 128,
    "key": "_id",
    "strategy": "hash",
    "function": "murmur3"
  },
  "vector_index_config": null,
  "vector_index_type": null,
  "vectorizer_config": null,
  "vectorizer": null,
  "vector_config": {
    "image_embedding": {
      "vectorizer": {
        "vectorizer": "none",
        "model": {},
        "source_properties": null
      },
      "vector_index_config": {
        "multi_vector": null,
        "quantizer": null,
        "cleanup_interval_seconds": 300,
        "distance_metric": "cosine",
        "dynamic_ef_min": 100,
        "dynamic_ef_max": 500,
        "dynamic_ef_factor": 8,
        "ef": -1,
        "ef_construction": 128,
        "filter_strategy": "sweeping",
        "flat_search_cutoff": 40000,
        "max_connections": 32,
        "skip": false,
        "vector_cache_max_objects": 1000000000000
      }
    },
    "text_embedding": {
      "vectorizer": {
        "vectorizer": "none",
        "model": {},
        "source_properties": null
      },
      "vector_index_config": {
        "multi_vector": null,
        "quantizer": null,
        "cleanup_interval_seconds": 300,
        "distance_metric": "cosine",
        "dynamic_ef_min": 100,
        "dynamic_ef_max": 500,
        "dynamic_ef_factor": 8,
        "ef": -1,
        "ef_construction": 128,
        "filter_strategy": "sweeping",
        "flat_search_cutoff": 40000,
        "max_connections": 32,
        "skip": false,
        "vector_cache_max_objects": 1000000000000
      }
    }
  }
}>

Could you please confirm that this is a correct multi-vector configuration? Thank you!