Add OpenAI embedding dimensions parameter#553
Open
dylothx wants to merge 1 commit into
Open
Conversation
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.
Description
Fixes #445
Adds a persistent
dimensionsparameter toOpenAIEmbeddingsandAzureOpenAIEmbeddings.This allows users to configure supported OpenAI embedding output dimensions at embedder initialization time, so retrievers that call
embed_query(query_text)automatically generate vectors with the intended size. This helps keep query embeddings aligned with Neo4j vector indexes created usingcreate_vector_index(dimensions=...).This PR intentionally keeps the change scoped to OpenAI/Azure OpenAI embedders. A broader alternative would be to make retrievers read the vector index dimension from Neo4j and automatically pass that value into the embedder. However, that would require changing or expanding the generic
Embeddercontract, since not all embedding providers support configurable dimensions, and providers that do support it may expose the setting through different API parameters. It could also introduce implicit behavior where the retriever silently changes embedder output based on index metadata.The current implementation keeps dimension selection explicit at embedder initialization time while preserving the existing retriever and base embedder interfaces. Future work could explore a provider-agnostic dimension interface, or retriever-side validation that generated query vectors match the Neo4j vector index dimensions.
Type of Change
Complexity
Complexity: Low
How Has This Been Tested?
Checklist
The following requirements should have been met (depending on the changes in the branch):