Skip to content

Commit 6175107

Browse files
fix: small improvement to convert-to-safetensors (IBM#69)
When running `text-generation-server convert-to-safetensors ./` on a local download of model files that have some remote code files, the `AutoConfig.from_pretrained()` call prints an interactive prompt: ``` The repository for ./ contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/./. You can avoid this prompt in future by passing the argument `trust_remote_code=True`. Do you wish to run the custom code? [y/N] ``` This PR enables the command to be executed non-interactively in this case. TRUST_REMOTE_CODE defaults to true. Also made a small fix to a log message printed if the index file already exists to include the full name. Signed-off-by: Travis Johnson <[email protected]>
1 parent 316ca8d commit 6175107

File tree

1 file changed

+2
-1
lines changed
  • server/text_generation_server

1 file changed

+2
-1
lines changed

server/text_generation_server/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def convert_to_safetensors(
166166
config = transformers.AutoConfig.from_pretrained(
167167
model_name,
168168
revision=revision,
169+
trust_remote_code=utils.TRUST_REMOTE_CODE
169170
)
170171
architecture = config.architectures[0]
171172

@@ -184,7 +185,7 @@ def convert_to_safetensors(
184185
local_st_index_file = local_pt_index_file.parent / f"{st_prefix}.safetensors.index.json"
185186

186187
if os.path.exists(local_st_index_file):
187-
print("Existing .safetensors.index.json file found, remove it first to reconvert")
188+
print("Existing model.safetensors.index.json file found, remove it first to reconvert")
188189
return
189190

190191
utils.convert_index_file(local_pt_index_file, local_st_index_file, local_pt_files, local_st_files)

0 commit comments

Comments
 (0)