5
5
6
6
def get_model_info_table () -> List [str ]:
7
7
fpaths = ['docs/source/LLM/支持的模型和数据集.md' , 'docs/source_en/LLM/Supported-models-datasets.md' ]
8
- end_words = ['## 数据集' , '## Datasets' ]
8
+ end_words = [[ '### 多模态大模型' , '## 数据集'], [ '### MLLM' , '## Datasets'] ]
9
9
model_name_list = ModelType .get_model_name_list ()
10
- result = ('| Model Type | Model ID | Default Lora Target Modules | Default Template |'
11
- ' Support Flash Attn | Support VLLM | Requires | Tags | HF Model ID |\n '
12
- '| --------- | -------- | --------------------------- | ---------------- |'
13
- ' ------------------ | ------------ | -------- | ---- | ----------- |\n ' )
14
- res : List [str ] = []
10
+ result = [
11
+ '| Model Type | Model ID | Default Lora Target Modules | Default Template |'
12
+ ' Support Flash Attn | Support VLLM | Requires | Tags | HF Model ID |\n '
13
+ '| --------- | -------- | --------------------------- | ---------------- |'
14
+ ' ------------------ | ------------ | -------- | ---- | ----------- |\n '
15
+ ] * 2
16
+ res_llm : List [str ] = []
17
+ res_mllm : List [str ] = []
15
18
bool_mapping = {True : '✔' , False : '✘' }
16
19
for model_name in model_name_list :
17
20
model_info = MODEL_MAPPING [model_name ]
@@ -24,6 +27,11 @@ def get_model_info_table() -> List[str]:
24
27
support_vllm = bool_mapping [support_vllm ]
25
28
requires = ', ' .join (model_info ['requires' ])
26
29
tags = model_info .get ('tags' , [])
30
+ if 'multi-modal' in tags :
31
+ tags .remove ('multi-modal' )
32
+ is_multi_modal = True
33
+ else :
34
+ is_multi_modal = False
27
35
tags_str = ', ' .join (tags )
28
36
if len (tags_str ) == 0 :
29
37
tags_str = '-'
@@ -34,24 +42,32 @@ def get_model_info_table() -> List[str]:
34
42
model_name , model_id , lora_target_modules , template , support_flash_attn , support_vllm , requires , tags_str ,
35
43
hf_model_id
36
44
]
37
- res .append (r )
38
- text = ''
39
- for r in res :
40
- ms_url = f'https://modelscope.cn/models/{ r [1 ]} /summary'
41
- if r [8 ] != '-' :
42
- hf_url = f'https://huggingface.co/{ r [8 ]} '
43
- hf_model_id_str = f'[{ r [8 ]} ]({ hf_url } )'
45
+ if is_multi_modal :
46
+ res_mllm .append (r )
44
47
else :
45
- hf_model_id_str = '-'
46
- text += f'|{ r [0 ]} |[{ r [1 ]} ]({ ms_url } )|{ r [2 ]} |{ r [3 ]} |{ r [4 ]} |{ r [5 ]} |{ r [6 ]} |{ r [7 ]} |{ hf_model_id_str } |\n '
47
- print (f'模型总数: { len (res )} ' )
48
- result += text
49
- for idx , fpath in enumerate (fpaths ):
48
+ res_llm .append (r )
49
+ print (f'LLM总数: { len (res_llm )} , MLLM总数: { len (res_mllm )} ' )
50
+ text = ['' , '' ] # llm, mllm
51
+ for i , res in enumerate ([res_llm , res_mllm ]):
52
+ for r in res :
53
+ ms_url = f'https://modelscope.cn/models/{ r [1 ]} /summary'
54
+ if r [8 ] != '-' :
55
+ hf_url = f'https://huggingface.co/{ r [8 ]} '
56
+ hf_model_id_str = f'[{ r [8 ]} ]({ hf_url } )'
57
+ else :
58
+ hf_model_id_str = '-'
59
+ text [i ] += f'|{ r [0 ]} |[{ r [1 ]} ]({ ms_url } )|{ r [2 ]} |{ r [3 ]} |{ r [4 ]} |{ r [5 ]} |{ r [6 ]} |{ r [7 ]} |{ hf_model_id_str } |\n '
60
+ result [i ] += text [i ]
61
+
62
+ for i , fpath in enumerate (fpaths ):
50
63
with open (fpath , 'r' ) as f :
51
64
text = f .read ()
52
- start_idx = text .find ('| Model Type |' )
53
- end_idx = text .find (end_words [idx ])
54
- output = text [:start_idx ] + result + '\n \n ' + text [end_idx :]
65
+ llm_start_idx = text .find ('| Model Type |' )
66
+ mllm_start_idx = text [llm_start_idx + 1 :].find ('| Model Type |' ) + llm_start_idx + 1
67
+ llm_end_idx = text .find (end_words [i ][0 ])
68
+ mllm_end_idx = text .find (end_words [i ][1 ])
69
+ output = text [:llm_start_idx ] + result [0 ] + '\n \n ' + text [llm_end_idx :mllm_start_idx ] + result [
70
+ 1 ] + '\n \n ' + text [mllm_end_idx :]
55
71
with open (fpath , 'w' ) as f :
56
72
text = f .write (output )
57
73
return res
0 commit comments