-
Notifications
You must be signed in to change notification settings - Fork 688
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
Adding KNN scorer explanation #1899
Conversation
6a64e1b
to
46cfc50
Compare
p.s. the check failures aren't related to this PR.
It's possible @Thejas-bhat is already looking into these. But, if not yet - @metonymic-smokey would you work with Thejas in determining the cause here or the need to update the unit test expectations for bytes read/written with index sections. |
f386d79
to
efaeacb
Compare
3b9f58d
to
6475b83
Compare
@abhinavdangeti pls review this PR instead. |
Sample explanation: { "value": 0.125, "message": "weight(desc:query Vector^1.000000 in one), product of:", "children": [ { "value": 0.5, "message": "queryWeight(desc:query Vector^1.000000), product of:", "children": [ { "value": 1, "message": "boost" }, { "value": 0.5, "message": "queryNorm" } ] }, { "value": 0.25, "message": "fieldWeight(desc in doc one), score of:", "children": [ { "value": 0.25, "message": "vector(field(desc:one) with similarity_metric(dot_product)=0.250000" } ] } ] }
6475b83
to
a6135c8
Compare
So in the case where we set the max score to a large float if score = 0 for euclidean distance, this is what the explanation ends up looking like:
I'm concerned about the large number present in the child message - can't truncate the first part so changed it to use scientific notation everywhere instead, just motivated by this specific case. |
} | ||
|
||
// if the query weight isn't 1, multiply | ||
if sqs.queryWeight != 1.0 && score != maxKNNScore { | ||
score = score * sqs.queryWeight | ||
if sqs.options.Explain { | ||
childExplanations := make([]*search.Explanation, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we're double allocating unnecessarily above and below, this should be within an if and else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@metonymic-smokey address this separate please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..
This PR adds a score Explanation to the KNN scorer, along with a unit test.
Also, contains a minor refactor of scoring related code.