Mark COSINE VectorSimilarity function as deprecated (#13473)

This commit is contained in:
Pulkit Gupta 2024-06-11 23:19:21 +05:30 committed by GitHub
parent cfdc747cde
commit 1c655823dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View File

@ -243,7 +243,8 @@ Other
API Changes
---------------------
(No changes)
* GITHUB#13281: Mark COSINE VectorSimilarityFunction as deprecated. (Pulkit Gupta)
New Features
---------------------

View File

@ -66,7 +66,10 @@ public enum VectorSimilarityFunction {
* vectors to unit length, and instead use {@link VectorSimilarityFunction#DOT_PRODUCT}. You
* should only use this function if you need to preserve the original vectors and cannot normalize
* them in advance. The similarity score is normalised to assure it is positive.
*
* @deprecated Use MAXIMUM_INNER_PRODUCT or DOT_PRODUCT instead
*/
@Deprecated
COSINE {
@Override
public float compare(float[] v1, float[] v2) {

View File

@ -70,7 +70,9 @@ public final class VectorUtil {
* Returns the cosine similarity between the two vectors.
*
* @throws IllegalArgumentException if the vectors' dimensions differ.
* @deprecated use dot-product instead using normalized vectors
*/
@Deprecated
public static float cosine(float[] a, float[] b) {
if (a.length != b.length) {
throw new IllegalArgumentException("vector dimensions differ: " + a.length + "!=" + b.length);
@ -80,7 +82,12 @@ public final class VectorUtil {
return r;
}
/** Returns the cosine similarity between the two vectors. */
/**
* Returns the cosine similarity between the two vectors.
*
* @deprecated use dot-product instead using normalized vectors
*/
@Deprecated
public static float cosine(byte[] a, byte[] b) {
if (a.length != b.length) {
throw new IllegalArgumentException("vector dimensions differ: " + a.length + "!=" + b.length);