Repository navigation
Python: Allow output_dimensionality above 768 in GoogleAIEmbeddingPromptExecutionSettings - #14742
Open
Qiming Bao (14H034160212) wants to merge 1 commit into
Open
Qiming Bao (14H034160212) wants to merge 1 commit into
Qiming Bao (14H034160212) wants to merge 1 commit into
Conversation
…mptExecutionSettings output_dimensionality was capped with Field(le=768), the maximum of the older text-embedding-004 model. gemini-embedding-001 and gemini-embedding-2 support output dimensions from 128 to 3072 (recommended 768, 1536 and 3072), so 1536 and 3072 were rejected before any request was sent. The supported range depends on the model, and neither the Gemini API reference nor google-genai's EmbedContentConfig defines an upper bound, so require only a positive value and leave the model-specific limit to the service. This matches VertexAIEmbeddingPromptExecutionSettings, which has no cap.
Qiming Bao (14H034160212)
temporarily deployed
to
github-app-auth
November 7, 2026 11:16 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues blocking the embedding-dimension validation change.
No open issues 🎉
What changed in this PR
Updates Google AI embedding settings to accept output dimensions above 768, supporting newer Gemini embedding models without imposing a model-specific upper limit.
Changes:
- Replaces the 768 maximum with validation requiring positive dimensions.
- Adds tests confirming accepted values reach
prepare_settings_dict()and rejecting zero and negative values.
| File | Description |
|---|---|
python/tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py |
Adds parameterized tests for accepted and invalid dimensions. |
python/semantic_kernel/connectors/ai/google/google_ai/google_ai_prompt_execution_settings.py |
Changes dimension validation from le=768 to gt=0. |
Review effort: Balanced
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
GoogleAIEmbeddingPromptExecutionSettings.output_dimensionalityis declared asField(le=768)(source). 768 was the size of the oldertext-embedding-004vectors. The current Gemini embedding models support larger outputs, so common values are rejected before any request is sent:Sources:
gemini-embedding-001andgemini-embedding-2list "Output dimension size: Flexible, supports: 128 - 3072, Recommended: 768, 1536, 3072". The guide also notes thatgemini-embedding-001embeddings need manual normalization "for dimensions other than 3072", so 3072 is the full-size output.embedContent:outputDimensionalityis an optionalinteger, "Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end." No maximum is given.google-genai(1.75.0, the version thegoogleextra resolves to):EmbedContentConfig.output_dimensionalityisOptional[int]with no bounds.Description
output_dimensionality:Field(le=768)changed toField(gt=0).I chose not to replace 768 with a 3072 cap. The limit depends on the model, so a hard-coded maximum goes stale with the next model, which is what happened to 768. Neither the API reference nor the SDK defines a global maximum, and the service already returns a clear error for unsupported sizes.
gt=0still rejects nonsensical values locally. It also matchesVertexAIEmbeddingPromptExecutionSettings.output_dimensionality(source), which has no cap.Tests added to
tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py:prepare_settings_dict();4 of the new cases fail on
main: 1536 and 3072 are rejected, and 0 and -1 are accepted.Verification (from
python/):Contribution Checklist