mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
Add COSINE metric type (#23350)
Signed-off-by: Yudong Cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
4336ed8609
commit
2725d38b9e
@ -132,9 +132,17 @@ IsMetricType(const std::string_view str,
|
||||
return !strcasecmp(str.data(), metric_type.c_str());
|
||||
}
|
||||
|
||||
inline bool
|
||||
IsFloatMetricType(const knowhere::MetricType& metric_type) {
|
||||
return IsMetricType(metric_type, knowhere::metric::L2) ||
|
||||
IsMetricType(metric_type, knowhere::metric::IP) ||
|
||||
IsMetricType(metric_type, knowhere::metric::COSINE);
|
||||
}
|
||||
|
||||
inline bool
|
||||
PositivelyRelated(const knowhere::MetricType& metric_type) {
|
||||
return IsMetricType(metric_type, knowhere::metric::IP);
|
||||
return IsMetricType(metric_type, knowhere::metric::IP) ||
|
||||
IsMetricType(metric_type, knowhere::metric::COSINE);
|
||||
}
|
||||
|
||||
inline std::string
|
||||
|
||||
@ -30,9 +30,7 @@ CheckBruteForceSearchParam(const FieldMeta& field,
|
||||
AssertInfo(datatype_is_vector(data_type),
|
||||
"[BruteForceSearch] Data type isn't vector type");
|
||||
bool is_float_data_type = (data_type == DataType::VECTOR_FLOAT);
|
||||
bool is_float_metric_type =
|
||||
IsMetricType(metric_type, knowhere::metric::IP) ||
|
||||
IsMetricType(metric_type, knowhere::metric::L2);
|
||||
bool is_float_metric_type = IsFloatMetricType(metric_type);
|
||||
AssertInfo(is_float_data_type == is_float_metric_type,
|
||||
"[BruteForceSearch] Data type and metric type miss-match");
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
# or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set( KNOWHERE_VERSION 4a7b77b )
|
||||
set( KNOWHERE_VERSION 2fa9067d )
|
||||
|
||||
message(STATUS "Building knowhere-${KNOWHERE_SOURCE_VER} from source")
|
||||
message(STATUS ${CMAKE_BUILD_TYPE})
|
||||
|
||||
@ -28,6 +28,8 @@ const (
|
||||
L2 = "L2"
|
||||
// IP represents the inner product distance
|
||||
IP = "IP"
|
||||
// COSINE represents the cosine distance
|
||||
COSINE = "COSINE"
|
||||
// HAMMING represents the hamming distance
|
||||
HAMMING = "HAMMING"
|
||||
// TANIMOTO represents the tanimoto distance
|
||||
|
||||
@ -21,5 +21,5 @@ import "strings"
|
||||
// PositivelyRelated return if metricType are "ip" or "IP"
|
||||
func PositivelyRelated(metricType string) bool {
|
||||
mUpper := strings.ToUpper(metricType)
|
||||
return mUpper == strings.ToUpper(IP)
|
||||
return mUpper == strings.ToUpper(IP) || mUpper == strings.ToUpper(COSINE)
|
||||
}
|
||||
|
||||
@ -31,6 +31,9 @@ const (
|
||||
// IP represents inner product distance
|
||||
IP = "IP"
|
||||
|
||||
// COSINE represents cosine distance
|
||||
COSINE = "COSINE"
|
||||
|
||||
// HAMMING represents hamming distance
|
||||
HAMMING = "HAMMING"
|
||||
|
||||
@ -84,7 +87,7 @@ const (
|
||||
)
|
||||
|
||||
// METRICS is a set of all metrics types supported for float vector.
|
||||
var METRICS = []string{L2, IP} // const
|
||||
var METRICS = []string{L2, IP, COSINE} // const
|
||||
|
||||
// BinIDMapMetrics is a set of all metric types supported for binary vector.
|
||||
var BinIDMapMetrics = []string{HAMMING, JACCARD, TANIMOTO, SUBSTRUCTURE, SUPERSTRUCTURE} // const
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user