Class ModelOutputEvaluator

java.lang.Object
cc.mallet.fst.TransducerEvaluator
org.coordinatekit.crf.mallet.train.ModelOutputEvaluator

@NullMarked public class ModelOutputEvaluator extends cc.mallet.fst.TransducerEvaluator
An evaluator that writes the current transducer (model) to file using Java serialization.

This evaluator serializes the transducer at specified iteration intervals, allowing model checkpoints to be saved during training. The serialized models can later be deserialized for inference or to resume training.

Output files are named using the pattern {prefix}_iter{N}.{suffix}, where N is the iteration number.

Example usage:

 
 ModelOutputConfiguration config = ModelOutputConfiguration.builder().outputDirectory(Path.of("models"))
         .filePrefix("crf_model").fileSuffix("ser").iterationInterval(10).build();
 ModelOutputEvaluator evaluator = new ModelOutputEvaluator(config);

 // Add to trainer
 trainer.addEvaluator(evaluator);
 
 
See Also:
  • Field Summary

    Fields inherited from class cc.mallet.fst.TransducerEvaluator

    instanceListDescriptions, instanceLists
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new model output evaluator with the specified configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    evaluate(cc.mallet.fst.TransducerTrainer trainer)
     
    void
    evaluateInstanceList(cc.mallet.fst.TransducerTrainer trainer, cc.mallet.types.InstanceList instances, String description)
     

    Methods inherited from class cc.mallet.fst.TransducerEvaluator

    preamble, precondition

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModelOutputEvaluator

      public ModelOutputEvaluator(ModelOutputConfiguration configuration)
      Creates a new model output evaluator with the specified configuration.
      Parameters:
      configuration - the evaluator configuration
  • Method Details

    • evaluateInstanceList

      public void evaluateInstanceList(cc.mallet.fst.TransducerTrainer trainer, cc.mallet.types.InstanceList instances, String description)
      Specified by:
      evaluateInstanceList in class cc.mallet.fst.TransducerEvaluator
    • evaluate

      public void evaluate(cc.mallet.fst.TransducerTrainer trainer)
      Overrides:
      evaluate in class cc.mallet.fst.TransducerEvaluator