Skip to content

On train_on_responses_only #867

Closed
Closed

Description

@Oseltamivir

The colabs/CLI script does not train models on conversation, I.E. given a prompt, train only on response.
Instead, the current code trains the model on the prompt as well. This leads to some problems in certain FT cases (e.g. RAFT)

There is a note in the colab: [NOTE] To train only on completions (ignoring the user's input) read TRL's docs here.

But I think that training on completions only is the more helpful option for most people, and should be the default.

EDIT: Just saw the train_on_responses_only feature. May I ask why not use TRL's DataCollator as per the TRL docs? instead of rewriting the masking code?

Activity

  1. changed the title [-]Script/Colab NOT training on conversation[/-] [+]Script/Colab not training on conversation, ambiguous wording [/+] on Aug 3, 2024
  2. changed the title [-]Script/Colab not training on conversation, ambiguous wording [/-] [+]Script/Colab not training on conversation, CompletionsOnly script[/+] on Aug 3, 2024
  3. changed the title [-]Script/Colab not training on conversation, CompletionsOnly script[/-] [+]On train_on_responses_only[/+] on Aug 3, 2024
  4. Oseltamivir commented on Aug 3, 2024

    @Oseltamivir
    ContributorAuthor

    After poking and playing with _train_on_responses_only, it seems like it

    1. Requires instruction_ids to come after response_ids, which seems strange as the given alpaca prompt has the instruction before the response
    2. Masks both sides of the response (the response IDs and the instruction IDs)

    I'm not sure why the instruction IDs are even required, shouldnt everything up to the last token of response ID be masked? thats what TRL does.

  5. danielhanchen commented on Aug 4, 2024

    @danielhanchen
    Member

    TRL's Data Collator does not work on multiple conversations, and only works on 1 conversation.

  6. Oseltamivir commented on Aug 6, 2024

    @Oseltamivir
    ContributorAuthor

    Ok, I'll try to see how I can add on to the current code.

  7. danielhanchen commented on Sep 6, 2026

    @danielhanchen
    Member

    Only assistant spans get unmasked, multi turn is handled with one span per assistant turn, and the instruction / response markers auto detect from the chat template now so you don't have to pass them. We decided against making it the default, hope that's ok!

    Please update Unsloth: uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir (if it's not in the current release yet it'll be in the next one). Reopen if it still happens!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions