Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Won't Fix
-
11.8.1
Description
sql: SELECT VEC_DISTANCE_COSINE(VEC_FROMTEXT('[1,2,3]'), VEC_FROMTEXT('[0,0,0]'));
return value is 0.
static double calc_distance_cosine(float *v1, float *v2, size_t v_len) |
{
|
double dotp=0, abs1=0, abs2=0; |
for (size_t i= 0; i < v_len; i++, v1++, v2++) |
{
|
float f1= get_float(v1), f2= get_float(v2); |
abs1+= f1 * f1;
|
abs2+= f2 * f2;
|
dotp+= f1 * f2;
|
}
|
return 1 - dotp/sqrt(abs1*abs2); |
}
|
abs1 or abs2 maybe zero, so in this case,1 should be returned
Attachments
Issue Links
- relates to
-
MDEV-36317 vector search with Cosine Distance, the recall rate of the returned results is very low
-
- Open
-
This operation is undefined, you can't calculate cosine distance when either vectors is the 0 vector.