TrainingArguments
Arguments for GRADIEND training (HF Trainer–style, single training_args class).
Pass to Trainer at construction: Trainer(model=..., training_args=TrainingArguments(...)). Used directly by the core training loop.
activation_decoder
class-attribute
instance-attribute
Decoder activation name (e.g. 'id', 'tanh'). None = model default ('id').
activation_encoder
class-attribute
instance-attribute
Encoder activation name (e.g. 'tanh', 'gelu', 'relu'). None = model default ('tanh').
add_identity_for_other_classes
class-attribute
instance-attribute
If True, add identity (factual==alternative) examples for classes not in the target classes used for training.
analyze_seed_stability
class-attribute
instance-attribute
If True, require at least min_convergent_seeds convergent seeds after multi-seed training and forbid saved_seed_runs='best_only'. Multi-seed evaluation uses trainer.multi_seed().
base_gradient_batch_size
class-attribute
instance-attribute
Number of raw training examples merged into one base-model loss/backward call, producing one base-gradient vector.
base_model_device_map
class-attribute
instance-attribute
Hugging Face device_map for the base model. None auto-detects large models on >3 GPUs, False disables device_map, and strings/dicts are passed through explicitly.
base_model_max_memory
class-attribute
instance-attribute
Optional Hugging Face max_memory map for base-model device placement. When unset and base_model_device_map='auto' on multiple GPUs, GPU0 is reserved for GRADIEND automatically.
bias_decoder
class-attribute
instance-attribute
Whether the decoder linear layer uses a bias term. None = model default (True).
convergent_mean_by_class_threshold
class-attribute
instance-attribute
Optional additional convergence criterion: minimum absolute mean encoded value per target class.
Default: 0.5 when convergent_metric='correlation'. Set to None to disable the mean-based check and use only convergent_score_threshold. When set, convergence requires BOTH |correlation| >= convergent_score_threshold AND min(|mean|) over non-zero target classes >= convergent_mean_by_class_threshold at the best checkpoint step. For correlation-based convergence, the two non-zero target classes must also have opposite-sign mean encodings at the best checkpoint step (their product must be negative).
convergent_metric
class-attribute
instance-attribute
Metric for convergence: "correlation" or "loss". Defaults to correlation unless supervised_decoder.
convergent_score_threshold
class-attribute
instance-attribute
Threshold for convergence. Defaults to 0.6 for correlation; required for loss.
criterion
class-attribute
instance-attribute
Loss function; None = MSELoss().
dataset_trust_remote_code
class-attribute
instance-attribute
Optional trust_remote_code value for HuggingFace datasets.load_dataset. None means do not pass the keyword.
decoder_eval_feature_factors
class-attribute
instance-attribute
Feature factors for decoder grid search. None = derive from trainer target classes.
decoder_eval_lrs
class-attribute
instance-attribute
Learning rates for decoder grid search. None = DecoderEvaluator defaults (1/2/5 grid from 100 to 1e-3).
decoder_eval_max_size_neutral
class-attribute
instance-attribute
Max samples for decoder neutral evaluation data (also LMS text cap). None = use default behavior.
decoder_eval_max_size_training_like
class-attribute
instance-attribute
Max samples for decoder training-like evaluation data. None = use default behavior.
decoder_mlm_head_batch_size
class-attribute
instance-attribute
Batch size used when prediction_objective="clm_mlm_head" trains the auxiliary head.
decoder_mlm_head_epochs
class-attribute
instance-attribute
Epochs used when prediction_objective="clm_mlm_head" has to train the auxiliary head.
decoder_mlm_head_lr
class-attribute
instance-attribute
Learning rate used when prediction_objective="clm_mlm_head" trains the auxiliary head.
decoder_mlm_head_max_size
class-attribute
instance-attribute
Optional per-label cap for auxiliary decoder MLM-head training data.
decoder_sequence_cloze_rhs_window
class-attribute
instance-attribute
Right-context token window for clm_sequence_cloze / seq2seq_decoder_sequence_cloze scoring and training. -1 uses the full RHS.
delete_models
class-attribute
instance-attribute
If True, delete intermediate model files at end (e.g. .bin). This can be used to save disk space if you only care about metrics and not the model itself. Does not delete the whole model directory, which may contain other files (e.g. config, pre/post-prune results).
do_eval
class-attribute
instance-attribute
Whether to run evaluation during training.
encoder_decoder_same_device
class-attribute
instance-attribute
If True, place encoder and decoder on the same GPU (cuda:0), giving the base model the rest. Useful for large base models with pre-pruning: encoder+decoder are small and can share GPU 0; base model can use cuda:1 (2 GPUs) or cuda:2 (3+ GPUs). If False (default), encoder and decoder are split across cuda:0 and cuda:1 when 2+ GPUs are available.
encoder_eval_balance
class-attribute
instance-attribute
If True, balance encoder evaluation data per feature_class_id. If False, use natural class distribution.
encoder_eval_max_size
class-attribute
instance-attribute
Max samples for encoder evaluation outside training (e.g. analysis, manual evaluate_encoder). None = use all available.
encoder_eval_train_max_size
class-attribute
instance-attribute
Max samples for encoder evaluation during training (fast estimate; per-feature_class when available). None = use encoder_eval_max_size.
eval_steps
class-attribute
instance-attribute
Run evaluation every eval_steps (when eval_strategy == 'steps').
eval_strategy
class-attribute
instance-attribute
When to run evaluation: 'steps' (every eval_steps) or 'no'.
evaluate_fn
class-attribute
instance-attribute
Custom evaluation function; None = default (encoder correlation on eval data).
experiment_dir
class-attribute
instance-attribute
Root directory for this experiment. When set, default paths use subpaths under it (model, encoded_values, etc.). One experiment dir holds one model. Trainer.run_id (when set) is used as subdir under this.
fail_on_non_convergence
class-attribute
instance-attribute
If True, raise when training finishes and convergent_count < min_convergent_seeds (requires min_convergent_seeds > 0).
gradiend_batch_size
class-attribute
instance-attribute
Number of base-gradient vectors stacked into one GRADIEND optimizer step. Defaults to 1.
gradient_timing_steps
class-attribute
instance-attribute
If > 0, log timing for gradient-row creation every N rows.
highlight_non_convergence
class-attribute
instance-attribute
If True, append a non-convergence marker (†) to plot/tick labels for non-converged runs.
include_other_classes
class-attribute
instance-attribute
If True, encoder evaluation includes all class transitions in the split, not just the trained target pair. Applies when all_classes has more than two entries. Affects encoder metrics, encoder plots, and suite cross-encoding plots built from encoder evaluation. Set on TrainingArguments or pass include_other_classes=True to evaluate_encoder().
latent_dim
class-attribute
instance-attribute
GRADIEND latent dimension (number of features). None = model default (1).
max_steps
class-attribute
instance-attribute
If > 0, total number of steps; overrides num_train_epochs. -1 = use epochs.
min_convergent_seeds
class-attribute
instance-attribute
Stop once this many seeds have converged. None = run max_seeds. 0 is invalid.
model_use_cache
class-attribute
instance-attribute
When False (default), pass use_cache=False to decoder model forward during training (KV cache disabled). Use True only for inference/generation. Decoder-only MLM head training respects this via train_decoder_only_mlm_head.
normalize_gradiend
class-attribute
instance-attribute
Whether to normalize GRADIEND encodings during training, i.e., first target class is encoded to +1 and second to -1. This is recommended for enhanced comparability between runs.
output_dir
class-attribute
instance-attribute
Directory to save the trained model. If None and experiment_dir is set, uses experiment_dir/model (or experiment_dir/run_id/model when Trainer.run_id is set). Otherwise must be set explicitly.
params
class-attribute
instance-attribute
If set, only these parameter names or wildcards are included in the GRADIEND param map when building from a base model. None = include all backbone parameters (default). Enables future params selection processes.
positive_class
class-attribute
instance-attribute
Optional canonical positive feature class used for binary cross-encoding comparisons. When None, comparison utilities may infer it conservatively from target classes via the non_/non- prefix heuristic. Ignored for normal training.
post_prune_config
class-attribute
instance-attribute
If set, post-prune is run automatically after training. The pruned model is kept in memory for subsequent evaluation. No disk save unless you save explicitly.
pre_prune_config
class-attribute
instance-attribute
If set, pre-prune is run automatically before training. The pruned model is kept in memory; training then uses it. No disk save unless you save explicitly.
precompute_gradient_batches
class-attribute
instance-attribute
Whether to precompute the next gradient row asynchronously. None (default): auto-enable only when the base model is sharded and multiple CUDA devices are available. False: never precompute. True: always precompute (thread-safe via ModelWithGradiend.exclusive_base_gradient_access during base forward/backward).
precompute_gradient_buffer_size
class-attribute
instance-attribute
Number of already-computed gradient rows to keep in the asynchronous precompute queue.
prediction_objective
class-attribute
instance-attribute
Prediction objective for text-gradient training and decoder probability scoring.
Supported: auto, mlm_mask_token, clm_next_token, clm_mlm_head,
clm_sequence_cloze, seq2seq_decoder (experimental), seq2seq_decoder_sequence_cloze (experimental),
seq2seq_encoder_mlm.
auto: seq2seq models → seq2seq_encoder_mlm; decoder-only → clm_next_token (or cached
clm_mlm_head when a saved head exists); else mlm_mask_token.
reuse_pre_prune
class-attribute
instance-attribute
If True, cache pre-prune keep_idx under experiment_dir/cache/pre_prune for reuse across seeds in one train() call. Cache is removed when training finishes.
runtime_monitor
class-attribute
instance-attribute
If True, write persistent JSONL runtime diagnostics under the training output directory.
runtime_monitor_interval
class-attribute
instance-attribute
Seconds between runtime monitor heartbeat samples.
runtime_monitor_system_stats
class-attribute
instance-attribute
If True, runtime monitor heartbeats include CPU/GPU memory stats.
save_only_best
class-attribute
instance-attribute
If True, keep only the best checkpoint (by evaluation correlation).
save_steps
class-attribute
instance-attribute
Save checkpoint every save_steps when save_strategy == 'steps'.
save_strategy
class-attribute
instance-attribute
'best' (default): keep only best checkpoint by correlation. 'steps': also save periodic checkpoints every save_steps. 'no': no checkpointing.
saved_seed_runs
class-attribute
instance-attribute
Multi-seed retention policy: 'best_only', 'all_convergent', or 'all_tried'.
seed
class-attribute
instance-attribute
Random seed for reproducible runs (default 0). The Trainer sets PyTorch/numpy/Python RNG, CUDA determinism, and CUBLAS/OMP env vars; data pipelines use this as random_state. Also the base for multi-seed runs (seed+i). Pass seed=None for non-deterministic runs. If results still vary, call set_seed(42) at the very start of your script or set env CUBLAS_WORKSPACE_CONFIG=:4096:8 and OMP_NUM_THREADS=1 before starting Python.
seed_runs_dir
class-attribute
instance-attribute
Directory for per-seed runs. Defaults to experiment_dir/seeds when experiment_dir is set.
seed_selection_eval_max_size
class-attribute
instance-attribute
Max samples for encoder evaluation when selecting the best seed. None = use encoder_eval_max_size.
seed_stability_part
class-attribute
instance-attribute
Importance part used for convergent-seed top-k stability summaries.
seed_stability_topk
class-attribute
instance-attribute
Top-k selection used for stability summaries across convergent seeds. None disables the report.
source
class-attribute
instance-attribute
Source for GRADIEND input: 'factual', 'alternative', or 'diff'.
split_resplit_per_seed
class-attribute
instance-attribute
When split_col is "heldout" or None, re-draw splits per training seed.
For "heldout", vocabulary groups rotate (see split_resplit_strategy).
For None, rows are reshuffled randomly. False keeps the same assignment across
multi-seed runs (using TrainingArguments.seed).
split_resplit_strategy
class-attribute
instance-attribute
Strategy used when split_resplit_per_seed=True.
"random" redraws splits from each seed. "balanced_cycle" rotates
canonical target groups through train/validation/test across seed indices
so ratios such as 60/20/20 over five seed slots place each word in train
three times, validation once, and test once.
supervised_decoder
class-attribute
instance-attribute
If True, train only the GRADIEND decoder: decoder(labels) vs target gradients (MSE). Baseline mode. Cannot be True together with supervised_encoder.
supervised_encoder
class-attribute
instance-attribute
If True, train only the GRADIEND encoder: encode(source) vs labels (MSE). Baseline mode.
target
class-attribute
instance-attribute
Target for GRADIEND output: 'factual', 'alternative', or 'diff'.
torch_dtype
class-attribute
instance-attribute
dtype for model; None = torch.float32.
train_batch_size
class-attribute
instance-attribute
Alias/default for base_gradient_batch_size. Does not affect gradiend_batch_size.
train_max_size
class-attribute
instance-attribute
If set, cap training samples per feature_class_id (downsampling).
Note: Balancing is handled automatically by the dataset scheduler via oversampling (cycling through balance groups). This parameter primarily reduces total dataset size for memory/performance. None = use all data.
trust_remote_code
class-attribute
instance-attribute
If True, pass trust_remote_code=True when loading models/tokenizers from Hugging Face (e.g. for EuroBERT).
use_cache
class-attribute
instance-attribute
Training checkpoint reuse policy.
False: always retrain even when a saved model exists.True: reuse when a saved model exists and matches the training cache fingerprint."always": reuse any saved model at the output path (skip fingerprint matching)."only_convergent": same fingerprint check asTrue, but only when the saved run meetsmin_convergent_seeds(per-seed convergence for individual seed dirs; aggregate count for the selected model).
use_cached_gradients
class-attribute
instance-attribute
Whether to use cached gradients if available. Using cached gradients speeds up training and evaluation, but leads to exhaustive memory usage (in memory) and/or on disk (in cached files).
__post_init__
Source code in gradiend/trainer/core/arguments.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
__str__
Source code in gradiend/trainer/core/arguments.py
from_dict
classmethod
Create from dict (e.g. loaded from JSON). Canonical keys only.
Source code in gradiend/trainer/core/arguments.py
get
to_dict
Dict for serialization (excludes callables and nn.Module). Canonical keys only.