Package com.redis.vl.utils.rerank
Class HFCrossEncoderReranker.Builder
java.lang.Object
com.redis.vl.utils.rerank.HFCrossEncoderReranker.Builder
- Enclosing class:
HFCrossEncoderReranker
Builder for creating HFCrossEncoderReranker instances.
Provides a fluent API for configuring cross-encoder rerankers with model selection, result limits, score inclusion, and cache directory settings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the HFCrossEncoderReranker instance.Set the cache directory for model storage.limit
(int limit) Set the maximum number of results to return.Set the model name.returnScore
(boolean returnScore) Set whether to return scores with results.
-
Constructor Details
-
Builder
public Builder()Creates a new builder with default settings.
-
-
Method Details
-
model
Set the model name.- Parameters:
model
- HuggingFace model name (e.g., "cross-encoder/ms-marco-MiniLM-L-6-v2")- Returns:
- This builder
-
limit
Set the maximum number of results to return.- Parameters:
limit
- Maximum number of results (must be positive)- Returns:
- This builder
- Throws:
IllegalArgumentException
- if limit is not positive
-
returnScore
Set whether to return scores with results.- Parameters:
returnScore
- true to include scores- Returns:
- This builder
-
cacheDir
Set the cache directory for model storage.- Parameters:
cacheDir
- Path to cache directory- Returns:
- This builder
-
build
Build the HFCrossEncoderReranker instance.- Returns:
- Configured reranker
-