-
Notifications
You must be signed in to change notification settings - Fork 368
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
Dense Vector Feature as a param to a Mustache script score template #465
Comments
Hacked like this to make work. Here is the definition of the feature. Any feedback? {
"name": "vector_simularity",
"params": [
"embedding"
],
"template_language": "mustache",
"template": {
"function_score": {
"script_score": {
"script": {
"source": """
List parseArrayOfFloats(def aryOfFloats) {
def x = aryOfFloats.substring(1, aryOfFloats.length() - 1);
def z = new StringTokenizer(x, ",");
def y = new ArrayList();
while(z.hasMoreTokens()) {
y.add(Float.parseFloat((String)z.nextToken()));
}
return y;
}
return cosineSimilarity(parseArrayOfFloats(params.query_vector), 'base_name_vector') + 1.0;
""",
"params": {
"query_vector": "{{#toJson}}embedding{{/toJson}}"
}
}
}
}
}
} |
I believe that the problem is that the original query is not structured correctly. The
Note that all the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to use embeddings to compute cosine similarity. The problem I am getting is there no way to pass the embedding as a param to invoke the following feature during logging.
I got the idea to use
toJson
mustache template from another post which seems to match what I am tying to do #338I get the following error when running the query
Please note a query like the following works as expected
The text was updated successfully, but these errors were encountered: