summaryrefslogtreecommitdiff
path: root/convert-falcon-hf-to-gguf.py
diff options
context:
space:
mode:
authorCebtenzzre <cebtenzzre@gmail.com>2023-08-31 01:02:23 -0400
committerGitHub <noreply@github.com>2023-08-31 08:02:23 +0300
commit92d0b751a77a089e650983e9f1564ef4d31b32b9 (patch)
tree28beced44af777ec563f489518a14509994187dd /convert-falcon-hf-to-gguf.py
parent8afe2280009ecbfc9de2c93b8f41283dc810609a (diff)
convert : fix python 3.8 support, modernize type annotations (#2916)
* convert : fix python 3.8 support * convert : sort imports * convert : fix required parameters in convert-llama-ggmlv3-to-gguf * convert : fix mypy errors in convert-llama-ggmlv3-to-gguf * convert : use PEP 585 generics and PEP 604 unions Now that we have `from __future__ import annotations`, we can use this modern syntax in Python 3.7 instead of restricting support to Python 3.9 or 3.10 respectively. * gguf.py : a tuple is already a tuple * add mypy.ini * convert : add necessary `type: ignore` comments * gguf-py: bump version
Diffstat (limited to 'convert-falcon-hf-to-gguf.py')
-rwxr-xr-xconvert-falcon-hf-to-gguf.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/convert-falcon-hf-to-gguf.py b/convert-falcon-hf-to-gguf.py
index 0fdea70e..ec786ff6 100755
--- a/convert-falcon-hf-to-gguf.py
+++ b/convert-falcon-hf-to-gguf.py
@@ -1,18 +1,21 @@
#!/usr/bin/env python3
# HF falcon--> gguf conversion
-import gguf
+from __future__ import annotations
+
+import argparse
+import json
import os
-import sys
import struct
-import json
+import sys
+from pathlib import Path
+from typing import Any
+
+import gguf
import numpy as np
import torch
-import argparse
+from transformers import AutoTokenizer # type: ignore[import]
-from typing import Any, List
-from pathlib import Path
-from transformers import AutoTokenizer
def bytes_to_unicode():
# ref: https://github.com/openai/gpt-2/blob/master/src/encoder.py
@@ -114,9 +117,9 @@ gguf_writer.add_file_type(ftype)
print("gguf: get tokenizer metadata")
-tokens: List[bytearray] = []
-scores: List[float] = []
-toktypes: List[int] = []
+tokens: list[bytearray] = []
+scores: list[float] = []
+toktypes: list[int] = []
tokenizer_json_file = dir_model / 'tokenizer.json'
if not tokenizer_json_file.is_file():