Skip to content

Commit de3d9e3

Browse files
committed
patch: Apply fix for downloading related model files
1 parent 17f2243 commit de3d9e3

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

convert-hf-to-gguf-update.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ def download_file_with_auth(url, token, save_path):
102102
repo = model["repo"]
103103
tokt = model["tokt"]
104104

105-
# set url paths
106-
url_main = f"{repo}/raw/main"
105+
# NOTE: We should always be using resolve to download files
107106
url_resolve = f"{repo}/resolve/main"
108107

109108
# set dir paths
@@ -138,28 +137,18 @@ def download_file_with_auth(url, token, save_path):
138137
)
139138
else: # Get the models tokenizer
140139
download_file_with_auth(
141-
url=f"{url_main}/tokenizer.json",
140+
url=f"{url_resolve}/tokenizer.json",
142141
token=token,
143142
save_path=model_tokenizer_path
144143
)
145144

146145
# Get the models hyper params
147146
download_file_with_auth(
148-
url=f"{url_main}/config.json",
147+
url=f"{url_resolve}/config.json",
149148
token=token,
150149
save_path=f"{model_name_or_path}/config.json"
151150
)
152151

153-
# if downloaded file is less than 1KB, we likely need to download an LFS instead
154-
if os.path.getsize(model_tokenizer_path) < 1024:
155-
# remove the file
156-
os.remove(model_tokenizer_path)
157-
download_file_with_auth(
158-
url=f"{url_resolve}/tokenizer.json",
159-
token=token,
160-
save_path=model_tokenizer_path
161-
)
162-
163152
# Handle sentencepiece tokenizer
164153
if tokt == TOKENIZER_TYPE.SPM:
165154
download_file_with_auth(
@@ -170,7 +159,7 @@ def download_file_with_auth(url, token, save_path):
170159

171160
# Get the tokenizer config
172161
download_file_with_auth(
173-
url=f"{url_main}/tokenizer_config.json",
162+
url=f"{url_resolve}/tokenizer_config.json",
174163
token=token,
175164
save_path=f"{model_name_or_path}/tokenizer_config.json"
176165
)

0 commit comments

Comments
 (0)