xai-org/x-algorithm · error · ValueError

Unknown model type: {clip_model_type}. Choices: {self.MODELS

Error message

Unknown model type: {clip_model_type}. Choices: {self.MODELS.keys()}

What it means

The CLIP wrapper keeps a MODELS dict of supported clip_model_type strings; __init__ validates membership and raises with the list of choices when an unknown type is requested (e.g. a typo or a variant not compiled into this build).

Source

Thrown at clip/model.py:70

    }

    MODELS = {**PRETRAINED_MODELS, **TWITTER_MODELS}

    MODEL_NAMES = tuple(MODELS.keys())

    def __init__(
        self,
        clip_model_type=DEFAULT_CLIP_MODEL_TYPE,
        top_feedforward=True,
        final_embedding_dim=DEFAULT_FINAL_EMBEDDING_DIM,
        truncate_text=True,
        logit_scale=None,
        use_gpu=None,
    ):
        self.clip_model_type = clip_model_type

        if clip_model_type not in self.MODELS:
            raise ValueError(
                f"Unknown model type: {clip_model_type}. Choices: {self.MODELS.keys()}"
            )

        if clip_model_type in self.PRETRAINED_MODELS:
            self.base_clip_model_type = clip_model_type
        else:
            self.base_clip_model_type = self.TWITTER_MODELS_PRETRAINED_BASE[
                clip_model_type
            ]

        io_utils.maybe_download_file(self.PRETRAINED_MODELS[self.base_clip_model_type])
        self.clip_model, self.torch_preprocess_pretrained = clip.load(
            self.base_clip_model_type, jit=False
        )

        self.image_encoder = ImageCLIP(
            self.clip_model,
            top_feedforward=top_feedforward,

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Print Model.MODELS.keys() and pass one of those exact strings
  2. Check for casing/spacing mismatches in the configured type
  3. If the type should exist, update to a repo version whose MODELS includes it, or register it in MODELS
  4. Pass the base clip type, not a fine-tuned checkpoint name

Example fix

# before
model = Model(clip_model_type='VIT-B/32')
# after
model = Model(clip_model_type='ViT-B/32')
Defensive patterns

Strategy: type-guard

Validate before calling

from clip.model import Model
assert clip_model_type in Model.MODELS, f"choices: {list(Model.MODELS)}"

Type guard

def is_supported_clip_type(t: str) -> bool:
    return t in Model.MODELS

Try / catch

try:
    Model(clip_model_type=t)
except ValueError as e:
    if 'Unknown model type' in str(e):
        t = nearest_known(t)  # or fail config validation
    else:
        raise

Prevention

When it happens

Trigger: Constructing the model with clip_model_type='RN50x16' when MODELS only has 'RN50','RN101','ViT-B/32', etc.; passing a config value with different casing/spacing; referencing a variant added in a newer commit of the repo.

Common situations: Copy-pasted model name from another project; config drift after pulling new code; using a fine-tuned checkpoint name where the base type was expected.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/b3274a82748ff06c. Report an issue: GitHub.