Skip to content

Commit

Permalink
fix: update the l2_distance with a weighted sum of inner product and …
Browse files Browse the repository at this point in the history
…inverted l2 distance
  • Loading branch information
sshivaditya committed Oct 10, 2024
1 parent a875107 commit 03f0110
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions supabase/migrations/20241008175109_function_issue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ BEGIN
RETURN QUERY
SELECT id AS issue_id,
plaintext AS issue_plaintext,
1 - (l2_distance(current_quantized, embedding)) AS similarity
((0.5 * inner_product(current_quantized, embedding)) + 0.5 * (1 / (1 + l2_distance(current_quantized, embedding)))) as similarity
FROM issues
WHERE id <> current_id
AND current_repo = payload->'repository'->>'name'::text
AND current_org = payload->'repository'->'owner'->>'login'::text
AND 1 - l2_distance(current_quantized, embedding) > threshold -- Ensure similarity exceeds threshold
AND ((0.5 * inner_product(current_quantized, embedding)) + 0.5 * (1 / (1 + l2_distance(current_quantized, embedding)))) > threshold
ORDER BY similarity DESC
LIMIT top_k;
END;
Expand Down

0 comments on commit 03f0110

Please sign in to comment.