Trains binary text classifiers and returns complete BinClass.Classifier values.
Training includes tokenizer construction, stratified train/validation partitioning, optional class balancing, checkpoint selection, and decision-policy calibration.
Summary
Functions
Trains a binary classifier on the given data stream.
Functions
Trains a binary classifier on the given data stream.
Options
:epochs- Positive integer number of training epochs. Defaults to10.:batch_size- Positive integer batch size for training. Defaults to32.:learning_rate- Positive initial learning rate. Defaults to1.0e-3.:decay- Non-negative AdamW weight decay. Defaults to1.0e-2.:schedule- Learning rate decay schedule. Accepts:linear(Meta FAIR warmup + linear decay),:cosine(warmup + cosine decay),:wsd(warmup-stable-decay),:constant, options tuples like{:linear, warmup_ratio: 0.1}, or a 1-argument schedule function. Defaults to:linear.:labels- Output label names as a two-element list of distinct binaries or%{0 => negative_binary, 1 => positive_binary}. Defaults to["0", "1"].:target_mode- How training labels are interpreted.:hardaccepts only0and1;:softaccepts positive-class probabilities from0.0through1.0. Defaults to:hard.:target_threshold- Boundary used to turn soft targets into binary labels for balancing, validation metrics, and threshold calibration. Defaults to0.5.:balance- Boolean controlling whether to oversample the smaller class in the training partition. Validation examples are never oversampled. Soft targets are assigned to a class using:target_threshold. Defaults totrue.:validation_split- Fraction of full batches to use for validation. Partitions are stratified when both target classes can occur in both. Defaults to0.1.:patience- Non-negative integer number of epochs to wait for improvement before early stopping. Defaults to5.:compiler- A module implementingNx.Defn.Compiler. Defaults toEXLA.:architecture- The named architecture to use. Defaults to:parallel_cnn.:dropout_rate- Dropout rate from0.0up to, but excluding,1.0. Defaults to0.2.:decision_policy- How probabilities become labels. Accepts:argmax,{:positive_threshold, threshold},:optimize_threshold, or{:optimize_threshold, options}. Threshold optimization options are:objective(:accuracy,:balanced_accuracy, or:f1) and:false_positive_cost. Defaults to:argmax.:minimum_input_tokens- Inputs with fewer active tokens return:insufficient_inputat inference. Defaults to0.:vector_length- Positive fixed sequence length satisfying the architecture's minimum. Defaults to512.:vocab_size- Positive maximum vocabulary size for tokenizer training. Defaults to8_000.:normalizer- Text normalizer to apply before tokenization. Accepts:nfkc_lowercase(default),:nfkc,:lowercase,:none,nil, or aTokenizers.Normalizerstruct.:label_smoothing- Label smoothing factor $lpha in [0.0, 0.5]$ applied to target labels during training to regularize extreme confidence. Defaults to0.0(no smoothing).:seed- Optional integer seed for deterministic partition ordering, model initialization, and dropout. Defaults to nondeterministic training.