-
Notifications
You must be signed in to change notification settings - Fork 694
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
[FEATURE] DX: Add dimension() in EmbeddingModel #1080
Comments
HI @Martin7-1 thank you, this is long due! A few thoughts:
|
|
We can add a mapping (model->dimensions) and a conditional logic in the
For me it is more natural to say "dimensions" as in "How many dimensions does this embedding vector have?". Sadly, the naming is inconsistent between providers. But we have much more "dimension" than "dimensions" in our codebase already, so I guess it makes more sense to use "dimension" for new code and migrate all "dimansions" to "dimension". |
I think it's ok! Another question is that when we do "test" embedding, there are duplicate code(check whether cache -> do embedding -> cache to a variable -> return). If we do not abstract the logic, it seems that there are duplicate variable in all Currently I want to implement by a abstract class, having a variable named /**
* An Embedding Model which contains
*/
public abstract class AbstractEmbeddingModel implements EmbeddingModel {
/**
* embedding model dimension
*/
protected Integer dimension;
/**
* A map contains known model name and its dimension
*
* @return A map, key is the common represented model name, value is its dimension
*/
protected abstract Map<String, Integer> dimensionMap();
/**
* Get embedding model's name
*
* @return embedding model's name
*/
protected abstract String modelName();
@Override
public int dimension() {
if (dimension != null) {
return dimension;
}
return dimensionMap().compute(modelName(), (key, value) -> {
this.dimension = Optional.ofNullable(value).orElse(embed("test").content().dimension());
return dimension;
});
}
} And then all specific
OK. I will take a look when I implement. |
Is your feature request related to a problem? Please describe.
As describe in Redis embedding store spring boot starter. Embedding model should have
dimension()
method to enableEmbeddingStore
to have a default value.Describe the solution you'd like
In
EmbeddingModel
, will add method like below:Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: