mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 12:10:09 +01:00
fix
This commit is contained in:
@@ -17,7 +17,7 @@ class TextGPT3GenerationTest(unittest.TestCase):
|
||||
self.model_dir_13B = snapshot_download(self.model_id_13B)
|
||||
self.input = '好的'
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
@unittest.skip('deprecated, skipped')
|
||||
def test_gpt3_1_3B(self):
|
||||
pipe = pipeline(
|
||||
Tasks.text_generation,
|
||||
@@ -25,7 +25,7 @@ class TextGPT3GenerationTest(unittest.TestCase):
|
||||
external_engine_for_llm=False)
|
||||
print(pipe(self.input))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
@unittest.skip('deprecated, skipped')
|
||||
def test_gpt3_1_3B_with_streaming(self):
|
||||
pipe = pipeline(
|
||||
Tasks.text_generation,
|
||||
@@ -35,7 +35,7 @@ class TextGPT3GenerationTest(unittest.TestCase):
|
||||
print(output, end='\r')
|
||||
print()
|
||||
|
||||
@unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
|
||||
@unittest.skip('deprecated, skipped')
|
||||
def test_gpt3_2_7B(self):
|
||||
pipe = pipeline(
|
||||
Tasks.text_generation,
|
||||
@@ -43,7 +43,7 @@ class TextGPT3GenerationTest(unittest.TestCase):
|
||||
external_engine_for_llm=False)
|
||||
print(pipe(self.input))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
@unittest.skip('deprecated, skipped')
|
||||
def test_gpt3_1_3B_with_args(self):
|
||||
pipe = pipeline(
|
||||
Tasks.text_generation,
|
||||
|
||||
@@ -141,37 +141,25 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_chatglm2(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='ZhipuAI/chatglm2-6b',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='ZhipuAI/chatglm2-6b')
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_chatglm2int4(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='ZhipuAI/chatglm2-6b-int4',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='ZhipuAI/chatglm2-6b-int4')
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_chatglm232k(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='ZhipuAI/chatglm2-6b-32k',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='ZhipuAI/chatglm2-6b-32k')
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_chatglm3(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='ZhipuAI/chatglm3-6b',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='ZhipuAI/chatglm3-6b')
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -182,8 +170,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model='modelscope/Llama-2-7b-ms',
|
||||
torch_dtype=torch.float16,
|
||||
device_map='auto',
|
||||
ignore_file_pattern=[r'.+\.bin$'],
|
||||
external_engine_for_llm=True)
|
||||
ignore_file_pattern=[r'.+\.bin$'])
|
||||
print('messages: ', pipe(self.messages_en, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_en, **self.gen_cfg))
|
||||
|
||||
@@ -195,8 +182,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
revision='v1.0.2',
|
||||
torch_dtype=torch.float16,
|
||||
device_map='auto',
|
||||
ignore_file_pattern=[r'.+\.bin$'],
|
||||
external_engine_for_llm=True)
|
||||
ignore_file_pattern=[r'.+\.bin$'])
|
||||
print('messages: ', pipe(self.messages_en, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_en, **self.gen_cfg))
|
||||
|
||||
@@ -207,8 +193,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model='AI-ModelScope/CodeLlama-7b-Instruct-hf',
|
||||
torch_dtype=torch.float16,
|
||||
device_map='auto',
|
||||
ignore_file_pattern=[r'.+\.bin$'],
|
||||
external_engine_for_llm=True)
|
||||
ignore_file_pattern=[r'.+\.bin$'])
|
||||
print('messages: ', pipe(self.messages_code, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_code, **self.gen_cfg))
|
||||
|
||||
@@ -218,8 +203,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/baichuan-7B',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -229,8 +213,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan-13B-Base',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -240,8 +223,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan-13B-Chat',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -251,8 +233,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-7B-Base',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -262,8 +243,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-7B-Chat',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -273,8 +253,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-7B-Chat-4bits',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -284,8 +263,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-13B-Chat-4bits',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
external_engine_for_llm=True)
|
||||
torch_dtype=torch.float16)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -296,8 +274,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model='AI-ModelScope/WizardLM-13B-V1.2',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
format_messages='wizardlm',
|
||||
external_engine_for_llm=True)
|
||||
format_messages='wizardlm')
|
||||
print('messages: ', pipe(self.messages_en, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_en, **self.gen_cfg))
|
||||
|
||||
@@ -308,8 +285,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model='AI-ModelScope/WizardMath-7B-V1.0',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
format_messages='wizardcode',
|
||||
external_engine_for_llm=True)
|
||||
format_messages='wizardcode')
|
||||
print('messages: ', pipe(self.message_wizard_math, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_wizard_math, **self.gen_cfg))
|
||||
|
||||
@@ -320,8 +296,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model='AI-ModelScope/WizardCoder-Python-13B-V1.0',
|
||||
device_map='auto',
|
||||
torch_dtype=torch.float16,
|
||||
format_messages='wizardcode',
|
||||
external_engine_for_llm=True)
|
||||
format_messages='wizardcode')
|
||||
print('messages: ', pipe(self.message_wizard_code, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_wizard_code, **self.gen_cfg))
|
||||
|
||||
@@ -337,28 +312,19 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_qwen(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='qwen/Qwen-7B-Chat',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='qwen/Qwen-7B-Chat')
|
||||
print('messages: ', pipe(self.messages_zh_with_system, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skip('Need optimum and auto-gptq')
|
||||
def test_qwen_int4(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='qwen/Qwen-7B-Chat-Int4',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='qwen/Qwen-7B-Chat-Int4')
|
||||
print('messages: ', pipe(self.messages_zh_with_system, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_qwen_vl(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='qwen/Qwen-VL-Chat',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='qwen/Qwen-VL-Chat')
|
||||
print('messages: ', pipe(self.messages_mm, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -368,27 +334,20 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
model_type = ModelTypeHelper.get(model_id)
|
||||
assert not LLMAdapterRegistry.contains(model_type)
|
||||
|
||||
pipe = pipeline(
|
||||
task='chat', model=model_id, external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model=model_id)
|
||||
print('messages: ', pipe(self.messages_zh, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_qwen_stream_gemerate(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='qwen/Qwen-7B-Chat',
|
||||
external_engine_for_llm=True)
|
||||
pipe = pipeline(task='chat', model='Qwen/Qwen-7B-Chat')
|
||||
for stream_output in pipe.stream_generate(self.messages_zh_with_system,
|
||||
**self.gen_cfg):
|
||||
print('messages: ', stream_output, end='\r')
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_qwen1_5_stream_gemerate(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='qwen/Qwen1.5-1.8B-Chat',
|
||||
external_engine_for_llm=True)
|
||||
def test_qwen1_5_stream_generate(self):
|
||||
pipe = pipeline(task='chat', model='Qwen/Qwen1.5-1.8B-Chat')
|
||||
for stream_output in pipe.stream_generate(self.messages_zh_with_system,
|
||||
**self.gen_cfg):
|
||||
print('messages: ', stream_output, end='\r')
|
||||
@@ -398,8 +357,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-13B-Chat',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
llm_framework='swift')
|
||||
print('messages: ', pipe(self.messages_zh_with_system, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -408,8 +366,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='baichuan-inc/Baichuan2-13B-Chat',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
llm_framework='swift')
|
||||
for stream_output in pipe.stream_generate(self.messages_zh,
|
||||
**self.gen_cfg):
|
||||
print('messages: ', stream_output, end='\r')
|
||||
@@ -417,20 +374,14 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_yi_with_swift(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='01ai/Yi-1.5-6B-Chat',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
task='chat', model='01ai/Yi-1.5-6B-Chat', llm_framework='swift')
|
||||
print('messages: ', pipe(self.messages_zh_with_system, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_yi_stream_gemerate(self):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='01ai/Yi-1.5-6B-Chat',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
task='chat', model='01ai/Yi-1.5-6B-Chat', llm_framework='swift')
|
||||
for stream_output in pipe.stream_generate(self.messages_zh,
|
||||
**self.gen_cfg):
|
||||
print('messages: ', stream_output, end='\r')
|
||||
@@ -440,8 +391,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='Shanghai_AI_Laboratory/internlm2-1_8b',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
llm_framework='swift')
|
||||
print('messages: ', pipe(self.messages_zh_one_round, **self.gen_cfg))
|
||||
print('prompt: ', pipe(self.prompt_zh, **self.gen_cfg))
|
||||
|
||||
@@ -450,8 +400,7 @@ class LLMPipelineTest(unittest.TestCase):
|
||||
pipe = pipeline(
|
||||
task='chat',
|
||||
model='Shanghai_AI_Laboratory/internlm2-1_8b',
|
||||
llm_framework='swift',
|
||||
external_engine_for_llm=True)
|
||||
llm_framework='swift')
|
||||
for stream_output in pipe.stream_generate(self.messages_zh_one_round,
|
||||
**self.gen_cfg):
|
||||
print('messages: ', stream_output, end='\r')
|
||||
|
||||
@@ -17,9 +17,7 @@ class MplugOwlMultimodalDialogueTest(unittest.TestCase):
|
||||
model = Model.from_pretrained(
|
||||
'damo/multi-modal_mplug_owl_multimodal-dialogue_7b')
|
||||
pipeline_multimodal_dialogue = pipeline(
|
||||
task=Tasks.multimodal_dialogue,
|
||||
model=model,
|
||||
external_engine_for_llm=False)
|
||||
task=Tasks.multimodal_dialogue, model=model)
|
||||
image = 'data/resource/portrait_input.png'
|
||||
system_prompt_1 = 'The following is a conversation between a curious human and AI assistant.'
|
||||
system_prompt_2 = "The assistant gives helpful, detailed, and polite answers to the user's questions."
|
||||
@@ -41,16 +39,14 @@ class MplugOwlMultimodalDialogueTest(unittest.TestCase):
|
||||
},
|
||||
]
|
||||
}
|
||||
result = pipeline_multimodal_dialogue(
|
||||
messages, max_length=5, external_engine_for_llm=False)
|
||||
result = pipeline_multimodal_dialogue(messages, max_length=5)
|
||||
print(result[OutputKeys.TEXT])
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_run_with_multimodal_dialogue_with_name(self):
|
||||
pipeline_multimodal_dialogue = pipeline(
|
||||
Tasks.multimodal_dialogue,
|
||||
model='damo/multi-modal_mplug_owl_multimodal-dialogue_7b',
|
||||
external_engine_for_llm=False)
|
||||
model='damo/multi-modal_mplug_owl_multimodal-dialogue_7b')
|
||||
image = 'data/resource/portrait_input.png'
|
||||
system_prompt_1 = 'The following is a conversation between a curious human and AI assistant.'
|
||||
system_prompt_2 = "The assistant gives helpful, detailed, and polite answers to the user's questions."
|
||||
@@ -79,8 +75,7 @@ class MplugOwlMultimodalDialogueTest(unittest.TestCase):
|
||||
def test_run_with_multimodal_dialogue_with_text(self):
|
||||
pipeline_multimodal_dialogue = pipeline(
|
||||
Tasks.multimodal_dialogue,
|
||||
model='damo/multi-modal_mplug_owl_multimodal-dialogue_7b',
|
||||
external_engine_for_llm=False)
|
||||
model='damo/multi-modal_mplug_owl_multimodal-dialogue_7b')
|
||||
system_prompt_1 = 'The following is a conversation between a curious human and AI assistant.'
|
||||
system_prompt_2 = "The assistant gives helpful, detailed, and polite answers to the user's questions."
|
||||
messages = {
|
||||
|
||||
Reference in New Issue
Block a user