Created
September 22, 2021 12:13
-
-
Save jobergum/d36c7ed26cd2e44f1f1c8ffd0734c49c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"yql": "select id from vector where ([{\"targetHits\": 100, \"approximate\":true}]nearestNeighbor(doc_embedding,q1_embedding);", | |
"hits": 100 | |
"ranking.features.query(q1_embedding): [0.21,0.12,....], | |
"ranking.features.query(q2_embedding): [0.21,0.12,....], | |
"ranking.features.query(threshold): 0.01, | |
"ranking.profile": "threshold-something-else" | |
} | |
schema: | |
document vector { | |
field doc_embedding type tensor<float>(d[128]) { | |
attribute { | |
distance-metric: euclidean | |
} | |
index { | |
hnsw { | |
max-links-per-node: 16 | |
neighbors-to-explore-at-insert: 500 | |
} | |
} | |
} | |
rank-profile threshold-someting-else { | |
#Calculate L2 distance between q2_embedding and doc_embedding | |
function other_distance() { | |
expression: sqrt(sum(map(query(q2_embedding) - attribute(doc_embedding), f(x)(x * x)))) | |
} | |
first-phase { #Only targetHits from q1_embedding, vector gets exposed to first phase when using approximate | |
rank-score-drop-limit:0 | |
expression: if(other_distance() > query(threshold),-1,closeness(field,vector)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment