-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Add multi-turn SFT support #195
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
feat: Add multi-turn SFT support #195
Conversation
- Add MultiTurnSFTDataset class for handling multi-turn conversations - Support different roles (system, user, assistant) with role-specific prefixes - Set loss mask to 1 for assistant responses only - Add comprehensive test suite for the new dataset class
- Replace custom chat formatting with HuggingFace chat template - Use Qwen tokenizer for testing - Fix tensor indexing and loss mask generation - Update test to verify proper tokenization
- Use HuggingFace chat template instead of custom formatting - Add comprehensive tests for loss mask behavior - Verify both assistant and non-assistant content - Add debug output for test failures
- Add separate workflow for unit tests - Run tests in tests/soft directory - Generate and upload coverage reports - Use same container as e2e tests
- Move tests from tests/soft to tests/sft/unit for consistency - Update CI workflow paths - Keep all SFT-related tests under tests/sft
- Update trainer to support both single-turn and multi-turn datasets - Add example script for multi-turn training - Add data preprocessing script for multi-turn conversations - Use proper chat template for multi-turn data
- Add use_multiturn flag (default: false) - Add messages_key for multi-turn mode (default: messages) - Group single-turn and multi-turn settings
- Add OpenHands SFT dataset preprocessing script - Add token length limit (32k) for conversations - Move multi-turn example to tests/sft - Add train/test split and statistics
Actually i think this PR is ready. I've been using this PR for a while and trained couple model without issue. Would love review here! Also, do we really need to sign CLA for openhands-agent? 🤣 |
Oh sorry I missed this PR. Will take a look |
Sorry! Must be some copy-pasta :( @OpenHands can you help me first merge from main - then help me address these review comments? |
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.
one last comment. otherwise looks good to me!
Is there any benchmark result you want to share on specific datasets? |
Could u merge main for a fix of megatron tests. And also fix lint with format.sh? |
@eric-haibin-lin Actually, OpenHands LM 32B was trained using this PR :) https://www.all-hands.dev/blog/introducing-openhands-lm-32b----a-strong-open-coding-agent-model |
Multi-turn Conversation Fine-tuning Support
Overview
This PR adds support for fine-tuning models on multi-turn conversations, including proper chat template handling and loss masking for assistant responses. The implementation includes support for the OpenHands SFT dataset and handles conversations up to 32k tokens.
Key Features
MultiTurnSFTDataset
class for handling multi-turn conversationsapply_chat_template
Implementation Details
Dataset:
Training:
use_multiturn
flag in configmessages_key
for multi-turn data formatExamples and Tests:
Usage Example
##Testing
Documentation
ok.. this is another PR mostly done by OpenHands with me messaging it about 10 times..
It is still WIP as I'm testing it on a training job now, will report back if it works