You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by be...@apache.org on 2024/08/01 19:05:12 UTC
(lucene) branch main updated: Revert cosine deprecation (#13613)
This is an automated email from the ASF dual-hosted git repository.
benwtrent pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 836c8e76ad1 Revert cosine deprecation (#13613)
836c8e76ad1 is described below
commit 836c8e76ad15fcd2894df215a21c8cbb293062a9
Author: Benjamin Trent <be...@gmail.com>
AuthorDate: Thu Aug 1 15:05:05 2024 -0400
Revert cosine deprecation (#13613)
Opening for more pointed discussion. See latest discussion here: #13281
I was hoping to have a full answer for folks who use byte models by Lucene 10, but I just don't have that.
I still want to remove the internal cosine optimized methods. We can do this if we store magnitudes along side the raw vectors. This way we can remove all the internal optimized cosine code as its complicated.
---
lucene/CHANGES.txt | 4 +---
.../java/org/apache/lucene/index/VectorSimilarityFunction.java | 3 ---
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java | 9 +--------
3 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9d89c2365f1..6107eb173f6 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -254,9 +254,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)
* GITHUB#13612: Hunspell: add Suggester#proceedPastRep to avoid losing relevant suggestions. (Peter Gromov)
diff --git a/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java b/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
index b625f0740a5..23bd0fd0ec6 100644
--- a/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
+++ b/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
@@ -66,10 +66,7 @@ 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) {
diff --git a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
index 0ae563c8701..f122ae95544 100644
--- a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
@@ -70,9 +70,7 @@ 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);
@@ -82,12 +80,7 @@ public final class VectorUtil {
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);