Tokenizer.apply_chat_template vs formatting_func

From what I understand from https://huggingface.co/docs/transformers/main/en/chat_templating#what-are-generation-prompts, tokenizer.apply_chat_template serves exactly the same role as

def formatting_prompts_func(example):
    output_texts = []
    for i in range(len(example['question'])):
        text = f"### Question: {example['question'][i]}\n ### Answer: {example['answer'][i]}"
        output_texts.append(text)
    return output_texts

in Supervised Fine-tuning Trainer. Is my understanding correct? If not, what are some of their differences?

1 Like