Skip to content

refactor(seq2seq): improve Seq2Seq data collation and logging - #80

Merged
JulesBelveze merged 2 commits into
mainfrom
chore/seq2seq-training-hardening
Jan 8, 2026
Merged

refactor(seq2seq): improve Seq2Seq data collation and logging#80
JulesBelveze merged 2 commits into
mainfrom
chore/seq2seq-training-hardening

Conversation

@JulesBelveze

@JulesBelveze JulesBelveze commented Jan 8, 2026

Copy link
Copy Markdown
Owner

Description

Improves Seq2Seq data handling and logging robustness. Replaces manual tokenizer padding with DataCollatorForSeq2Seq to properly handle label padding with ignore index (-100), preventing labels from being padded with the tokenizer's pad token. Refactors evaluation logging to support both tensor and non-tensor values (e.g., DistillationLoss objects), and restructures model initialization order to ensure models are properly configured before calling parent constructors. Also fixes scorer initialization to use label lists instead of integers.

Risk

Low risk - changes improve correctness and robustness. The data collation change ensures labels are properly masked during training. Model initialization order change ensures proper configuration but should be tested across different model types.

Tests

Comprehensive unit tests added:

  • test_collate_pads_labels_with_ignore_index: validates label padding with -100
  • test_lm_scorer_supports_loss_only and test_lm_scorer_supports_distillation_loss: validate LMScorer handles both tensor and DistillationLoss
  • test_base_sequence_classification_transformer_module_default_scorer: validates correct scorer initialization

 - Replace tokenizer pad with DataCollatorForSeq2Seq in Seq2SeqTransformerDataModule
 - Modify evaluation logging to handle cases with non-tensor values in BaseTransformerModule
 - Ensure consistency in logging loss and perplexity during training in SimpleT5Model
 - Update LMScorer to correctly handle a mix of tensor and non-tensor values, supporting DistillationLoss

[tests] - test: add tests for Seq2Seq collation and LMScorer changes

 - Add test to ensure correct padding behavior with ignore index in Seq2SeqTransformerDataModule
 - Add test to validate that LMScorer supports both tensor and DistillationLoss objects
…y checks

 - Move the default model initialization into the constructor based on `pretrained_model` and `model_config`
 - Delay the `super().__init__` call until after the model is potentially initialized within the class constructor

[bert_squeeze] - fix: correct scorer label initialization

 - Initialize the `BaseSequenceClassificationScorer` with a list of label indices instead of `self.num_labels`

[tests] - test: add tests for BaseSequenceClassificationTransformerModule default scorer

 - Ensure scorer is properly initialized with correct labels and distinct scorer objects for validation and test sets
@JulesBelveze
JulesBelveze merged commit e2e627b into main Jan 8, 2026
9 checks passed
@JulesBelveze
JulesBelveze deleted the chore/seq2seq-training-hardening branch January 8, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant