summaryrefslogtreecommitdiff
path: root/convert-llama-ggmlv3-to-gguf.py
diff options
context:
space:
mode:
Diffstat (limited to 'convert-llama-ggmlv3-to-gguf.py')
-rwxr-xr-xconvert-llama-ggmlv3-to-gguf.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/convert-llama-ggmlv3-to-gguf.py b/convert-llama-ggmlv3-to-gguf.py
index c8e7f176..3f39bc39 100755
--- a/convert-llama-ggmlv3-to-gguf.py
+++ b/convert-llama-ggmlv3-to-gguf.py
@@ -1,10 +1,14 @@
#!/usr/bin/env python3
-import sys, struct, math, argparse
-from pathlib import Path
+from __future__ import annotations
-import numpy as np
+import argparse
+import math
+import struct
+import sys
+from pathlib import Path
import gguf
+import numpy as np
# Note: Does not support GGML_QKK_64
QK_K = 256
@@ -72,7 +76,7 @@ class Vocab:
class Tensor:
def __init__(self):
self.name = None
- self.dims = ()
+ self.dims: tuple[int, ...] = ()
self.dtype = None
self.start_offset = 0
self.len_bytes = np.int64(0)
@@ -119,7 +123,7 @@ class GGMLV3Model:
offset += hp.load(data, offset)
vocab = Vocab()
offset += vocab.load(data, offset, hp.n_vocab)
- tensors = []
+ tensors: list[Tensor] = []
tensor_map = {}
while offset < len(data):
tensor = Tensor()
@@ -305,8 +309,8 @@ def handle_metadata(cfg, hp):
def handle_args():
parser = argparse.ArgumentParser(description = 'Convert GGMLv3 models to GGUF')
- parser.add_argument('--input', '-i', type = Path, help = 'Input GGMLv3 filename')
- parser.add_argument('--output', '-o', type = Path, help ='Output GGUF filename')
+ parser.add_argument('--input', '-i', type = Path, required = True, help = 'Input GGMLv3 filename')
+ parser.add_argument('--output', '-o', type = Path, required = True, help ='Output GGUF filename')
parser.add_argument('--name', help = 'Set model name')
parser.add_argument('--desc', help = 'Set model description')
parser.add_argument('--gqa', type = int, default = 1, help = 'grouped-query attention factor (use 8 for LLaMA2 70B)')