Improved precision for cosine distance [skip ci]

This commit is contained in:
Andrew Kane
2024-09-23 18:50:10 -07:00
parent 0a2803130f
commit 22efa8ec22
4 changed files with 6 additions and 10 deletions

View File

@@ -159,6 +159,9 @@ HnswOptionalProcInfo(Relation index, uint16 procnum)
Datum
HnswNormValue(const HnswTypeInfo * typeInfo, Oid collation, Datum value)
{
if (!typeInfo->normalize)
return value;
return DirectFunctionCall1Coll(typeInfo->normalize, collation, value);
}
@@ -1382,7 +1385,8 @@ hnsw_minivec_support(PG_FUNCTION_ARGS)
{
static const HnswTypeInfo typeInfo = {
.maxDimensions = HNSW_MAX_DIM * 4,
.normalize = minivec_l2_normalize,
/* Do not normalize to maximize precision */
.normalize = NULL,
.checkValue = NULL
};