Skip to content

[ML] Add support for dimensions in google vertex ai request #132689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jonathan-buttner
Copy link
Contributor

@jonathan-buttner jonathan-buttner commented Aug 11, 2025

This PR adds support for passing the dimensions field through to the request to send to google vertex ai. We had included the field in the service settings but didn't send it in the request.

The dimensions field maps to outputDimensionality https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api

Testing

PUT _inference/text_embedding/test
{
    "service": "googlevertexai",
    "service_settings": {
        "service_account_json": "<service_account>",
        "model_id": "gemini-embedding-001",
        "location": "us-central1",
        "project_id": "elastic-ml",
        "dimensions": 10
    }
}

Generate embeddings

POST _inference/text_embedding/test
{
    "input": ["The food was delicious"]
}

Response

{
    "text_embedding": [
        {
            "embedding": [
                0.0038749145,
                -0.0017926422,
                0.00781796,
                -0.06123169,
                -0.0026226782,
                -0.012737362,
                0.016699702,
                -0.016461374,
                -0.007187545,
                0.016607152
            ]
        }
    ]
}

@jonathan-buttner jonathan-buttner added >enhancement :ml Machine learning Team:ML Meta label for the ML team v9.2.0 labels Aug 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @jonathan-buttner, I've created a changelog YAML for you.

@@ -62,15 +66,19 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

builder.endArray();

if (taskSettings.autoTruncate() != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will allow an empty object for parameters to be sent. I verified that sending

"parameters": {}

succeeds.

@jonathan-buttner jonathan-buttner marked this pull request as ready for review August 11, 2025 21:12
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :ml Machine learning Team:ML Meta label for the ML team v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants