-
Notifications
You must be signed in to change notification settings - Fork 77
fix: prevent empty tensor errors by handling missing assistant roles #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe change updates the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🪛 LanguageToolREADME.md[uncategorized] ~90-~90: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION) 🔇 Additional comments (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
dataset.py (1)
82-90: Effective solution for preventing empty tensor errors!This change appropriately handles dataset items that lack an assistant response by using the accumulated input buffer to generate non-empty tensors. The approach prevents potential errors during tensor reshaping operations in the data collator while preserving all available training data.
A few observations:
- The warning message provides good visibility into potentially problematic data items
- Setting target_mask to all zeros ensures these inputs don't contribute to the loss function (since they have no target outputs)
- This is a graceful fallback that maintains dataset integrity without skipping samples
Consider enhancing the warning message with more context about the specific conversation structure:
- logger.warning(f"Dataset item {index} has no assistant response. Using input buffer.") + logger.warning(f"Dataset item {index} has no assistant response (roles present: {[conv['role'] for conv in conversations]}). Using input buffer.")
for more information, see https://pre-commit.ci
input_bufferfor dataset items without an "assistant" role, ensuring non-emptyinput_idsandtarget_mask.Summary by CodeRabbit
Bug Fixes
New Features
Chores