From 88b0d9effce24114426ffb34c11231db7c7f1fc2 Mon Sep 17 00:00:00 2001 From: Galunid Date: Tue, 7 Nov 2023 23:14:58 +0100 Subject: [PATCH] Review fixes --- convert-hf-to-gguf.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index 34f3e25f6..5c57473a7 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -837,14 +837,14 @@ def parse_args() -> argparse.Namespace: help="path to write to; default: based on input", ) parser.add_argument( - "model", type=Path, - help="directory containing model file, or model file itself (*.bin)", - ) - parser.add_argument( - "ftype", type=str, choices=["f32", "f16"], default="f16", nargs='?', + "--outtype", type=str, choices=["f32", "f16"], default="f16", nargs='?', help="output format - use 0 for float32, 1 for float16", ) parser.add_argument("--bigendian", action="store_true", help="model is executed on big endian machine") + parser.add_argument( + "model", type=Path, + help="directory containing model file, or model file itself (*.bin)", + ) return parser.parse_args() @@ -852,25 +852,27 @@ def parse_args() -> argparse.Namespace: args = parse_args() dir_model = args.model -ftype = args.ftype if not dir_model.is_dir(): print(f'Error: {args.model} is not a directory', file=sys.stderr) sys.exit(1) -ftype_str = ["f32", "f16"] +ftype = { + "f32": gguf.GGMLQuantizationType.F32, + "f16": gguf.GGMLQuantizationType.F16, +} if args.outfile is not None: fname_out = args.outfile else: # output in the same directory as the model by default - fname_out = dir_model / f'ggml-model-{ftype}.gguf' + fname_out = dir_model / f'ggml-model-{args.outtype}.gguf' print(f"Loading model: {dir_model.name}") hparams = Model.load_hparams(dir_model) model_class = Model.from_model_architecture(hparams["architectures"][0]) -model_instance = model_class(dir_model, ftype_str.index(ftype), fname_out, args.bigendian) +model_instance = model_class(dir_model, ftype[args.outtype], fname_out, args.bigendian) print("Set model parameters") model_instance.set_gguf_parameters()