{"id":1026,"hash":"a823c774b23f31369359508c7171dacb837004df12ea4afc63d4cd5f681a1455","pattern":"Transformers model from Hugging-Face throws error that specific classes couldn t be loaded","full_message":"Hi after running this code below, I get the following error.\n\nValueError: Could not load model facebook/bart-large-mnli with any of the following classes: (<class 'transformers.models.auto.modeling_tf_auto.TFAutoModelForSequenceClassification'>,).\n\nimport tensorflow as tf\nfrom transformers import pipeline\n\nclassifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\")\n\nCould someone please help.\nThank you!","ecosystem":"pypi","package_name":"tensorflow","package_version":null,"solution":"I had the same issue! Somebody has commented here that you need to have PyTorch installed (https://github.com/huggingface/transformers/issues/16849).\n\nTo sum it up:\n\nSome models only exist as PyTorch models (e.g. deepset/roberta-base-squad2).\nCalling pipeline() selects the framework (TF or PyTorch) based on what is installed on your machine (or venv in my case)\nIf both are installed, Torch will be selected\nIf you don't have PyTorch installed, it threw above mentioned error\nInstalling PyTorch solved the issue for me!\nIn the GitHub issue, another workaround is mentioned:\nload the model in TF with from_pt=True and save as personal copy as a TF model with save_pretrained and push_to_hub","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/70622895/transformers-model-from-hugging-face-throws-error-that-specific-classes-couldn-t","votes":19,"created_at":"2026-04-19T04:52:12.292082+00:00","updated_at":"2026-04-19T04:52:12.292082+00:00"}