{"record":{"id":"277fa3eff24239b5","repo":"microsoft/semantic-kernel","slug":"dimensionality-of-self-embedding-dim-exceeds-th","errorCode":null,"errorMessage":"Dimensionality of {self._embedding_dim} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.","messagePattern":"Dimensionality of (.+?) exceeds the maximum allowed value of (.+?)\\.","errorType":"validation","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/astradb/astradb_memory_store.py","lineNumber":82,"sourceCode":"        \"\"\"\n        try:\n            astradb_settings = AstraDBSettings(\n                app_token=astra_application_token,\n                db_id=astra_id,\n                region=astra_region,\n                keyspace=keyspace_name,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as ex:\n            raise MemoryConnectorInitializationError(\"Failed to create AstraDB settings.\", ex) from ex\n\n        self._embedding_dim = embedding_dim\n        self._similarity = similarity\n        self._session = session\n\n        if self._embedding_dim > MAX_DIMENSIONALITY:\n            raise MemoryConnectorInitializationError(\n                f\"Dimensionality of {self._embedding_dim} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.\"\n            )\n\n        self._client = AstraClient(\n            astra_id=astradb_settings.db_id,\n            astra_region=astradb_settings.region,\n            astra_application_token=(\n                astradb_settings.app_token.get_secret_value() if astradb_settings.app_token else None\n            ),\n            keyspace_name=astradb_settings.keyspace,\n            embedding_dim=embedding_dim,\n            similarity_function=similarity,\n            session=self._session,\n        )\n\n    async def get_collections(self) -> list[str]:\n        \"\"\"Gets the list of collections.\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/astradb/astradb_memory_store.py#L64-L100","documentation":"Constructor guard in `AstraDBMemoryStore.__init__`: after settings are built, if the configured `embedding_dim` exceeds `MAX_DIMENSIONALITY` (20000, defined in the same module) a `MemoryConnectorInitializationError` is raised. Astra DB cannot store vectors above this dimensionality, so the store refuses to initialize.","triggerScenarios":"Passing an `embedding_dim` > 20000 to the `AstraDBMemoryStore` constructor, typically driven by the embedding model's output size. This is a hard cap enforced before any client/network interaction.","commonSituations":"Using a very-high-dimensional embedding model; accidentally passing the model parameter count or token count instead of the embedding dimension; misconfigured dimension sourced from config; a future model whose native dim exceeds 20000.","solutions":["Use an embedding model whose output dimension is <= 20000 (e.g. switch to a model that supports Matryoshka/shorter dims).","Correct the `embedding_dim` value to the model's actual vector size.","If you genuinely need higher dims, choose a different vector store backend without this cap."],"exampleFix":"// before\nstore = AstraDBMemoryStore(..., embedding_dim=32768)  # > MAX_DIMENSIONALITY(20000)\n\n// after\nstore = AstraDBMemoryStore(..., embedding_dim=3072)  # within Astra limit","handlingStrategy":"validation","validationCode":"MAX_DIMENSIONALITY = 20000  # AstraDB cap in SK\n\ndef valid_astra_dim(d: int) -> bool:\n    return isinstance(d, int) and 0 < d <= MAX_DIMENSIONALITY\n\n# assert valid_astra_dim(embedding_dim) before constructing the store","typeGuard":"def is_valid_embedding_dim(d) -> bool:\n    return isinstance(d, int) and 1 <= d <= 20000","tryCatchPattern":"from semantic_kernel.exceptions import MemoryConnectorInitializationError\ntry:\n    store = AstraDBMemoryStore(..., embedding_dim=dim)\nexcept MemoryConnectorInitializationError as e:\n    if \"exceeds the maximum\" in str(e):\n        dim = choose_smaller_dim_model()\n    raise","preventionTips":["Read the embedding model's documented output dimension and assert it is <= 20000 before use with Astra.","Keep the dimension value in a single config source to avoid divergence.","Consider Matryoshka-capable models to reduce dimensionality when needed."],"tags":["astra-db","vector-dimension","validation","semantic-kernel","config"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}