From: Sigbjørn Skjæret Date: Thu, 5 Jun 2025 15:42:31 +0000 (+0200) Subject: gguf-py : add add_classifier_output_labels method to writer (#14031) X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=1caae7fc6c77551cb1066515e0f414713eebb367;p=pkg%2Fggml%2Fsources%2Fllama.cpp gguf-py : add add_classifier_output_labels method to writer (#14031) * add add_classifier_output_labels * use add_classifier_output_labels --- diff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.py index ec3b5697..7b9893c8 100755 --- a/convert_hf_to_gguf.py +++ b/convert_hf_to_gguf.py @@ -3709,8 +3709,7 @@ class BertModel(TextModel): self._try_set_pooling_type() if self.cls_out_labels: - key_name = gguf.Keys.Classifier.OUTPUT_LABELS.format(arch = gguf.MODEL_ARCH_NAMES[self.model_arch]) - self.gguf_writer.add_array(key_name, [v for k, v in sorted(self.cls_out_labels.items())]) + self.gguf_writer.add_classifier_output_labels([v for k, v in sorted(self.cls_out_labels.items())]) def set_vocab(self): tokens, toktypes, tokpre = self.get_vocab_base() diff --git a/gguf-py/gguf/gguf_writer.py b/gguf-py/gguf/gguf_writer.py index de6e45ae..adc673e3 100644 --- a/gguf-py/gguf/gguf_writer.py +++ b/gguf-py/gguf/gguf_writer.py @@ -935,6 +935,9 @@ class GGUFWriter: def add_eom_token_id(self, id: int) -> None: self.add_uint32(Keys.Tokenizer.EOM_ID, id) + def add_classifier_output_labels(self, labels: Sequence[str]) -> None: + self.add_array(Keys.Classifier.OUTPUT_LABELS.format(arch=self.arch), labels) + # for vision models def add_clip_has_vision_encoder(self, value: bool) -> None: