From 21829b5eaf3484a75b04329b05b3a16128bdbc17 Mon Sep 17 00:00:00 2001 From: Akshat Sehgal <34078596+akshatsehgal@users.noreply.github.com> Date: Sat, 31 May 2025 01:29:01 -0700 Subject: [PATCH] [model] add smollm2 support (#8220) --- src/llamafactory/data/template.py | 16 ++++++++++++++++ src/llamafactory/extras/constants.py | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/llamafactory/data/template.py b/src/llamafactory/data/template.py index c64734ef..701cd239 100644 --- a/src/llamafactory/data/template.py +++ b/src/llamafactory/data/template.py @@ -1693,6 +1693,22 @@ register_template( ) +register_template( + name="smollm2", + format_system=StringFormatter( + slots=["<|im_start|>system\n{{content}}<|im_end|>\n"] + ), + format_user=StringFormatter( + slots=["<|im_start|>user\n{{content}}<|im_end|>\n<|im_start|>assistant\n"] + ), + format_assistant=StringFormatter( + slots=["{{content}}<|im_end|>\n"] + ), + stop_words=["<|im_end|>"], + default_system="You are a helpful AI assistant named SmolLM, trained by Hugging Face.", +) + + register_template( name="solar", format_user=StringFormatter(slots=["### User:\n{{content}}\n\n### Assistant:\n"]), diff --git a/src/llamafactory/extras/constants.py b/src/llamafactory/extras/constants.py index fcfd7836..11b3319e 100644 --- a/src/llamafactory/extras/constants.py +++ b/src/llamafactory/extras/constants.py @@ -2765,6 +2765,13 @@ register_model_group( DownloadSource.DEFAULT: "HuggingFaceTB/SmolLM-1.7B-Instruct", DownloadSource.MODELSCOPE: "HuggingFaceTB/SmolLM-1.7B-Instruct", }, + }, + template="smollm", +) + + +register_model_group( + models={ "SmolLM2-135M": { DownloadSource.DEFAULT: "HuggingFaceTB/SmolLM2-135M", DownloadSource.MODELSCOPE: "HuggingFaceTB/SmolLM2-135M", @@ -2790,7 +2797,7 @@ register_model_group( DownloadSource.MODELSCOPE: "HuggingFaceTB/SmolLM2-1.7B-Instruct", }, }, - template="smollm", + template="smollm2", )