Repository navigation
Conversation
`concat_datasets(datasets, batch_size)` has no default for `batch_size`, so `ContrastiveTrainer(..., eval_dataset=[...])` raised `TypeError: concat_datasets() missing 1 required positional argument`. Mirror the train branch two statements above and pass `kwargs["args"].eval_batch_size`, so each eval dataset is rounded down to a whole number of eval batches.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ContrastiveTrainer.__init__handles a list of datasets for bothtrain_datasetandeval_dataset, but only the train branch passesbatch_sizetoconcat_datasets:batch_sizehas no default, so constructing the trainer with a list of eval datasets fails immediately:The single-dataset (non-list) path is unaffected, which is why this has gone unnoticed — only multi-dataset evaluation trips it.
Root cause
Vbert(#339,174055b0) factored the per-dataset round-down that #276 had added for training into the sharedconcat_datasets(datasets, batch_size)helper, and introduced both call sites in the same diff — the train one withbatch_size=, the eval one without:Fix
Pass the eval-side batch size, mirroring the train branch two statements above (that call is the spec):
TrainingArguments.eval_batch_sizeis the eval-side counterpart oftrain_batch_size, so each eval dataset now gets rounded down to a whole number of eval batches — the same invariantconcat_datasetswas written to enforce for training.+1 / −1.
Verification
transformers/torcharen't needed for this:concat_datasetsand the twoisinstance(kwargs[...], list)statements of__init__were pulled out of the real file withast.get_source_segment(nothing hand-transcribed) and executed withConcatDatasetstubbed to a list and a minimalDatasetexposing__len__/take.concat_datasetscall sitesbatch_size; line 44 → 1 pos, no kwargsbatch_sizeinspect.signature(concat_datasets).bind([datasets])missing a required argument: 'batch_size'__init__prologue,eval_dataset=[DS(10), DS(9)],eval_batch_size=4TypeError: concat_datasets() missing 1 required positional argument: 'batch_size'[DS(8), DS(8)]— rounded down to a multiple of 4train_dataset=[DS(20), DS(17)],train_batch_size=8[DS(16), DS(16)]— unchanged behavioureval_dataset=DS(9)(not a list)ruff format --checkis clean on the changed file.ruff checkreports only the pre-existingI001that the pristine upstream file also reports when linted outside the repo's own layout, so the change adds no new lint.🤖 Generated with Claude Code