Skip to content

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.

Re-apply #4939: updated models template mappers (#4950)

Roland Tannous800ddc95f845
diff --git a/studio/backend/utils/datasets/model_mappings.py b/studio/backend/utils/datasets/model_mappings.py
index 95b4791574f..7fcac637c68 100644
--- a/studio/backend/utils/datasets/model_mappings.py
+++ b/studio/backend/utils/datasets/model_mappings.py
@@ -215,6 +215,21 @@ TEMPLATE_TO_MODEL_MAPPER = {
"google/gemma-3n-E2B-it",
"unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit",
),
+ "gemma-4": (
+ "unsloth/gemma-4-E2B-it",
+ "google/gemma-4-E2B-it",
+ "unsloth/gemma-4-E4B-it",
+ "google/gemma-4-E4B-it",
+ "unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
+ "unsloth/gemma-4-E4B-it-unsloth-bnb-4bit",
+ ),
+ "gemma-4-thinking": (
+ "unsloth/gemma-4-26B-A4B-it",
+ "google/gemma-4-26B-A4B-it",
+ "unsloth/gemma-4-31B-it",
+ "unsloth/gemma-4-31B-it-unsloth-bnb-4bit",
+ "google/gemma-4-31B-it",
+ ),
"qwen2.5": (
"unsloth/Qwen2.5-0.5B-Instruct-unsloth-bnb-4bit",
"unsloth/Qwen2.5-0.5B-Instruct",
@@ -399,6 +414,15 @@ TEMPLATE_TO_MODEL_MAPPER = {
"THUDM/GLM-4.7-Flash",
"unsloth/GLM-4.7-Flash-bnb-4bit",
),
+ "lfm-2": (
+ "unsloth/LFM2-1.2B",
+ "LiquidAI/LFM2-1.2B",
+ "unsloth/LFM2-1.2B-unsloth-bnb-4bit",
+ ),
+ "lfm-2.5": (
+ "unsloth/LFM2.5-1.2B-Instruct",
+ "LiquidAI/LFM2.5-1.2B-Instruct",
+ ),
}
MODEL_TO_TEMPLATE_MAPPER = {}
@@ -414,6 +438,14 @@ for key, values in TEMPLATE_TO_MODEL_MAPPER.items():
TEMPLATE_TO_RESPONSES_MAPPER = {
+ "gemma-4-thinking": {
+ "instruction": "<|turn>user\n",
+ "response": "<|turn>model\n",
+ },
+ "gemma-4": {
+ "instruction": "<|turn>user\n",
+ "response": "<|turn>model\n",
+ },
"gemma-3": {
"instruction": "<start_of_turn>user\n",
"response": "<start_of_turn>model\n",
@@ -514,6 +546,10 @@ TEMPLATE_TO_RESPONSES_MAPPER = {
"instruction": "<|im_start|>user\n",
"response": "<|im_start|>assistant\n",
},
+ "lfm-2.5": {
+ "instruction": "<|im_start|>user\n",
+ "response": "<|im_start|>assistant\n",
+ },
"starling": {
"instruction": "GPT4 Correct User: ",
"response": "GPT4 Correct Assistant: ",
diff --git a/studio/backend/utils/transformers_version.py b/studio/backend/utils/transformers_version.py
index 0c13b5455ba..36c3a4c22dc 100644
--- a/studio/backend/utils/transformers_version.py
+++ b/studio/backend/utils/transformers_version.py
@@ -52,6 +52,7 @@ TRANSFORMERS_5_MODEL_SUBSTRINGS: tuple[str, ...] = (
"qwen3.5", # Qwen3.5 family (35B-A3B, etc.)
"qwen3-next", # Qwen3-Next and variants
"tiny_qwen3_moe", # imdatta0/tiny_qwen3_moe_2.8B_0.7B
+ "lfm2.5-vl-450m", # LiquidAI/LFM2.5-VL-450M
)
# Lowercase substrings for models that require transformers 5.5.0 (checked first).
diff --git a/unsloth/chat_templates.py b/unsloth/chat_templates.py
index 71f91cc8281..326fd592892 100644
--- a/unsloth/chat_templates.py
+++ b/unsloth/chat_templates.py
@@ -1716,6 +1716,8 @@ liquid_lfm2_template = \
liquid_lfm2_template_eos_token = "<|im_end|>"
CHAT_TEMPLATES["lfm-2"] = (liquid_lfm2_template, liquid_lfm2_template_eos_token, False, None)
DEFAULT_SYSTEM_MESSAGE["lfm-2"] = None # No system message in Phi-3
+CHAT_TEMPLATES["lfm-2.5"] = (liquid_lfm2_template, liquid_lfm2_template_eos_token, False, None)
+DEFAULT_SYSTEM_MESSAGE["lfm-2.5"] = None
# =========================================== Starling-LM
diff --git a/unsloth/models/mapper.py b/unsloth/models/mapper.py
index 8f2861db68f..57c1e292c3a 100644
--- a/unsloth/models/mapper.py
+++ b/unsloth/models/mapper.py
@@ -22,6 +22,39 @@ __all__ = [
__INT_TO_FLOAT_MAPPER = \
{
+ "unsloth/gemma-4-E2B-it-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-E2B-it",
+ "google/gemma-4-E2B-it",
+ ),
+ "unsloth/gemma-4-E4B-it-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-E4B-it",
+ "google/gemma-4-E4B-it",
+ ),
+ "unsloth/gemma-4-31B-it-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-31B-it",
+ "google/gemma-4-31B-it",
+ ),
+ "unsloth/gemma-4-26B-A4B-it" : (
+ "unsloth/gemma-4-26B-A4B-it",
+ "google/gemma-4-26B-A4B-it",
+ ),
+ "unsloth/gemma-4-E2B-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-E2B",
+ "google/gemma-4-E2B",
+ ),
+ "unsloth/gemma-4-E4B-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-E4B",
+ "google/gemma-4-E4B",
+ ),
+ "unsloth/gemma-4-31B-unsloth-bnb-4bit" : (
+ "unsloth/gemma-4-31B",
+ "google/gemma-4-31B",
+ ),
+ "unsloth/LFM2-1.2B-unsloth-bnb-4bit" : (
+ "unsloth/LFM2-1.2B",
+ "LiquidAI/LFM2-1.2B",
+ ),
+
"unsloth/mistral-7b-bnb-4bit" : (
"unsloth/mistral-7b",
"mistralai/Mistral-7B-v0.1",
@@ -1428,3 +1461,6 @@ for key, values in __INT_TO_FLOAT_MAPPER.items():
for value in values:
FLOAT_TO_INT_MAPPER[value.lower()] = lowered_key
+
+_add_with_lower(MAP_TO_UNSLOTH_16bit, "google/gemma-4-26B-A4B", "unsloth/gemma-4-26B-A4B")
+_add_with_lower(MAP_TO_UNSLOTH_16bit, "LiquidAI/LFM2.5-1.2B-Instruct", "unsloth/LFM2.5-1.2B-Instruct")
diff --git a/unsloth/ollama_template_mappers.py b/unsloth/ollama_template_mappers.py
index 728b08813a2..065165d5d79 100644
--- a/unsloth/ollama_template_mappers.py
+++ b/unsloth/ollama_template_mappers.py
@@ -1978,12 +1978,19 @@ OLLAMA_TEMPLATE_TO_MODEL_MAPPER = {
),
"gemma4": (
"unsloth/gemma-4-E2B-it",
+ "unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
+ "google/gemma-4-E2B-it",
"unsloth/gemma-4-E2B",
"unsloth/gemma-4-E4B-it",
+ "unsloth/gemma-4-E4B-it-unsloth-bnb-4bit",
+ "google/gemma-4-E4B-it",
"unsloth/gemma-4-E4B",
"unsloth/gemma-4-31B-it",
+ "unsloth/gemma-4-31B-it-unsloth-bnb-4bit",
+ "google/gemma-4-31B-it",
"unsloth/gemma-4-31B",
"unsloth/gemma-4-26B-A4B-it",
+ "google/gemma-4-26B-A4B-it",
"unsloth/gemma-4-26B-A4B",
),
"gemma3n": (