diff options
Diffstat (limited to 'convert-gptq-to-ggml.py')
-rw-r--r-- | convert-gptq-to-ggml.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/convert-gptq-to-ggml.py b/convert-gptq-to-ggml.py index 860eb148..42e99c2f 100644 --- a/convert-gptq-to-ggml.py +++ b/convert-gptq-to-ggml.py @@ -50,7 +50,7 @@ fout.write(struct.pack("i", 4)) # This loop unchanged from convert-pth-to-ggml.py: for i in range(tokenizer.vocab_size()): if tokenizer.is_unknown(i): - text = " \u2047 ".encode("utf-8") + text = " \u2047 ".encode() elif tokenizer.is_control(i): text = b"" elif tokenizer.is_byte(i): @@ -61,13 +61,13 @@ for i in range(tokenizer.vocab_size()): byte_value = int(piece[3:-1], 16) text = struct.pack("B", byte_value) else: - text = tokenizer.id_to_piece(i).replace("\u2581", " ").encode("utf-8") + text = tokenizer.id_to_piece(i).replace("\u2581", " ").encode() fout.write(struct.pack("i", len(text))) fout.write(text) fout.write(struct.pack("f", tokenizer.get_score(i))) def write_header(shape, dst_name, ftype_cur): - sname = dst_name.encode('utf-8') + sname = dst_name.encode() fout.write(struct.pack("iii", len(shape), len(sname), ftype_cur)) fout.write(struct.pack("i" * len(shape), *shape[::-1])) fout.write(sname) @@ -80,7 +80,7 @@ def write_header(shape, dst_name, ftype_cur): def convert_non_q4(src_name, dst_name): v = model[src_name] shape = v.shape - print("Processing non-Q4 variable: " + src_name + " with shape: ", shape, " and type: ", v.dtype) + print(f"Processing non-Q4 variable: {src_name} with shape: {shape} and type: {v.dtype}") if len(shape) == 1: print(" Converting to float32") v = v.to(torch.float32) @@ -105,7 +105,7 @@ def convert_q4(src_name, dst_name, permute=False): # Each int32 item is actually 8 int4 items packed together, and it's transposed. shape = (qweight.shape[0], qweight.shape[1] * 8) - print("Processing Q4 variable: " + src_name + " with shape: ", shape) + print(f"Processing Q4 variable: {src_name} with shape: {shape}") # The output format has the int4 weights in groups of 32 rather than 8. # It looks like this: @@ -168,5 +168,5 @@ for i in range(n_layer): fout.close() -print("Done. Output file: " + fname_out) -print("") +print(f"Done. Output file: {fname_out}") +print() |