Skip to content

Add dimensions parameter support for embeddings endpoint (Matryoshka) #4542

Description

@daniele-arosio

The /v3/embeddings endpoint currently doesn't support the dimensions parameter from the OpenAI API.

Many modern embedding models (like ibm-granite/granite-embedding-311m-multilingual-r2, nomic-embed-text, text-embedding-3-small) support Matryoshka Representation Learning, which allows truncating embeddings to smaller dimensions without retraining.

Request

Add support for the dimensions parameter in EmbeddingsCalculatorOV to truncate and re-normalize the output embeddings.

Example request

{
  "model": "my-embedding-model",
  "input": "Hello world",
  "dimensions": 256
}

Expected behavior

Return embeddings truncated to 256 dimensions (instead of full 768), re-normalized.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions