Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: end plain-text training rows with EOS when Format is Auto (#17255)
Nilay58973e8d538c
diff --git a/studio/backend/tests/test_plain_text_dataset.py b/studio/backend/tests/test_plain_text_dataset.pyindex 8d52d8728bb..d90fc4992b6 100644--- a/studio/backend/tests/test_plain_text_dataset.py+++ b/studio/backend/tests/test_plain_text_dataset.py@@ -5,6 +5,7 @@import sysfrom pathlib import Path+from types import SimpleNamespaceimport pytestfrom datasets import Dataset@@ -15,7 +16,7 @@ if str(_BACKEND_ROOT) not in sys.path:from hub.utils import dataset_format # noqa: E402from utils.datasets import format_detection # noqa: E402-from utils.datasets.dataset_utils import format_dataset # noqa: E402+from utils.datasets.dataset_utils import format_and_template_dataset, format_dataset # noqa: E402def _text_dataset(column: str = "text"):@@ -115,3 +116,45 @@ def test_auto_leaves_a_mapped_dataset_alone():)assert info["final_format"] != "raw_text"++[email protected]("column", ["text", "content"], ids = ["text", "content"])+def test_auto_raw_text_rows_end_in_eos(column):+ tokenizer = SimpleNamespace(eos_token = "</s>")+ train = format_and_template_dataset(+ _text_dataset(column), model_name = "unsloth/test", tokenizer = tokenizer+ )+ eval_split = format_and_template_dataset(+ _text_dataset(column),+ model_name = "unsloth/test",+ tokenizer = tokenizer,+ split_name = "eval",+ raw_text_column = train["raw_text_column"],+ )++ for info in (train, eval_split):+ assert info["final_format"] == "raw_text"+ assert info["dataset"]["text"] == [+ "## What happened\nWrote the fix.</s>",+ "## What happened\nReviewed the diff.</s>",+ ]+++def test_auto_raw_text_reads_eos_from_a_processors_tokenizer():+ processor = SimpleNamespace(tokenizer = SimpleNamespace(eos_token = "<|im_end|>"))+ info = format_and_template_dataset(+ _text_dataset(), model_name = "unsloth/test", tokenizer = processor+ )++ assert all(text.endswith("<|im_end|>") for text in info["dataset"]["text"])+++def test_explicit_raw_leaves_eos_to_the_trainer():+ info = format_and_template_dataset(+ _text_dataset(),+ model_name = "unsloth/test",+ tokenizer = SimpleNamespace(eos_token = "</s>"),+ format_type = "raw",+ )++ assert not any(text.endswith("</s>") for text in info["dataset"]["text"])diff --git a/studio/backend/utils/datasets/dataset_utils.py b/studio/backend/utils/datasets/dataset_utils.pyindex a037cb43aa0..5813ca9d1e7 100644--- a/studio/backend/utils/datasets/dataset_utils.py+++ b/studio/backend/utils/datasets/dataset_utils.py@@ -442,13 +442,23 @@ def _format_dataset(multimodal_info = detect_multimodal_dataset(dataset)- if format_type == "auto" and not custom_format_mapping and is_plain_text_dataset(dataset):+ auto_raw = (+ format_type == "auto" and not custom_format_mapping and is_plain_text_dataset(dataset)+ )+ if auto_raw:# Matches the preview's "raw" verdict; auto would otherwise fail as "unknown".format_type = "raw"if format_type == "raw":+ # Explicit "raw" already gets EOS from the trainer / MLXTrainingConfig.append_eos.raw_result = prepare_raw_text_dataset(- dataset, split_name = split_name, text_column = raw_text_column+ dataset,+ split_name = split_name,+ # A processor without Unsloth's patch (MLX VLM) keeps eos_token on its inner tokenizer.+ eos_token = getattr(tokenizer, "eos_token", None)+ or getattr(getattr(tokenizer, "tokenizer", None), "eos_token", None),+ append_eos = auto_raw,+ text_column = raw_text_column,)return {"dataset": raw_result.dataset,