Skip to content

Commit ff3fcab

Browse files
authored
convert : add --print-supported-models option (ggml-org#11172)
* convert : add --print-supported-models option This commit adds a new option to the convert_hf_to_gguf.py script to print the supported models. The motivation for this is that it can be useful to know which models are supported by the script without having to look at the code. Example usage: ```console $ ./convert_hf_to_gguf.py --print-supported-models Supported models: - GPTNeoXForCausalLM - BloomForCausalLM - BloomModel - MPTForCausalLM - OrionForCausalLM - BaichuanForCausalLM - BaiChuanForCausalLM - XverseForCausalLM - FalconForCausalLM - RWForCausalLM - GPTBigCodeForCausalLM - GPTRefactForCausalLM - StableLmForCausalLM - StableLMEpochForCausalLM - LlavaStableLMEpochForCausalLM - LLaMAForCausalLM - LlamaForCausalLM - MistralForCausalLM - MixtralForCausalLM - DeciLMForCausalLM - BitnetForCausalLM - GrokForCausalLM - DbrxForCausalLM - MiniCPMForCausalLM - MiniCPM3ForCausalLM - QWenLMHeadModel - Qwen2ForCausalLM - Qwen2VLForConditionalGeneration - WavTokenizerDec - Qwen2MoeForCausalLM - GPT2LMHeadModel - PhiForCausalLM - Phi3ForCausalLM - PhiMoEForCausalLM - PlamoForCausalLM - CodeShellForCausalLM - InternLM2ForCausalLM - BertModel - BertForMaskedLM - CamembertModel - RobertaModel - NomicBertModel - XLMRobertaModel - XLMRobertaForSequenceClassification - GemmaForCausalLM - Gemma2ForCausalLM - Starcoder2ForCausalLM - Rwkv6ForCausalLM - RWKV6Qwen2ForCausalLM - MambaForCausalLM - MambaLMHeadModel - FalconMambaForCausalLM - CohereForCausalLM - Cohere2ForCausalLM - OLMoForCausalLM - OlmoForCausalLM - Olmo2ForCausalLM - OlmoeForCausalLM - JinaBertModel - JinaBertForMaskedLM - OpenELMForCausalLM - ArcticForCausalLM - DeepseekForCausalLM - DeepseekV3ForCausalLM - DeepseekV2ForCausalLM - UMT5ForConditionalGeneration - MT5ForConditionalGeneration - T5ForConditionalGeneration - T5WithLMHeadModel - T5EncoderModel - JAISLMHeadModel - ChatGLMModel - ChatGLMForConditionalGeneration - NemotronForCausalLM - ExaoneForCausalLM - GraniteForCausalLM - GraniteMoeForCausalLM - ChameleonForCausalLM - ChameleonForConditionalGeneration ``` * squash! convert : add --print-supported-models option Fix flake8 error.
1 parent c3f9d25 commit ff3fcab

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

convert_hf_to_gguf.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ def func(modelcls: AnyModel) -> AnyModel:
478478
return modelcls
479479
return func
480480

481+
@classmethod
482+
def print_registered_models(cls):
483+
for name in cls._model_classes.keys():
484+
logger.error(f"- {name}")
485+
481486
@classmethod
482487
def from_model_architecture(cls, arch: str) -> type[Model]:
483488
try:
@@ -4929,6 +4934,7 @@ def parse_args() -> argparse.Namespace:
49294934
parser.add_argument(
49304935
"model", type=Path,
49314936
help="directory containing model file",
4937+
nargs="?",
49324938
)
49334939
parser.add_argument(
49344940
"--use-temp-file", action="store_true",
@@ -4966,8 +4972,15 @@ def parse_args() -> argparse.Namespace:
49664972
"--metadata", type=Path,
49674973
help="Specify the path for an authorship metadata override file"
49684974
)
4975+
parser.add_argument(
4976+
"--print-supported-models", action="store_true",
4977+
help="Print the supported models"
4978+
)
49694979

4970-
return parser.parse_args()
4980+
args = parser.parse_args()
4981+
if not args.print_supported_models and args.model is None:
4982+
parser.error("the following arguments are required: model")
4983+
return args
49714984

49724985

49734986
def split_str_to_n_bytes(split_str: str) -> int:
@@ -4991,6 +5004,11 @@ def split_str_to_n_bytes(split_str: str) -> int:
49915004
def main() -> None:
49925005
args = parse_args()
49935006

5007+
if args.print_supported_models:
5008+
logger.error("Supported models:")
5009+
Model.print_registered_models()
5010+
sys.exit(0)
5011+
49945012
if args.verbose:
49955013
logging.basicConfig(level=logging.DEBUG)
49965014
else:

0 commit comments

Comments
 (0)