Interface ScoringFunction
- All Known Implementing Classes:
VectorScoringFunctions
public interface ScoringFunction
Strategy interface for scoring functions.
Implementations define how score (distance or similarity) between two vectors is computed, allowing control over ranking behavior in search queries.
Provides commonly used scoring variants via static factory methods. See VectorScoringFunctions for the
concrete implementations.
- Since:
- 4.0
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScoringFunctioncosine()Return the cosine similarity scoring function.static ScoringFunctionReturn the dot product (also known as inner product) scoring function.static ScoringFunctionReturn the Euclidean distance scoring function.getName()Return the name of the scoring function.static ScoringFunctionReturns the defaultScoringFunctionto be used when none is explicitly specified.
-
Method Details
-
unspecified
Returns the defaultScoringFunctionto be used when none is explicitly specified.This is typically used to indicate the absence of a scoring definition.
- Returns:
- the default
ScoringFunctioninstance.
-
euclidean
Return the Euclidean distance scoring function.Calculates the L2 norm (straight-line distance) between two vectors.
- Returns:
- the
ScoringFunctionbased on Euclidean distance.
-
cosine
Return the cosine similarity scoring function.Measures the cosine of the angle between two vectors, independent of magnitude.
- Returns:
- the
ScoringFunctionbased on cosine similarity.
-
dotProduct
Return the dot product (also known as inner product) scoring function.Computes the algebraic product of two vectors, considering both direction and magnitude.
- Returns:
- the
ScoringFunctionbased on dot product.
-
getName
String getName()Return the name of the scoring function.Typically used for display or configuration purposes.
- Returns:
- the identifying name of this scoring function.
-