From 0eeb7732f712f34756a70cc7699b9fad29f32c60 Mon Sep 17 00:00:00 2001 From: "yuze.zyz" Date: Fri, 27 Sep 2024 16:33:44 +0800 Subject: [PATCH] fix regex --- modelscope/preprocessors/templates/loader.py | 10 +++++----- tests/tools/test_to_ollama.py | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modelscope/preprocessors/templates/loader.py b/modelscope/preprocessors/templates/loader.py index 3b04444d..e4a329a6 100644 --- a/modelscope/preprocessors/templates/loader.py +++ b/modelscope/preprocessors/templates/loader.py @@ -53,14 +53,14 @@ template_info = [ TemplateInfo( template=TemplateType.llama3, template_regex= - f'.*{cases("llama3", "llama-3-")}{no_multi_modal()}.*{chat_suffix}.*', + f'.*{cases("llama3", "llama-3")}{no_multi_modal()}.*{chat_suffix}.*', modelfile_link= 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama-3.modelfile', ), TemplateInfo( template=TemplateType.llama, template_regex= - f'{cases("llama", "llama-2-", "mistral", "codestral", "mixtral")}{no_multi_modal()}.*{chat_suffix}.*' + f'.*{cases("llama2", "llama-2", "mistral", "codestral", "mixtral")}{no_multi_modal()}.*{chat_suffix}.*' ), # qwen @@ -74,7 +74,7 @@ template_info = [ # codeqwen1.5 TemplateInfo( template_regex= - f'.*{cases("codeqwen1.5", "codeqwen-1.5-")}.*{chat_suffix}.*', + f'.*{cases("codeqwen1.5", "codeqwen-1.5")}.*{chat_suffix}.*', modelfile_link= 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codeqwen1.5.modelfile', ), @@ -217,7 +217,7 @@ template_info = [ TemplateInfo( template=TemplateType.gemma, template_regex= - f'{no("pali")}.*{cases("gemma2", "gemma-2-")}.*{chat_suffix}.*', + f'{no("pali")}.*{cases("gemma2", "gemma-2")}.*{chat_suffix}.*', modelfile_link= 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gemma2.modelfile', ), @@ -226,7 +226,7 @@ template_info = [ TemplateInfo( template=TemplateType.phi3, template_regex= - f'.*{cases("phi3", "phi-3-")}{no_multi_modal()}.*{chat_suffix}.*', + f'.*{cases("phi3", "phi-3")}{no_multi_modal()}.*{chat_suffix}.*', modelfile_link= 'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi3.modelfile', ), diff --git a/tests/tools/test_to_ollama.py b/tests/tools/test_to_ollama.py index 24dbe9d3..aaf5f4d0 100644 --- a/tests/tools/test_to_ollama.py +++ b/tests/tools/test_to_ollama.py @@ -81,6 +81,14 @@ class TestToOllama(unittest.TestCase): @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') def test_load_ollama(self): + ollama = TemplateLoader.to_ollama( + 'LLM-Research/Meta-Llama-3.1-8B-Instruct-GGUF') + self.assertTrue(ollama is not None) + ollama = TemplateLoader.to_ollama( + 'QuantFactory/Gemma-2-Ataraxy-9B-Chat-GGUF') + self.assertTrue(ollama is not None) + ollama = TemplateLoader.to_ollama('Xorbits/Llama-2-7b-Chat-GGUF') + self.assertTrue(ollama is not None) ollama = TemplateLoader.to_ollama( 'AI-ModelScope/gemma2-2b-instruct-GGUF') self.assertTrue(ollama is not None)