@@ -54,7 +54,7 @@ def test_get_model_id_components(self):
54
54
self .assertEqual (gguf .Metadata .get_model_id_components ("NousResearch/Meta-Llama-3-8B" ),
55
55
('Meta-Llama-3-8B' , "NousResearch" , 'Meta-Llama-3' , None , None , '8B' ))
56
56
57
- # Can't detect all non standard form in a heuristically safe way... best to err in caution and output nothing...
57
+ # Non standard naming
58
58
self .assertEqual (gguf .Metadata .get_model_id_components ("Qwen1.5-MoE-A2.7B-Chat" ),
59
59
('Qwen1.5-MoE-A2.7B-Chat' , None , 'Qwen1.5-MoE' , 'Chat' , None , 'A2.7B' ))
60
60
@@ -71,7 +71,7 @@ def test_get_model_id_components(self):
71
71
self .assertEqual (gguf .Metadata .get_model_id_components ("delphi-suite/stories-llama2-50k" , 50 * 10 ** 3 ),
72
72
('stories-llama2-50k' , 'delphi-suite' , 'stories-llama2' , None , None , '50K' ))
73
73
74
- # None standard and not easy to disambiguate
74
+ # Non standard and not easy to disambiguate
75
75
self .assertEqual (gguf .Metadata .get_model_id_components ("DeepSeek-Coder-V2-Lite-Instruct" ),
76
76
('DeepSeek-Coder-V2-Lite-Instruct' , None , 'DeepSeek-Coder-V2-Lite' , 'Instruct' , None , None ))
77
77
@@ -123,6 +123,51 @@ def test_get_model_id_components(self):
123
123
self .assertEqual (gguf .Metadata .get_model_id_components ("bigscience/bloom-7b1-petals" ),
124
124
('bloom-7b1-petals' , 'bigscience' , 'bloom' , 'petals' , None , '7.1B' ))
125
125
126
+ # Ignore full-text size labels when there are number-based ones, and deduplicate size labels
127
+ self .assertEqual (gguf .Metadata .get_model_id_components ("MaziyarPanahi/GreenNode-mini-7B-multilingual-v1olet-Mistral-7B-Instruct-v0.1" ),
128
+ ('GreenNode-mini-7B-multilingual-v1olet-Mistral-7B-Instruct-v0.1' , 'MaziyarPanahi' , 'GreenNode-mini' , 'multilingual-v1olet-Mistral-Instruct' , 'v0.1' , '7B' ))
129
+
130
+ # Instruct in a name without a size label
131
+ self .assertEqual (gguf .Metadata .get_model_id_components ("mistralai/Mistral-Nemo-Instruct-2407" ),
132
+ ('Mistral-Nemo-Instruct-2407' , 'mistralai' , 'Mistral-Nemo' , 'Instruct' , '2407' , None ))
133
+
134
+ # Non-obvious splitting relying on 'chat' keyword
135
+ self .assertEqual (gguf .Metadata .get_model_id_components ("deepseek-ai/DeepSeek-V2-Chat-0628" ),
136
+ ('DeepSeek-V2-Chat-0628' , 'deepseek-ai' , 'DeepSeek-V2' , 'Chat' , '0628' , None ))
137
+
138
+ # Multiple versions
139
+ self .assertEqual (gguf .Metadata .get_model_id_components ("OpenGVLab/Mini-InternVL-Chat-2B-V1-5" ),
140
+ ('Mini-InternVL-Chat-2B-V1-5' , 'OpenGVLab' , 'Mini-InternVL' , 'Chat' , 'V1-5' , '2B' ))
141
+
142
+ # TODO: DPO in the name
143
+ self .assertEqual (gguf .Metadata .get_model_id_components ("jondurbin/bagel-dpo-2.8b-v0.2" ),
144
+ ('bagel-dpo-2.8b-v0.2' , 'jondurbin' , 'bagel-dpo' , None , 'v0.2' , '2.8B' ))
145
+
146
+ # DPO in name, but can't be used for the finetune to keep 'LLaMA-3' in the basename
147
+ self .assertEqual (gguf .Metadata .get_model_id_components ("voxmenthe/SFR-Iterative-DPO-LLaMA-3-8B-R-unquantized" ),
148
+ ('SFR-Iterative-DPO-LLaMA-3-8B-R-unquantized' , 'voxmenthe' , 'SFR-Iterative-DPO-LLaMA-3' , 'R-unquantized' , None , '8B' ))
149
+
150
+ # Too ambiguous
151
+ # TODO: should "base" be a 'finetune' or 'size_label'?
152
+ # (in this case it should be a size label, but other models use it to signal that they are not finetuned)
153
+ self .assertEqual (gguf .Metadata .get_model_id_components ("microsoft/Florence-2-base" ),
154
+ ('Florence-2-base' , 'microsoft' , None , None , None , None ))
155
+
156
+ ## Invalid cases ##
157
+
158
+ # Start with a dash and has dashes in rows
159
+ self .assertEqual (gguf .Metadata .get_model_id_components ("mistralai/-Mistral--Nemo-Base-2407-" ),
160
+ ('-Mistral--Nemo-Base-2407-' , 'mistralai' , 'Mistral-Nemo-Base' , None , '2407' , None ))
161
+
162
+ ## LoRA ##
163
+
164
+ self .assertEqual (gguf .Metadata .get_model_id_components ("Llama-3-Instruct-abliteration-LoRA-8B" ),
165
+ ('Llama-3-Instruct-abliteration-LoRA-8B' , None , 'Llama-3' , 'Instruct-abliteration-LoRA' , None , '8B' ))
166
+
167
+ # Negative size --> output is a LoRA adaper --> prune "LoRA" out of the name to avoid redundancy with the suffix
168
+ self .assertEqual (gguf .Metadata .get_model_id_components ("Llama-3-Instruct-abliteration-LoRA-8B" , - 1234 ),
169
+ ('Llama-3-Instruct-abliteration-LoRA-8B' , None , 'Llama-3' , 'Instruct-abliteration' , None , '8B' ))
170
+
126
171
def test_apply_metadata_heuristic_from_model_card (self ):
127
172
model_card = {
128
173
'tags' : ['Llama-3' , 'instruct' , 'finetune' , 'chatml' , 'DPO' , 'RLHF' , 'gpt4' , 'synthetic data' , 'distillation' , 'function calling' , 'json mode' , 'axolotl' ],
@@ -134,7 +179,7 @@ def test_apply_metadata_heuristic_from_model_card(self):
134
179
}
135
180
got = gguf .Metadata .apply_metadata_heuristic (gguf .Metadata (), model_card , None , None )
136
181
expect = gguf .Metadata ()
137
- expect .base_models = [{'name' : 'Mistral 7B Merge 14 v0' , 'organization' : 'EmbeddedLLM' , 'version' : 'v0' , 'repo_url' : 'https://huggingface.co/EmbeddedLLM/Mistral-7B-Merge-14-v0' }, {'name' : 'Trinity v1' , 'organization' : 'Janai Hq' , 'version' : 'v1' , 'repo_url' : 'https://huggingface.co/janai-hq/trinity-v1' }]
182
+ expect .base_models = [{'name' : 'Mistral 7B Merge 14 v0' , 'organization' : 'EmbeddedLLM' , 'version' : '14- v0' , 'repo_url' : 'https://huggingface.co/EmbeddedLLM/Mistral-7B-Merge-14-v0' }, {'name' : 'Trinity v1' , 'organization' : 'Janai Hq' , 'version' : 'v1' , 'repo_url' : 'https://huggingface.co/janai-hq/trinity-v1' }]
138
183
expect .tags = ['Llama-3' , 'instruct' , 'finetune' , 'chatml' , 'DPO' , 'RLHF' , 'gpt4' , 'synthetic data' , 'distillation' , 'function calling' , 'json mode' , 'axolotl' ]
139
184
expect .languages = ['en' ]
140
185
expect .datasets = ['teknium/OpenHermes-2.5' ]
0 commit comments