Repository navigation
Conversation
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
Both embedder collators can dynamically pad each sub-batch to a different sequence length. M3's list-input encoding path directly concatenates the ColBERT vectors along the batch dimension, so unified fine-tuning raises a tensor-size mismatch when those sequence lengths differ. This prevents the documented sub-batch option from working on ordinary variable-length training text.
Changes
Pad the ColBERT vectors to the longest sub-batch sequence before concatenation, using the tokenizer's padding side and zero vectors for padding. Build the corresponding list-input attention mask in the same order: remove each sub-batch's first position, as ColBERT encoding already does, then pad. A leading column preserves the existing full-mask scoring interface.
Dense-only encoding and the tensor-input sub-batch path are unchanged.
Validation
Added 20 tests with an actual local BertTokenizerFast, tiny BERT backbone, sparse/ColBERT heads, and both native collators:
The unchanged upstream base produces 14 failed, 6 passed. With the fix, the new tests and existing Trainer/import checks produce 28 passed, 1 skipped. Ruff on the new test module and
git diff --checkpass.The tests preserve the existing first-position removal convention and do not claim to redefine left-padded special-token handling. This change is separate from passage MaxSim masking in #1610; it does not change that scoring reduction.