Skip to content

Commit b46d12f

Browse files
authored
convert.py: also look for plain model.safetensors (ggml-org#4043)
* add safetensors to convert.py help message * Check for single-file safetensors model * Update convert.py "model" option help message * revert convert.py help message change
1 parent bd90eca commit b46d12f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

convert.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ def load_some_model(path: Path) -> ModelPlus:
10361036
# Be extra-friendly and accept either a file or a directory:
10371037
if path.is_dir():
10381038
# Check if it's a set of safetensors files first
1039-
files = list(path.glob("model-00001-of-*.safetensors"))
1039+
globs = ["model-00001-of-*.safetensors", "model.safetensors"]
1040+
files = [file for glob in globs for file in path.glob(glob)]
10401041
if not files:
10411042
# Try the PyTorch patterns too, with lower priority
10421043
globs = ["consolidated.00.pth", "pytorch_model-00001-of-*.bin", "*.pt", "pytorch_model.bin"]
@@ -1123,7 +1124,7 @@ def main(args_in: list[str] | None = None) -> None:
11231124
parser.add_argument("--outtype", choices=output_choices, help="output format - note: q8_0 may be very slow (default: f16 or f32 based on input)")
11241125
parser.add_argument("--vocab-dir", type=Path, help="directory containing tokenizer.model, if separate from model file")
11251126
parser.add_argument("--outfile", type=Path, help="path to write to; default: based on input")
1126-
parser.add_argument("model", type=Path, help="directory containing model file, or model file itself (*.pth, *.pt, *.bin)")
1127+
parser.add_argument("model", type=Path, help="directory containing model file, or model file itself (*.pth, *.pt, *.bin, *.safetensors)")
11271128
parser.add_argument("--vocabtype", choices=["spm", "bpe"], help="vocab format (default: spm)", default="spm")
11281129
parser.add_argument("--ctx", type=int, help="model training context (default: based on input)")
11291130
parser.add_argument("--concurrency", type=int, help=f"concurrency used for conversion (default: {DEFAULT_CONCURRENCY})", default = DEFAULT_CONCURRENCY)

0 commit comments

Comments
 (0)