{"record":{"id":"d1d00504c7518b4a","repo":"apache/beam","slug":"dimension-must-be-one-of-128-256-512-or-1408","errorCode":null,"errorMessage":"dimension must be one of 128, 256, 512, or 1408","messagePattern":"dimension must be one of 128, 256, 512, or 1408","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/rag/embeddings/vertex_ai.py","lineNumber":172,"sourceCode":"    Args:\n        model_name: Name of the Vertex AI model.\n        dimension: Embedding dimension. Must be one of\n            128, 256, 512, or 1408.\n        project: GCP project ID.\n        location: GCP location.\n        credentials: Optional GCP credentials.\n        **kwargs: Additional arguments passed to\n            :class:`~apache_beam.ml.transforms.base.EmbeddingsManager`.\n    \"\"\"\n    if not vertexai:\n      raise ImportError(\n          \"vertexai is required to use \"\n          \"VertexAIImageEmbeddings. \"\n          \"Please install it with \"\n          \"`pip install google-cloud-aiplatform`\")\n\n    if dimension is not None and dimension not in (128, 256, 512, 1408):\n      raise ValueError(\"dimension must be one of \"\n                       \"128, 256, 512, or 1408\")\n\n    super().__init__(type_adapter=_create_image_adapter(), **kwargs)\n    self.model_name = model_name\n    self.dimension = dimension\n    self.project = project\n    self.location = location\n    self.credentials = credentials\n\n  def get_model_handler(self):\n    \"\"\"Returns model handler for image embedding.\"\"\"\n    return _VertexAIImageEmbeddingHandler(\n        model_name=self.model_name,\n        dimension=self.dimension,\n        project=self.project,\n        location=self.location,\n        credentials=self.credentials,\n    )","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/rag/embeddings/vertex_ai.py#L154-L190","documentation":"The Vertex AI multimodal embedding model only supports embedding dimensionality of 128, 256, 512, or 1408. If a `dimension` argument is passed to VertexAIImageEmbeddings with any other value (or an invalid type that isn't in the tuple), __init__ raises ValueError before building the model adapter.","triggerScenarios":"VertexAIImageEmbeddings(..., dimension=768) or dimension=1024, or passing dimension copied from a text-embedding config whose model uses different sizes.","commonSituations":"Reusing vector DB schemas sized for text-embedding models (768/1536); typos; copying dimension from OpenAI or other providers' configs.","solutions":["Set dimension to one of 128, 256, 512, or 1408.","Omit `dimension` entirely to use the model default (1408).","Align your BigQuery/Milvus vector column size with the chosen dimension.","Validate the config value before constructing the manager."],"exampleFix":"// before\nembedder = VertexAIImageEmbeddings(model_name='multimodalembedding@001', dimension=768)\n// after\nembedder = VertexAIImageEmbeddings(model_name='multimodalembedding@001', dimension=1408)","handlingStrategy":"validation","validationCode":"VALID_DIMS = (128, 256, 512, 1408)\nassert dimension is None or dimension in VALID_DIMS, f'dimension must be one of {VALID_DIMS}'","typeGuard":null,"tryCatchPattern":"try:\n    embedder = VertexAIImageEmbeddings(model_name='multimodalembedding@001', dimension=cfg.dim)\nexcept ValueError as e:\n    logging.error('Invalid embedding dimension: %s', e)\n    raise","preventionTips":["Centralize the allowed dimensions constant in config code.","Never copy `dimension` from text-embedding model configs.","Keep vector DB column sizes in sync with the chosen dimension."],"tags":["python","vertex-ai","config","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}