Skip to content

Add OpenAI embedding dimensions parameter#553

Open
dylothx wants to merge 1 commit into
neo4j:mainfrom
dylothx:feature/openai-embedding-dimensions
Open

Add OpenAI embedding dimensions parameter#553
dylothx wants to merge 1 commit into
neo4j:mainfrom
dylothx:feature/openai-embedding-dimensions

Conversation

@dylothx

@dylothx dylothx commented Jul 4, 2026

Copy link
Copy Markdown

Description

Fixes #445

Adds a persistent dimensions parameter to OpenAIEmbeddings and AzureOpenAIEmbeddings.

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 using create_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 Embedder contract, 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

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: Low

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed
  • CHANGELOG.md updated if appropriate

@dylothx dylothx requested a review from a team as a code owner July 4, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Embedding dimension parameter for Embeddings

1 participant