Do I need to apply_chat_template before Supervised Fine-tuning Gemma-1.1-7b-it?

#19
by Syax19 - opened

I'm a novice in training LLM for the first time and would greatly appreciate any assistance.

I noticed that in the "example_sft_qlora.py" script, there's a formatting function defined as:

def formatting_func(example):
    text = f"### USER: {example['data'][0]}\n### ASSISTANT: {example['data'][1]}"
    return text

I don't see any mention of applying apply_chat_template as using Gemma-1.1-7b-it model for inference.
Is it because supervised fine-tuning doesn't require using the original template?
Will my custom template which is like in the formatting_func overwrite original template during training, or do I need to modify the formatting_func to apply the original chat_template?

Looking forward for replying.
Thanks!

Google org

Hi @Syax19 , Supervised Fine tuning doesn't utilize the original chat template during inference. Hence, the custom template in formatting_func will not overwrite the original template. You can use your custom template for training without the need to modify formatting_func. If you want to apply the original chat template, you would need to modify the formatting_func to include the template. Alternatively, you can use the apply_chat_template utility provided by Gemma-1.1-7b-it to apply the template during inference.

Thanks for your help!

Sign up or log in to comment