@@ -1523,7 +1523,7 @@ def load_vocab(self, vocab_types: list[str] | None, model_parent_path: Path) ->
1523
1523
return vocab , special_vocab
1524
1524
1525
1525
1526
- def default_outfile ( model_paths : list [ Path ], file_type : GGMLFileType , params : Params , model_params_count : int , metadata : Metadata ) -> Path :
1526
+ def default_convention_outfile ( file_type : GGMLFileType , params : Params , model_params_count : int , metadata : Metadata ) -> str :
1527
1527
quantization = {
1528
1528
GGMLFileType .AllF32 : "F32" ,
1529
1529
GGMLFileType .MostlyF16 : "F16" ,
@@ -1546,7 +1546,12 @@ def default_outfile(model_paths: list[Path], file_type: GGMLFileType, params: Pa
1546
1546
elif params .path_model is not None :
1547
1547
name = params .path_model .name
1548
1548
1549
- ret = model_paths [0 ].parent / f"{ name } { version } -{ expert_count } { parameters } -{ quantization } .gguf"
1549
+ return f"{ name } { version } -{ expert_count } { parameters } -{ quantization } "
1550
+
1551
+
1552
+ def default_outfile (model_paths : list [Path ], file_type : GGMLFileType , params : Params , model_params_count : int , metadata : Metadata ) -> Path :
1553
+ default_filename = default_convention_outfile (file_type , params , model_params_count , metadata )
1554
+ ret = model_paths [0 ].parent / f"{ default_filename } .gguf"
1550
1555
if ret in model_paths :
1551
1556
logger .error (
1552
1557
f"Error: Default output path ({ ret } ) would overwrite the input. "
@@ -1585,6 +1590,7 @@ def main(args_in: list[str] | None = None) -> None:
1585
1590
parser .add_argument ("--skip-unknown" , action = "store_true" , help = "skip unknown tensor names instead of failing" )
1586
1591
parser .add_argument ("--verbose" , action = "store_true" , help = "increase output verbosity" )
1587
1592
parser .add_argument ("--metadata" , type = Path , help = "Specify the path for a metadata file" )
1593
+ parser .add_argument ("--get-outfile" , action = "store_true" , help = "get calculated default outfile name" )
1588
1594
1589
1595
args = parser .parse_args (args_in )
1590
1596
@@ -1598,6 +1604,16 @@ def main(args_in: list[str] | None = None) -> None:
1598
1604
1599
1605
metadata = Metadata .load (args .metadata )
1600
1606
1607
+ if args .get_outfile :
1608
+ logging .basicConfig (level = logging .CRITICAL )
1609
+ model_plus = load_some_model (args .model )
1610
+ params = Params .load (model_plus )
1611
+ model = convert_model_names (model_plus .model , params , args .skip_unknown )
1612
+ model_params_count = model_parameter_count (model_plus .model )
1613
+ ftype = pick_output_type (model , args .outtype )
1614
+ print (f"{ default_convention_outfile (ftype , params , model_params_count , metadata )} " ) # noqa: NP100
1615
+ return
1616
+
1601
1617
if args .no_vocab and args .vocab_only :
1602
1618
raise ValueError ("--vocab-only does not make sense with --no-vocab" )
1603
1619
0 commit comments