huggingface/transformers · error · ValueError

{lowercase_name} is not a valid model name

Error message

{lowercase_name} is not a valid model name

What it means

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.

Source

Thrown at src/transformers/cli/add_new_model_like.py:143

class ModelInfos:
    """
    Retrieve the basic information about an existing model classes.
    """

    def __init__(self, lowercase_name: str):
        from ..models.auto.configuration_auto import CONFIG_MAPPING_NAMES
        from ..models.auto.feature_extraction_auto import FEATURE_EXTRACTOR_MAPPING_NAMES
        from ..models.auto.image_processing_auto import IMAGE_PROCESSOR_MAPPING_NAMES
        from ..models.auto.processing_auto import PROCESSOR_MAPPING_NAMES
        from ..models.auto.tokenization_auto import TOKENIZER_MAPPING_NAMES
        from ..models.auto.video_processing_auto import VIDEO_PROCESSOR_MAPPING_NAMES

        # Just to make sure it's indeed lowercase
        self.lowercase_name = lowercase_name.lower().replace(" ", "_").replace("-", "_")
        if self.lowercase_name not in CONFIG_MAPPING_NAMES:
            self.lowercase_name.replace("_", "-")
        if self.lowercase_name not in CONFIG_MAPPING_NAMES:
            raise ValueError(f"{lowercase_name} is not a valid model name")

        self.config_class = CONFIG_MAPPING_NAMES[self.lowercase_name]
        self.camelcase_name = self.config_class.replace("Config", "")

        # Get tokenizer class
        if self.lowercase_name in TOKENIZER_MAPPING_NAMES:
            self.tokenizer_class = None
            self.fast_tokenizer_class = TOKENIZER_MAPPING_NAMES[self.lowercase_name]
            self.fast_tokenizer_class = (
                None if self.fast_tokenizer_class == "PreTrainedTokenizerFast" else self.fast_tokenizer_class
            )
        else:
            self.tokenizer_class, self.fast_tokenizer_class = None, None

        self.image_processor_classes = IMAGE_PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)
        self.video_processor_class = VIDEO_PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)
        self.feature_extractor_class = FEATURE_EXTRACTOR_MAPPING_NAMES.get(self.lowercase_name, None)
        self.processor_class = PROCESSOR_MAPPING_NAMES.get(self.lowercase_name, None)

View on GitHub (pinned to a597f97485)

Solutions

  1. Use the exact lowercase model type from CONFIG_MAPPING_NAMES (e.g. 'bert', 'llama', 'whisper')
  2. List valid names: python -c "from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES; print(sorted(CONFIG_MAPPING_NAMES))"
  3. Fix typos: remove org prefixes, use singular lowercase names
  4. Upgrade transformers if the model type was added in a newer release

Example fix

# before
transformers add-new-model-like --old_model meta-llama/Llama-3

# after
transformers add-new-model-like --old_model llama
Defensive patterns

Strategy: validation

Validate before calling

from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES

name = name.lower().replace(" ", "_").replace("-", "_")
if name not in CONFIG_MAPPING_NAMES and name.replace("_", "-") not in CONFIG_MAPPING_NAMES:
    raise SystemExit(f"{name} not a valid model type; pick from {sorted(CONFIG_MAPPING_NAMES)[:20]}...")

Type guard

from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES

def is_valid_model_type(name: str) -> bool:
    n = name.lower().replace(" ", "_").replace("-", "_")
    return n in CONFIG_MAPPING_NAMES or n.replace("_", "-") in CONFIG_MAPPING_NAMES

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14). Data as JSON: /api/errors/2f6f17603a68d416. Report an issue: GitHub.