-
Notifications
You must be signed in to change notification settings - Fork 1.8k
⏩ Train on completion only #3329
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
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Suggestion to update the DataCollator example to:
given that |
def test_train_model_wrong_torch_dtype(self): | ||
# Get the dataset | ||
dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") | ||
|
||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
# Initialize the trainer | ||
training_args = SFTConfig(output_dir=tmp_dir, model_init_kwargs={"torch_dtype": -1}, report_to="none") | ||
with self.assertRaises(ValueError) as context: | ||
SFTTrainer( | ||
model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset | ||
) | ||
self.assertIn( | ||
"Invalid `torch_dtype` passed to `SFTConfig`. Expected either 'auto' or a string representing " | ||
"a `torch.dtype` (e.g., 'float32'), but got -1.", | ||
str(context.exception), | ||
) | ||
|
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.
This is not related to the core change of this PR.
With the new serialisation logic of TrainingArguments
, passing a wrong dtype fails when you instantiate the TrainingArguments
. There is no need for such test anymore
# If the dataset is prompt-completion, convert it to language modeling type | ||
first_example = next(iter(dataset)) | ||
if "prompt" in first_example.keys() and "completion" in first_example.keys(): | ||
key = "messages" if is_conversational(first_example) else "text" | ||
|
||
def concat_prompt_completion(example): | ||
return {key: example["prompt"] + example["completion"]} | ||
|
||
dataset = dataset.map(concat_prompt_completion, remove_columns=["prompt", "completion"]) | ||
|
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.
This concatenation needs to be removed, as we loses the information about where the completion starts. This completion is now managed in tokenize
.
Thanks! Done in 7f7f2a4 |
What does this PR do?
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.