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: keep a system column when the advisor mapping carries metadata (#14999)
Vineeth Sai Varikuntlaecf0054bb5dc
diff --git a/studio/backend/tests/test_alpaca_ai_assist_mapping.py b/studio/backend/tests/test_alpaca_ai_assist_mapping.pyindex dcab1c7e10d..ac6f6b1d29e 100644--- a/studio/backend/tests/test_alpaca_ai_assist_mapping.py+++ b/studio/backend/tests/test_alpaca_ai_assist_mapping.py@@ -140,3 +140,49 @@ def test_chatml_advisor_mapping_renders_list_cells_as_text():assert result["final_format"] == "chatml_conversations", result["warnings"]assert [convo[-1]["content"] for convo in result["dataset"]["conversations"]] == ["0", "1, 2"]+++def test_chatml_advisor_mapping_keeps_a_system_column():+ result = format_dataset(+ Dataset.from_dict({"persona": ["Be a pirate.", ""], "text": ["hi", "yo"], "label": [1, 0]}),+ format_type = "chatml",+ batch_size = 2,+ custom_format_mapping = {+ "persona": "system",+ "text": "user",+ "label": "assistant",+ "__label_mapping": LABEL_MAPPING,+ },+ )++ assert result["final_format"] == "chatml_conversations", result["warnings"]+ assert list(result["dataset"]["conversations"]) == [+ [+ {"role": "system", "content": "Be a pirate."},+ {"role": "user", "content": "hi"},+ {"role": "assistant", "content": "pos"},+ ],+ [+ {"role": "user", "content": "yo"},+ {"role": "assistant", "content": "neg"},+ ],+ ]+++def test_chatml_advisor_mapping_puts_the_system_prompt_before_a_system_column():+ result = format_dataset(+ Dataset.from_dict({"persona": ["Be a pirate."], "text": ["hi"], "label": [1]}),+ format_type = "chatml",+ batch_size = 1,+ custom_format_mapping = {+ "persona": "system",+ "text": "user",+ "label": "assistant",+ "__system_prompt": PROMPT,+ },+ )++ assert result["dataset"]["conversations"][0][0] == {+ "role": "system",+ "content": f"{PROMPT}\n\nBe a pirate.",+ }diff --git a/studio/backend/utils/datasets/dataset_utils.py b/studio/backend/utils/datasets/dataset_utils.pyindex b853403c6fd..c75e35c534d 100644--- a/studio/backend/utils/datasets/dataset_utils.py+++ b/studio/backend/utils/datasets/dataset_utils.py@@ -265,11 +265,11 @@ def _apply_template_mapping(meta: dict,batch_size: int = 1000,):- """Apply advisor-driven mapping for non-conversational datasets: groups columns by assigned role (user/assistant), concatenates values within each role into one message, and injects an optional system prompt. Label mapping converts integer labels to human-readable strings. Returns a dataset with a single 'conversations' column."""+ """Apply advisor-driven mapping for non-conversational datasets: groups columns by assigned role (system/user/assistant), concatenates values within each role into one message, and injects an optional system prompt ahead of any system column. Label mapping converts integer labels to human-readable strings. Returns a dataset with a single 'conversations' column."""system_prompt = meta.get("__system_prompt", "")label_mapping = meta.get("__label_mapping", {}) # {col: {int_str: label_str}}- role_groups: dict[str, list[str]] = {"user": [], "assistant": []}+ role_groups: dict[str, list[str]] = {"system": [], "user": [], "assistant": []}for col, role in column_roles.items():canonical = _TO_CHATML.get(role, role)if canonical in role_groups:@@ -289,8 +289,17 @@ def _apply_template_mapping(for i in range(num):convo = []- if system_prompt:- convo.append({"role": "system", "content": system_prompt})+ # The system prompt leads, then system columns, so neither is dropped.+ system_parts = [+ _extract_column_value(examples[col][i], col, label_mapping)+ for col in role_groups["system"]+ if col in examples+ ]+ system_text = "\n\n".join(+ part for part in (system_prompt, "\n".join(p for p in system_parts if p)) if part+ )+ if system_text:+ convo.append({"role": "system", "content": system_text})user_parts = []for col in role_groups["user"]: