Skip to content
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

Train on completions only by fixing the collator inquiry #1396

Open
hessaAlawwad opened this issue Dec 7, 2024 · 1 comment
Open

Train on completions only by fixing the collator inquiry #1396

hessaAlawwad opened this issue Dec 7, 2024 · 1 comment

Comments

@hessaAlawwad
Copy link

Hello,

I was wondering if I would be able to use the DataCollatorForCompletionOnlyLM to train Llama 3.2 vision model on the generated prompts only?
Something like passing a response template and the tokenizer in this code:

response_template = " ### Answer:"
collator = DataCollatorForCompletionOnlyLM(response_template, tokenizer=tokenizer)

I see that in the provided code they are using data_collator = UnslothVisionDataCollator(model, tokenizer) and indicating it is a must use. So can I see it and edit to serve my purpose of training which is computing the loss only on the generated token?

@danielhanchen
Copy link
Contributor

Apologies on the delay! Oh you're better off using our conversational notebook which masks instructions out - https://colab.research.google.com/drive/1T5-zKWM_5OD21QHwXHiV9ixTRR7k3iB9?usp=sharing

from unsloth.chat_templates import train_on_responses_only
trainer = train_on_responses_only(
    trainer,
    instruction_part = "<|start_header_id|>user<|end_header_id|>\n\n",
    response_part = "<|start_header_id|>assistant<|end_header_id|>\n\n",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants