{"record":{"id":"ca5886e27e7a8d46","repo":"apache/beam","slug":"dimension-argument-must-be-one-of-128-256-512-or-1408","errorCode":null,"errorMessage":"dimension argument must be one of 128, 256, 512, or 1408","messagePattern":"dimension argument must be one of 128, 256, 512, or 1408","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/transforms/embeddings/vertex_ai.py","lineNumber":282,"sourceCode":"    for use.\n\n    Args:\n      model_name: The name of the Vertex AI Multi-Modal Embedding model.\n      columns: The columns containing the image to be embedded.\n      dimension: The length of the embedding vector to generate. Must be one of\n        128, 256, 512, or 1408. If not set, Vertex AI's default value is 1408.\n      project: The default GCP project for API calls.\n      location: The default location for API calls.\n      credentials: Custom credentials for API calls.\n        Defaults to environment credentials.\n    \"\"\"\n    self.model_name = model_name\n    self.project = project\n    self.location = location\n    self.credentials = credentials\n    self.kwargs = kwargs\n    if dimension is not None and dimension not in (128, 256, 512, 1408):\n      raise ValueError(\n          \"dimension argument must be one of 128, 256, 512, or 1408\")\n    self.dimension = dimension\n    super().__init__(columns=columns, **kwargs)\n\n  def get_model_handler(self) -> ModelHandler:\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        **self.kwargs)\n\n  def get_ptransform_for_processing(self, **kwargs) -> beam.PTransform:\n    return RunInference(\n        model_handler=_ImageEmbeddingHandler(self),\n        inference_args=self.inference_args)\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/transforms/embeddings/vertex_ai.py#L264-L300","documentation":"VertexAIImageEmbeddings only supports the fixed output dimensions offered by the Vertex multimodal embedding model: 128, 256, 512, or 1408. Passing any other dimension (when not None) raises ValueError at construction.","triggerScenarios":"VertexAIImageEmbeddings(columns=..., dimension=768) or any dimension outside {128, 256, 512, 1408}.","commonSituations":"Reusing a dimension value chosen for another embedding model (e.g. 768 for BERT-style models) when switching to Vertex AI image embeddings.","solutions":["Set dimension to one of 128, 256, 512, or 1408.","Pass dimension=None to use the model default (1408).","Check the model version docs; older multimodal models may only support 1408."],"exampleFix":"// before\nhandler = VertexAIImageEmbeddings(columns=['image'], dimension=768)\n// after\nhandler = VertexAIImageEmbeddings(columns=['image'], dimension=1408)","handlingStrategy":"validation","validationCode":"if dimension is not None and dimension not in (128, 256, 512, 1408):\n    raise ValueError('dimension must be one of 128, 256, 512, 1408')","typeGuard":null,"tryCatchPattern":"try:\n    handler = VertexAIImageEmbeddings(columns=['image'], dimension=dim)\nexcept ValueError as e:\n    if 'dimension' in str(e):\n        handler = VertexAIImageEmbeddings(columns=['image'], dimension=None)","preventionTips":["Use dimension=None unless reduced dims are required","Keep allowed dims in a shared constant"],"tags":["python","vertex-ai","embeddings","validation"],"backgroundTag":"invalid-argument-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"}