microsoft / microsoft/SPTAG

Cosine Similarity is implemented as a minimizer instead of a maximizer

Open
#99 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

customer raised need_triage
Dominant language
C++
Stars
5k
Forks
622
Avg merge
8h 37m
Merged PRs (30d)
5

Description

In order to find the most similar vector using cosine similarity one needs to maximize the measure, not to minimize it as SPTAG does. ( we are setting the build paramter to 'Cosine' and then do the search as we normally do)
I tried to solve this issue by using Cosine measure but instead of indexing vector v1 I indexed vector -1*v1 so instead of maximizing cos(v1,v2) we are minimizing cos(-v1, v2) but the neighborhood search returns weird numbers (cosine similarities higher than one). Is it us doing something wrong?

Thank you for your help.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported search with the build parameter set to “Cosine,” comparing normal indexing with indexing vector -1*v1. Inspect the cosine-measure path and neighborhood search results, then verify whether similarities can exceed one and determine the expected maximization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.