RyanCodrai/turbovec · error · ValueError

embedding dim {vectors.shape[1]} does not match index dim {s

Error message

embedding dim {vectors.shape[1]} does not match index dim {self.dimensions}

What it means

Raised in TurboQuantVectorDb.insert when the embedding batch is 2D but its second dimension differs from self.dimensions — the dimension the index was created (or locked) with. It means the embedder used for these documents produces vectors of a different size than the one the store was constructed with.

Source

Thrown at turbovec-python/python/turbovec/agno.py:514

            for doc in documents
            if doc.embedding is None or len(doc.embedding) == 0
        ]
        if missing:
            ids = [doc.id or "<no id>" for doc in missing]
            raise ValueError(
                f"failed to embed {len(missing)} document(s): {ids}"
            )

        # Batch the entire `documents` list into a single add_with_ids call.
        # Per-document inserts would invalidate the SIMD-blocked cache
        # between every doc.
        vectors = np.asarray([doc.embedding for doc in documents], dtype=np.float32)
        if vectors.ndim != 2:
            raise ValueError(
                f"expected 2D embedding batch, got {vectors.ndim}D"
            )
        if vectors.shape[1] != self.dimensions:
            raise ValueError(
                f"embedding dim {vectors.shape[1]} does not match "
                f"index dim {self.dimensions}"
            )
        if not vectors.flags["C_CONTIGUOUS"]:
            vectors = np.ascontiguousarray(vectors)
        # Cosine mode: L2-normalize outside the lock (pure computation,
        # like the embedding step) so the kernel's raw score is true
        # cosine similarity. Zero rows pass through unchanged.
        if self.distance == Distance.cosine:
            vectors = l2_normalize_rows(vectors)

        # Build every side-car payload BEFORE mutating any state (pure
        # computation, no store reads).
        prepared = []
        for doc in documents:
            cleaned = doc.content.replace("\x00", "�") if doc.content else ""
            doc_id = self._derive_doc_id(doc, content_hash, cleaned)
            prepared.append(

View on GitHub (pinned to ccab9f325e)

Solutions

  1. Re-create the store with dimensions matching the current embedder's output size, or re-embed the documents with the original embedder.
  2. Check that the embedder configuration (model, truncation) has not changed between index creation and this insert.
  3. Log both vectors.shape[1] and self.dimensions to identify which side is stale before re-embedding or rebuilding.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at turbovec-python/python/turbovec/agno.py:514 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of RyanCodrai/turbovec@ccab9f325e (2026-09-06). Data as JSON: /api/errors/b9b1b9e3a3c5fa07. Report an issue: GitHub.