Enum Class VectorScoringFunctions
- All Implemented Interfaces:
Serializable, Comparable<VectorScoringFunctions>, Constable, ScoringFunction
ScoringFunction implementations for vector-based similarity computations.
Provides a set of standard scoring strategies for comparing vectors in search or matching operations. Includes options such as Euclidean distance, cosine similarity, and dot product.
These constants are intended for reuse across components requiring vector scoring semantics. Each scoring function represents a mathematical approach to quantifying the similarity or distance between vectors in a multidimensional space.
When selecting a scoring function, consider the specific requirements of your application domain:
- For spatial distance measurements where magnitude matters, use
EUCLIDEAN. - For directional similarity irrespective of magnitude, use
COSINE. - For efficient high-dimensional calculations, use
DOT_PRODUCT. - For grid-based or axis-aligned problems, use
TAXICAB. - For binary vector or string comparisons, use
HAMMING.
ScoringFunction and score values are typically subject to fine-tuning during the development to
achieve optimal performance and accuracy.- Since:
- 4.0
- Author:
- Mark Paluch
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionScoring based on cosine similarity between two vectors.Scoring based on the dot product (also known as inner product) between two vectors.Scoring based on the Euclidean distance between two vectors.Scoring based on the Hamming distance between two vectors or strings.Scoring based on taxicab (Manhattan) distance. -
Method Summary
Modifier and TypeMethodDescriptiongetName()Return the name of the scoring function.static VectorScoringFunctionsReturns the enum constant of this class with the specified name.static VectorScoringFunctions[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EUCLIDEAN
Scoring based on the Euclidean distance between two vectors.Computes the L2 norm, involving a square root operation. Typically more computationally expensive than
COSINEorDOT_PRODUCT, but precise in spatial distance measurement. -
COSINE
Scoring based on cosine similarity between two vectors.Measures the angle between vectors, independent of their magnitude. Involves a
DOT_PRODUCTand normalization, offering a balance between precision and performance. -
DOT_PRODUCT
Scoring based on the dot product (also known as inner product) between two vectors.Efficient to compute and particularly useful in high-dimensional vector spaces.
-
TAXICAB
Scoring based on taxicab (Manhattan) distance.Computes the sum of absolute differences across dimensions. Useful in contexts where axis-aligned movement or L1 norms are preferred.
-
HAMMING
Scoring based on the Hamming distance between two vectors or strings.Counts the number of differing positions. Suitable for binary (bitwise) vectors or fixed-length character sequences.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getName
Description copied from interface:ScoringFunctionReturn the name of the scoring function.Typically used for display or configuration purposes.
- Specified by:
getNamein interfaceScoringFunction- Returns:
- the identifying name of this scoring function.
-