Skip to content
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

Support user-defined embedding dimensions in Generators #111

Open
bernard-ng opened this issue May 4, 2024 · 1 comment
Open

Support user-defined embedding dimensions in Generators #111

bernard-ng opened this issue May 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@bernard-ng
Copy link
Contributor

bernard-ng commented May 4, 2024

https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions

dimensions integer Optional
The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.

It is possible to define the dimension of an embedding via the configuration of the service used, for openai via “dimensions” in the model options. Defining the dimension of embeddings can be interesting if you want to interchange different embedding generators (eg: research, benchmarking, etc...).

Currently, the size is defined statically:

final class OpenAI3SmallEmbeddingGenerator extends AbstractOpenAIEmbeddingGenerator
{
    public function getEmbeddingLength(): int
    {
        return 1536;
    }
// ...
}

I think this function should take into account customizations made by the user, or add a function to define the embedding dimension from the generator

public function getDefaultEmbeddingLength(): int;

// default unless user-defined 
public function getEmbeddingLength(): int;

// alter config to add “dimensions” option
// $dimension should be >= default embedding length 
public function setEmbeddingLength(int $dimension): void;

What do you think?

@MaximeThoonsen MaximeThoonsen added the enhancement New feature or request label May 6, 2024
@MaximeThoonsen
Copy link
Contributor

Hey @bernard-ng ,

Yes I agree. Do you want to contribute on this one?

bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 10, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 10, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 17, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 17, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 17, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 25, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 25, 2024
bernard-ng added a commit to bernard-ng/LLPhant that referenced this issue May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants