{"record":{"id":"2f6f17603a68d416","repo":"huggingface/transformers","slug":"lowercase-name-is-not-a-valid-model-name","errorCode":null,"errorMessage":"{lowercase_name} is not a valid model name","messagePattern":"(.+?) is not a valid model name","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/cli/add_new_model_like.py","lineNumber":143,"sourceCode":"class ModelInfos:\n    \"\"\"\n    Retrieve the basic information about an existing model classes.\n    \"\"\"\n\n    def __init__(self, lowercase_name: str):\n        from ..models.auto.configuration_auto import CONFIG_MAPPING_NAMES\n        from ..models.auto.feature_extraction_auto import FEATURE_EXTRACTOR_MAPPING_NAMES\n        from ..models.auto.image_processing_auto import IMAGE_PROCESSOR_MAPPING_NAMES\n        from ..models.auto.processing_auto import PROCESSOR_MAPPING_NAMES\n        from ..models.auto.tokenization_auto import TOKENIZER_MAPPING_NAMES\n        from ..models.auto.video_processing_auto import VIDEO_PROCESSOR_MAPPING_NAMES\n\n        # Just to make sure it's indeed lowercase\n        self.lowercase_name = lowercase_name.lower().replace(\" \", \"_\").replace(\"-\", \"_\")\n        if self.lowercase_name not in CONFIG_MAPPING_NAMES:\n            self.lowercase_name.replace(\"_\", \"-\")\n        if self.lowercase_name not in CONFIG_MAPPING_NAMES:\n            raise ValueError(f\"{lowercase_name} is not a valid model name\")\n\n        self.config_class = CONFIG_MAPPING_NAMES[self.lowercase_name]\n        self.camelcase_name = self.config_class.replace(\"Config\", \"\")\n\n        # Get tokenizer class\n        if self.lowercase_name in TOKENIZER_MAPPING_NAMES:\n            self.tokenizer_class = None\n            self.fast_tokenizer_class = TOKENIZER_MAPPING_NAMES[self.lowercase_name]\n            self.fast_tokenizer_class = (\n                None if self.fast_tokenizer_class == \"PreTrainedTokenizerFast\" else self.fast_tokenizer_class\n            )\n        else:\n            self.tokenizer_class, self.fast_tokenizer_class = None, None\n\n        self.image_processor_classes = IMAGE_PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)\n        self.video_processor_class = VIDEO_PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)\n        self.feature_extractor_class = FEATURE_EXTRACTOR_MAPPING_NAMES.get(self.lowercase_name, None)\n        self.processor_class = PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/add_new_model_like.py#L125-L161","documentation":"Raised by the ModelInfos constructor in the `transformers add-new-model-like` CLI command when the supplied base model name (after lowercasing and normalizing spaces/dashes to underscores, then trying underscores back to dashes) is not a key in CONFIG_MAPPING_NAMES. The command needs a real, registered model type because it derives the config class, tokenizer class, and file structure from it.","triggerScenarios":"Running `transformers add-new-model-like --old_model xxx` where xxx is not in CONFIG_MAPPING_NAMES; typos in the model type; using an unofficial community model type; using a processor/feature-extractor-only name that has no entry in the config mapping.","commonSituations":"Typing `bert-large` instead of the registered `bert`; referring to a model known only by its full repo id (e.g. `meta-llama/Llama-3`) instead of the model type (`llama`); using a very new model type with an older transformers install where it is not yet registered.","solutions":["Use the exact lowercase model type from CONFIG_MAPPING_NAMES (e.g. 'bert', 'llama', 'whisper')","List valid names: python -c \"from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES; print(sorted(CONFIG_MAPPING_NAMES))\"","Fix typos: remove org prefixes, use singular lowercase names","Upgrade transformers if the model type was added in a newer release"],"exampleFix":"# before\ntransformers add-new-model-like --old_model meta-llama/Llama-3\n\n# after\ntransformers add-new-model-like --old_model llama","handlingStrategy":"validation","validationCode":"from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES\n\nname = name.lower().replace(\" \", \"_\").replace(\"-\", \"_\")\nif name not in CONFIG_MAPPING_NAMES and name.replace(\"_\", \"-\") not in CONFIG_MAPPING_NAMES:\n    raise SystemExit(f\"{name} not a valid model type; pick from {sorted(CONFIG_MAPPING_NAMES)[:20]}...\")","typeGuard":"from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES\n\ndef is_valid_model_type(name: str) -> bool:\n    n = name.lower().replace(\" \", \"_\").replace(\"-\", \"_\")\n    return n in CONFIG_MAPPING_NAMES or n.replace(\"_\", \"-\") in CONFIG_MAPPING_NAMES","tryCatchPattern":null,"preventionTips":["Print CONFIG_MAPPING_NAMES keys before running the command","Use the model *type* (bert), never a repo id (google-bert/bert-base-uncased)","Upgrade transformers so recently added model types are registered"],"tags":["cli","valueerror","add-new-model","model-type","developer-tooling"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}