Skip to content

Commit

Permalink
Revert cosine deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
benwtrent committed Jul 26, 2024
1 parent 8d4f7a6 commit 6268187
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
4 changes: 1 addition & 3 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ Other
API Changes
---------------------

* GITHUB#13281: Mark COSINE VectorSimilarityFunction as deprecated. (Pulkit Gupta)

* GITHUB#13469: Expose FlatVectorsFormat as a first-class format; can be configured using a custom Codec. (Michael Sokolov)
* GITHUB#13469: Expose FlatVectorsFormat as a first-class format; can be configured using a custom Codec. (Michael Sokolov)

New Features
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ public float compare(byte[] v1, byte[] v2) {
* 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) {
Expand Down
9 changes: 1 addition & 8 deletions lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ public static float dotProduct(float[] a, float[] b) {
* 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);
Expand All @@ -82,12 +80,7 @@ public static float cosine(float[] a, float[] b) {
return r;
}

/**
* Returns the cosine similarity between the two vectors.
*
* @deprecated use dot-product instead using normalized vectors
*/
@Deprecated
/** Returns the cosine similarity between the two vectors. */
public static float cosine(byte[] a, byte[] b) {
if (a.length != b.length) {
throw new IllegalArgumentException("vector dimensions differ: " + a.length + "!=" + b.length);
Expand Down

0 comments on commit 6268187

Please sign in to comment.