Re: Other vector similarity metric than provided by VectorSimilarityFunction

2023-01-14 Thread Michael Wechner

Hi Adrien

Thanks for your feedback! Whereas I am not sure I fully understand what 
you mean


At the moment I am using something like:

float[] vector = ...;
FieldType vectorFieldType = KnnVectorField.createFieldType(vector.length, 
VectorSimilarityFunction.COSINE);
KnnVectorField vectorField =new KnnVectorField("vector_field", vector, 
vectorFieldType);
doc.add(vectorField);

Could you give me some sample code what you mean with "custom KNN 
vectors format"?


Thanks

Michael

Am 14.01.23 um 22:14 schrieb Adrien Grand:

Hi Michael,

You could create a custom KNN vectors format that ignores the vector
similarity configured on the field and uses its own.

Le sam. 14 janv. 2023, 21:33, Michael Wechner  a
écrit :


Hi

IIUC Lucene currently supports

VectorSimilarityFunction.COSINE
VectorSimilarityFunction.DOT_PRODUCT
VectorSimilarityFunction.EUCLIDEAN

whereas some embedding models have been trained with other metrics.
Also see

https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cdist.html

How can I best implement another metric?

Thanks

Michael





-
To unsubscribe, e-mail:java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail:java-user-h...@lucene.apache.org




Re: Other vector similarity metric than provided by VectorSimilarityFunction

2023-01-14 Thread Adrien Grand
Hi Michael,

You could create a custom KNN vectors format that ignores the vector
similarity configured on the field and uses its own.

Le sam. 14 janv. 2023, 21:33, Michael Wechner  a
écrit :

> Hi
>
> IIUC Lucene currently supports
>
> VectorSimilarityFunction.COSINE
> VectorSimilarityFunction.DOT_PRODUCT
> VectorSimilarityFunction.EUCLIDEAN
>
> whereas some embedding models have been trained with other metrics.
> Also see
>
> https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cdist.html
>
> How can I best implement another metric?
>
> Thanks
>
> Michael
>
>
>
>
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


Other vector similarity metric than provided by VectorSimilarityFunction

2023-01-14 Thread Michael Wechner

Hi

IIUC Lucene currently supports

VectorSimilarityFunction.COSINE
VectorSimilarityFunction.DOT_PRODUCT
VectorSimilarityFunction.EUCLIDEAN

whereas some embedding models have been trained with other metrics.
Also see 
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cdist.html


How can I best implement another metric?

Thanks

Michael





-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org