summaryrefslogtreecommitdiff
path: root/convert-hf-to-gguf.py
diff options
context:
space:
mode:
authorDouglas Hanley <thesecretaryofwar@gmail.com>2024-03-03 04:40:27 -0600
committerGitHub <noreply@github.com>2024-03-03 12:40:27 +0200
commit475df1d6cf817060028d3ff763cb8097d4ec40d6 (patch)
tree5cad43f149f24b7b3f40604b78b7971e458aa309 /convert-hf-to-gguf.py
parent87c2e8b2797860a06af3d6c06b8488a8ff1a09ab (diff)
llama : allow for user specified embedding pooling type (#5849)
* allow for user specified pooling type * llama : use enum types over int --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Diffstat (limited to 'convert-hf-to-gguf.py')
-rwxr-xr-xconvert-hf-to-gguf.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py
index fa9d4f22..ffdba744 100755
--- a/convert-hf-to-gguf.py
+++ b/convert-hf-to-gguf.py
@@ -1644,16 +1644,17 @@ class BertModel(Model):
self.gguf_writer.add_causal_attention(False)
# get pooling path
- with open(self.dir_model / "modules.json", encoding="utf-8") as f:
- modules = json.load(f)
pooling_path = None
- for mod in modules:
- if mod["type"] == "sentence_transformers.models.Pooling":
- pooling_path = mod["path"]
- break
+ module_path = self.dir_model / "modules.json"
+ if module_path.is_file():
+ with open(module_path, encoding="utf-8") as f:
+ modules = json.load(f)
+ for mod in modules:
+ if mod["type"] == "sentence_transformers.models.Pooling":
+ pooling_path = mod["path"]
+ break
# get pooling type
- pooling_type = gguf.PoolingType.NONE
if pooling_path is not None:
with open(self.dir_model / pooling_path / "config.json", encoding="utf-8") as f:
pooling = json.load(f)
@@ -1663,8 +1664,7 @@ class BertModel(Model):
pooling_type = gguf.PoolingType.CLS
else:
raise NotImplementedError("Only MEAN and CLS pooling types supported")
-
- self.gguf_writer.add_pooling_type(pooling_type)
+ self.gguf_writer.add_pooling_type(pooling_type)
def set_vocab(self):
path = self.dir_model