Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35005

vec_distance_cosine can return negative values

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • N/A
    • 11.7.1
    • Vector search
    • None

    Description

      vec_distance_cosine function can sometimes return negative values. Apparently it is a result of a rounding error, but still, it looks strange and probably can lead to unexpected results when used in an application.

      set @x=vec_fromtext('[94.542572,8.735560,60.050098,74.043800,90.068710,28.212160,70.854660,69.636841,35.620232,69.190628]');
      select vec_distance_cosine(@x,@x);
      

      bb-11.6-MDEV-32887-vector e19526802732b5723664b17ac026a1ea36f99dce

      MariaDB [test]> select vec_distance_cosine(@x,@x);
      +----------------------------+
      | vec_distance_cosine(@x,@x) |
      +----------------------------+
      | -0.00000011920928955078125 |
      +----------------------------+
      1 row in set (0.001 sec)
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.