Append EOS to caption targets (train captions to stop) - #157
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates caption tokenization/label construction so captioning fine-tunes learn to emit a stop token by appending the tokenizer EOS (when available) within max_text_len, and extends unit tests to cover EOS supervision and prior edge cases (single-token and empty captions).
Changes:
- Append
eos_token_id(when defined) during_tokenize_and_maskso the last caption token is supervised to predict EOS. - Update/extend unit tests for both image (VLM) and video caption datasets to validate EOS supervision and edge cases.
- Document the behavior in
_tokenize_and_mask’s docstring and add a changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
kempnerforge/data/vlm_dataset.py |
Appends EOS within max_text_len in _tokenize_and_mask and documents supervision semantics. |
tests/unit/test_vlm_dataset.py |
Updates tests to assert EOS is appended/predicted and adds coverage for single-token + empty captions. |
tests/unit/test_video_dataset.py |
Updates video dataset tests to match new EOS-append/label expectations. |
CHANGELOG.md |
Records the EOS stop-target fix and notes prompt-related first-token supervision behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
amazloumi
force-pushed
the
followup/vlm-caption-bos-eos
branch
from
July 24, 2026 22:11
39d5502 to
0995194
Compare
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.
Summary
_tokenize_and_maskappends the tokenizer's EOS to each caption (when defined), reserving its slot withinmax_text_len, so the last caption token is supervised to predict stop. No-op when the tokenizer has no EOS. Shared by the image + video caption paths.-100edge case ([x]→[x, EOS]).Stacks on #155
Testing
ruff check/ruff format --checkpasspyright(0 errors)pytest tests/unit/{test_vlm_dataset,test_video_dataset}.py— 53 passedCloses #156