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.

Update save.py

Daniel Han5bd7d3640f86
diff --git a/unsloth/save.py b/unsloth/save.py
index 7f523faadc0..dce30c4c717 100644
--- a/unsloth/save.py
+++ b/unsloth/save.py
@@ -1485,9 +1485,23 @@ def create_ollama_modelfile(tokenizer, gguf_location):
modelfile = getattr(tokenizer, "_ollama_modelfile", None)
if modelfile is None: return None
+ FILE_LOCATION_REPLACER = "⚫@✅#🦥__FILE_LOCATION__⚡@🦥#⛵"
+ EOS_TOKEN_REPLACER = "⚫@✅#🦥__EOS_TOKEN__⚡@🦥#⛵"
+ LEFT_BRACKET_REPLACER = "⚫@✅#🦥"
+ RIGHT_BRACKET_REPLACER = "⚡@🦥#⛵"
+
+ # Fixes https://github.com/unslothai/unsloth/issues/1087
+ # We must convert all {'s and }'s but keep {__FILE_LOCATION__} intact
+ modelfile = modelfile\
+ .replace("{__FILE_LOCATION__}", FILE_LOCATION_REPLACER)\
+ .replace("{__EOS_TOKEN__}", EOS_TOKEN_REPLACER)\
+ .replace("{", LEFT_BRACKET_REPLACER)\
+ .replace("}", RIGHT_BRACKET_REPLACER)
+
+ # Revert {__FILE_LOCATION__} back
modelfile = modelfile\
- .replace("{{", "⚫@✅#🦥")\
- .replace("}}", "⚡@🦥#⛵")
+ .replace(FILE_LOCATION_REPLACER, "{__FILE_LOCATION__}")\
+ .replace(EOS_TOKEN_REPLACER, "{__EOS_TOKEN__}")
if "__EOS_TOKEN__" in modelfile:
modelfile = modelfile.format(
@@ -1501,8 +1515,8 @@ def create_ollama_modelfile(tokenizer, gguf_location):
pass
modelfile = modelfile\
- .replace("⚫@✅#🦥", "{{")\
- .replace("⚡@🦥#⛵", "}}")\
+ .replace("⚫@✅#🦥", "{")\
+ .replace("⚡@🦥#⛵", "}")\
.rstrip()
return modelfile