Skip to content

📜 Add chat_template_path parameter to SFTConfig #3599

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

Merged
merged 16 commits into from
Jun 20, 2025

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Jun 16, 2025

Take the chat template from "Qwen/Qwen3-4B" to train a tiny GPTNeoX model:

from datasets import load_dataset
from trl import SFTConfig, SFTTrainer

dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train")
training_args = SFTConfig(chat_template_path="Qwen/Qwen3-4B")
trainer = SFTTrainer(
    model="trl-internal-testing/tiny-GPTNeoXForCausalLM",  # trl-internal-testing/tiny-GPTNeoXForCausalLM doesn't have a chat template set by default
    args=training_args,
    train_dataset=dataset
)
trainer.train()

or from a path:

training_args = SFTConfig(chat_template_path="path_to_template.jinja")

@qgallouedec qgallouedec changed the title Add chat_template parameter to SFTConfig and integrate clone_chat_tem… Add chat_template_source parameter to SFTConfig Jun 16, 2025
@qgallouedec qgallouedec marked this pull request as ready for review June 16, 2025 08:44
@HuggingFaceDocBuilderDev

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.

@qgallouedec qgallouedec requested a review from cmpatino June 16, 2025 10:08
@qgallouedec qgallouedec changed the title Add chat_template_source parameter to SFTConfig 📜 Add chat_template_source parameter to SFTConfig Jun 18, 2025
@qgallouedec qgallouedec changed the title 📜 Add chat_template_source parameter to SFTConfig 📜 Add chat_template_path parameter to SFTConfig Jun 20, 2025
@qgallouedec qgallouedec merged commit 67f17f7 into main Jun 20, 2025
11 checks passed
@qgallouedec qgallouedec deleted the sft-chat-template-arg branch June 20, 2025 12:15
marcandrelarochelle pushed a commit to marcandrelarochelle/trl that referenced this pull request Jul 29, 2025
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

Successfully merging this pull request may close these issues.

4 participants