{"record":{"id":"1dc03af6fe96d9ad","repo":"unslothai/unsloth","slug":"unknown-completion-masking-template-dataset-temp","errorCode":null,"errorMessage":"Unknown completion masking template: {dataset_template}","messagePattern":"Unknown completion masking template: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/datasets/completion_masking.py","lineNumber":83,"sourceCode":"    the run instead of silently changing the training objective.\n    \"\"\"\n    if notify is None:\n        notify = lambda level, message: None\n    kwargs = {}\n    if num_proc is not None:\n        kwargs[\"num_proc\"] = num_proc\n\n    processor = getattr(trainer, \"processing_class\", None) or getattr(trainer, \"tokenizer\", None)\n    if type(processor).__name__ == \"TokenizerWrapper\":\n        wrapped = getattr(processor, \"_tokenizer\", None)\n        if wrapped is not None:\n            processor = wrapped\n    inner = getattr(processor, \"tokenizer\", processor)\n\n    if dataset_template is not None:\n        markers = TEMPLATE_TO_RESPONSES_MAPPER.get(dataset_template)\n        if not markers:\n            raise ValueError(f\"Unknown completion masking template: {dataset_template}\")\n        has_preset_markers = hasattr(inner, \"_unsloth_input_part\") and hasattr(\n            inner, \"_unsloth_output_part\"\n        )\n        if has_preset_markers:\n            previous_instruction = inner._unsloth_input_part\n            previous_response = inner._unsloth_output_part\n            inner._unsloth_input_part = markers[\"instruction\"]\n            inner._unsloth_output_part = markers[\"response\"]\n            try:\n                trainer = train_fn(trainer, **kwargs)\n            finally:\n                inner._unsloth_input_part = previous_instruction\n                inner._unsloth_output_part = previous_response\n        else:\n            trainer = train_fn(\n                trainer,\n                instruction_part = markers[\"instruction\"],\n                response_part = markers[\"response\"],","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/datasets/completion_masking.py#L65-L101","documentation":"ValueError from apply_completion_masking when an explicit dataset_template is passed but is not a key in TEMPLATE_TO_RESPONSES_MAPPER (the manual marker table in model_mappings). The explicit template bypasses tokenizer marker detection, so an unknown name cannot be silently ignored — masking would target the wrong tokens, so it raises instead. Note the lookup is truthiness-based, so an empty-string template also lands here.","triggerScenarios":"Calling apply_completion_masking(..., dataset_template='chatml-qwen2') when the table only knows names like those registered in model_mappings.TEMPLATE_TO_RESPONSES_MAPPER; also dataset_template='' (falsy markers).","commonSituations":"Typos in template names from UI dropdowns or config files; version skew where the table was renamed between releases; passing a model name instead of a template name; forwarding a user free-text field without validation.","solutions":["Use a template name that exists as a key in model_mappings.TEMPLATE_TO_RESPONSES_MAPPER — inspect its keys to get the exact spelling","Pass dataset_template=None to fall back to tokenizer marker auto-detection with the manual model-table fallback","Validate the value against TEMPLATE_TO_RESPONSES_MAPPER at the API/config boundary before it reaches training"],"exampleFix":"# before\napply_completion_masking(trainer, model, train_fn, dataset_template='qwen-chat')  # typo\n\n# after\nfrom .model_mappings import TEMPLATE_TO_RESPONSES_MAPPER\nif dataset_template is not None and dataset_template not in TEMPLATE_TO_RESPONSES_MAPPER:\n    raise ValueError(f\"template must be one of {sorted(TEMPLATE_TO_RESPONSES_MAPPER)}\")\napply_completion_masking(trainer, model, train_fn, dataset_template=dataset_template)","handlingStrategy":"validation","validationCode":"from studio.backend.utils.datasets.model_mappings import TEMPLATE_TO_RESPONSES_MAPPER\n\ndef is_known_template(name: str | None) -> bool:\n    return name is None or name in TEMPLATE_TO_RESPONSES_MAPPER","typeGuard":"def known_templates() -> list[str]:\n    return sorted(TEMPLATE_TO_RESPONSES_MAPPER)","tryCatchPattern":null,"preventionTips":["Validate dataset_template against TEMPLATE_TO_RESPONSES_MAPPER at the config/UI boundary","Prefer dataset_template=None (auto-detect) unless you know the dataset is pre-rendered","Empty string is NOT 'no template' — normalize '' to None before passing it in"],"tags":["training","completion-masking","configuration","validation"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}