{"record":{"id":"b9b1b9e3a3c5fa07","repo":"RyanCodrai/turbovec","slug":"embedding-dim-vectors-shape-1-does-not-match-in","errorCode":null,"errorMessage":"embedding dim {vectors.shape[1]} does not match index dim {self.dimensions}","messagePattern":"embedding dim (.+?) does not match index dim (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/agno.py","lineNumber":514,"sourceCode":"            for doc in documents\n            if doc.embedding is None or len(doc.embedding) == 0\n        ]\n        if missing:\n            ids = [doc.id or \"<no id>\" for doc in missing]\n            raise ValueError(\n                f\"failed to embed {len(missing)} document(s): {ids}\"\n            )\n\n        # Batch the entire `documents` list into a single add_with_ids call.\n        # Per-document inserts would invalidate the SIMD-blocked cache\n        # between every doc.\n        vectors = np.asarray([doc.embedding for doc in documents], dtype=np.float32)\n        if vectors.ndim != 2:\n            raise ValueError(\n                f\"expected 2D embedding batch, got {vectors.ndim}D\"\n            )\n        if vectors.shape[1] != self.dimensions:\n            raise ValueError(\n                f\"embedding dim {vectors.shape[1]} does not match \"\n                f\"index dim {self.dimensions}\"\n            )\n        if not vectors.flags[\"C_CONTIGUOUS\"]:\n            vectors = np.ascontiguousarray(vectors)\n        # Cosine mode: L2-normalize outside the lock (pure computation,\n        # like the embedding step) so the kernel's raw score is true\n        # cosine similarity. Zero rows pass through unchanged.\n        if self.distance == Distance.cosine:\n            vectors = l2_normalize_rows(vectors)\n\n        # Build every side-car payload BEFORE mutating any state (pure\n        # computation, no store reads).\n        prepared = []\n        for doc in documents:\n            cleaned = doc.content.replace(\"\\x00\", \"�\") if doc.content else \"\"\n            doc_id = self._derive_doc_id(doc, content_hash, cleaned)\n            prepared.append(","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/agno.py#L496-L532","documentation":"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.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/agno.py:514 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-create the store with dimensions matching the current embedder's output size, or re-embed the documents with the original embedder.","Check that the embedder configuration (model, truncation) has not changed between index creation and this insert.","Log both vectors.shape[1] and self.dimensions to identify which side is stale before re-embedding or rebuilding."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}