diff --git a/modelscope/preprocessors/templates/loader.py b/modelscope/preprocessors/templates/loader.py index 58838a1e..5a20bac7 100644 --- a/modelscope/preprocessors/templates/loader.py +++ b/modelscope/preprocessors/templates/loader.py @@ -54,6 +54,12 @@ def no_multi_modal(): # Order matters template_info = [ # llama + TemplateInfo( + template_regex= + f'.*{cases("llama4", "llama-4")}.*', + modelfile_prefix= + 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama4', + ), ## "llama3" TemplateInfo( template_regex= @@ -154,11 +160,15 @@ template_info = [ # qwen TemplateInfo( - template=TemplateType.qwen, template_regex=f'.*{cases("qwen3")}{no_multi_modal()}.*', modelfile_prefix= 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen3', ), + TemplateInfo( + template_regex=f'.*{cases("qwen2.5")}.*{cases("vl")}.*', + modelfile_prefix= + 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2.5vl', + ), TemplateInfo( template=TemplateType.qwen, template_regex=f'.*{cases("qwen2.5")}.*{cases("coder")}.*{chat_suffix}.*', @@ -249,6 +259,18 @@ template_info = [ 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin3'), # "phi" + TemplateInfo( + template_regex= + f'.*{cases("phi-4-reasoning")}.*', + modelfile_prefix= + 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4-reasoning', + ), + TemplateInfo( + template_regex= + f'.*{cases("phi-4-mini-reasoning")}.*', + modelfile_prefix= + 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4-mini-reasoning', + ), TemplateInfo( template_regex= f'.*{cases("llava-phi3", "llava-phi-3")}.*', diff --git a/tests/tools/test_to_ollama.py b/tests/tools/test_to_ollama.py index 14d35142..60405194 100644 --- a/tests/tools/test_to_ollama.py +++ b/tests/tools/test_to_ollama.py @@ -122,6 +122,18 @@ class TestToOllama(unittest.TestCase): @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') def test_check_template_type(self): + _test_check_tmpl_type( + 'unsloth/Qwen2.5-VL-3B-Instruct-GGUF', + 'qwen2.5vl', + gguf_meta={'general.name': 'Qwen2.5-Vl-3B-Instruct'}) + _test_check_tmpl_type( + 'unsloth/Phi-4-reasoning-GGUF', + 'phi4-reasoning', + gguf_meta={'general.name': 'Phi-4-Reasoning-Plus'}) + _test_check_tmpl_type('unsloth/Phi-4-mini-reasoning-GGUF', + 'phi4-mini-reasoning') + _test_check_tmpl_type('unsloth/Llama-4-Scout-17B-16E-Instruct-GGUF', + 'llama4') _test_check_tmpl_type( 'unsloth/Qwen3-32B-GGUF', 'qwen3',