Class MalletCrfTrainerConfiguration.Builder
java.lang.Object
org.coordinatekit.crf.mallet.train.MalletCrfTrainerConfiguration.Builder
- Enclosing class:
MalletCrfTrainerConfiguration
Builder for constructing
MalletCrfTrainerConfiguration instances.
All parameters have sensible defaults, so you only need to set the values you want to customize.
The builder validates all parameters when build() is called.
Example:
MalletCrfTrainerConfig config = MalletCrfTrainerConfig.builder().gaussianVariance(5.0).trainingFraction(0.8)
.iterations(1000).build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuration with the current settings.conllOutputConfiguration(ConllOutputConfiguration conllOutputConfiguration) Sets the configuration for CoNLL output.conllOutputEnabled(boolean conllOutputEnabled) Sets whether to enable CoNLL output during training.fullyConnected(boolean fullyConnected) Sets whether to create a fully connected CRF state machine.gaussianVariance(double gaussianVariance) Sets the Gaussian prior variance for L2 regularization.iterations(int iterations) Sets the maximum number of training iterations.modelOutputConfiguration(ModelOutputConfiguration modelOutputConfiguration) Sets the configuration for model checkpoint output.modelOutputEnabled(boolean modelOutputEnabled) Sets whether to enable model checkpoint output during training.randomSeed(int randomSeed) Sets the random seed for data splitting.threads(int numThreads) Sets the number of threads for parallel training.trainingFraction(double trainingFraction) Sets the fraction of data to use for training.weightsType(WeightsType weightsType) Sets the weight storage type.
-
Method Details
-
build
Builds the configuration with the current settings.- Returns:
- an immutable configuration instance
-
conllOutputEnabled
Sets whether to enable CoNLL output during training.- Parameters:
conllOutputEnabled- true to enable CoNLL output- Returns:
- this builder
-
conllOutputConfiguration
public MalletCrfTrainerConfiguration.Builder conllOutputConfiguration(ConllOutputConfiguration conllOutputConfiguration) Sets the configuration for CoNLL output.If null is provided, a default configuration will be used.
- Parameters:
conllOutputConfiguration- the CoNLL output configuration, or null for defaults- Returns:
- this builder
-
fullyConnected
Sets whether to create a fully connected CRF state machine.- Parameters:
fullyConnected- true for a fully connected CRF- Returns:
- this builder
-
gaussianVariance
Sets the Gaussian prior variance for L2 regularization.- Parameters:
gaussianVariance- the variance, must be positive- Returns:
- this builder
- Throws:
IllegalArgumentException- if gaussianVariance is not positive
-
iterations
Sets the maximum number of training iterations.- Parameters:
iterations- the maximum iterations, must be positive- Returns:
- this builder
- Throws:
IllegalArgumentException- if iterations is not positive
-
modelOutputEnabled
Sets whether to enable model checkpoint output during training.- Parameters:
modelOutputEnabled- true to enable model output- Returns:
- this builder
-
modelOutputConfiguration
public MalletCrfTrainerConfiguration.Builder modelOutputConfiguration(ModelOutputConfiguration modelOutputConfiguration) Sets the configuration for model checkpoint output.If null is provided, a default configuration will be used.
- Parameters:
modelOutputConfiguration- the model output configuration, or null for defaults- Returns:
- this builder
-
randomSeed
Sets the random seed for data splitting.- Parameters:
randomSeed- the seed value- Returns:
- this builder
-
threads
Sets the number of threads for parallel training.- Parameters:
numThreads- the number of threads, must be positive- Returns:
- this builder
- Throws:
IllegalArgumentException- if threads is not positive
-
trainingFraction
Sets the fraction of data to use for training.- Parameters:
trainingFraction- the fraction, must be greater than 0.0 and at most 1.0- Returns:
- this builder
- Throws:
IllegalArgumentException- if trainingFraction is not in (0.0, 1.0]
-
weightsType
Sets the weight storage type.- Parameters:
weightsType- the weights type, must not be null- Returns:
- this builder
- Throws:
IllegalArgumentException- if weightsType is null
-