From dd86a4df3781959c4b9c6778095f64beadd6ec70 Mon Sep 17 00:00:00 2001 From: Christian Medina <37550954+cmedinasoriano@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:39:21 -0400 Subject: [PATCH] fix: rename dataset column to 'text' for SFTTrainer compatibility --- train.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/train.py b/train.py index dd127ae..54a57fa 100644 --- a/train.py +++ b/train.py @@ -140,13 +140,19 @@ def train(config_path): text_column = config["dataset"][0].get("text_column", "text") print(f"Using text column: {text_column}") + # Rename column to 'text' if needed (SFTTrainer expects 'text') + if text_column != "text": + print(f" Renaming '{text_column}' column to 'text'...") + dataset["train"] = dataset["train"].rename_column(text_column, "text") + if "test" in dataset and dataset["test"] is not None: + dataset["test"] = dataset["test"].rename_column(text_column, "text") + trainer = SFTTrainer( model=model, processing_class=tokenizer, train_dataset=dataset["train"], eval_dataset=dataset.get("test"), args=training_args, - dataset_text_field=text_column, ) # Train